Class: RuboCop::Cop::Rails::DelegateAllowBlank
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Rails::DelegateAllowBlank
- Defined in:
- lib/rubocop/cop/rails/delegate_allow_blank.rb
Overview
This cop 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`.'
Instance Method Summary collapse
Instance Method Details
#autocorrect(pair_node) ⇒ Object
29 30 31 32 33 |
# File 'lib/rubocop/cop/rails/delegate_allow_blank.rb', line 29 def autocorrect(pair_node) lambda do |corrector| corrector.replace(pair_node.key.source_range, 'allow_nil') end end |
#on_send(node) ⇒ Object
23 24 25 26 27 |
# File 'lib/rubocop/cop/rails/delegate_allow_blank.rb', line 23 def on_send(node) allow_blank_option(node) do |offending_node| add_offense(offending_node) end end |