Class: RuboCop::Cop::Rails::ActionFilter
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Rails::ActionFilter
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rails/action_filter.rb
Overview
This cop enforces the consistent use of action filter methods.
The cop is configurable and can enforce the use of the older something_filter methods or the newer something_action methods.
Constant Summary collapse
- MSG =
'Prefer `%<prefer>s` over `%<current>s`.'
- FILTER_METHODS =
%i[ after_filter append_after_filter append_around_filter append_before_filter around_filter before_filter prepend_after_filter prepend_around_filter prepend_before_filter skip_after_filter skip_around_filter skip_before_filter skip_filter ].freeze
- ACTION_METHODS =
%i[ after_action append_after_action append_around_action append_before_action around_action before_action prepend_after_action prepend_around_action prepend_before_action skip_after_action skip_around_action skip_before_action skip_action_callback ].freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/rubocop/cop/rails/action_filter.rb', line 77 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.selector, preferred_method(node.loc.selector.source).to_s) end end |
#on_block(node) ⇒ Object
69 70 71 |
# File 'lib/rubocop/cop/rails/action_filter.rb', line 69 def on_block(node) check_method_node(node.send_node) end |
#on_send(node) ⇒ Object
73 74 75 |
# File 'lib/rubocop/cop/rails/action_filter.rb', line 73 def on_send(node) check_method_node(node) unless node.receiver end |