Class: RuboCop::Cop::Rails::DelegateAllowBlank
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::DelegateAllowBlank
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rails/delegate_allow_blank.rb
Overview
Looks for delegations that pass :allow_blank as an option instead of :allow_nil. :allow_blank is not a valid option to pass to ActiveSupport#delegate.
Constant Summary collapse
- MSG =
'`allow_blank` is not a valid option, use `allow_nil`.'
- RESTRICT_ON_SEND =
%i[delegate].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rubocop/cop/rails/delegate_allow_blank.rb', line 26 def on_send(node) return unless (offending_node = allow_blank_option(node)) add_offense(offending_node) do |corrector| corrector.replace(offending_node.key, 'allow_nil') end end |