class RuboCop::Cop::Rails::ActionFilter

something_filter methods or the newer something_action methods.
The cop is configurable and the enforce the use of older
This cop enforces the consistent use of action filters methods.

def autocorrect(node)

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.loc.selector,
                      preferred_method(node.loc.selector.source).to_s)
  end
end

def bad_methods

def bad_methods
  style == :action ? FILTER_METHODS : ACTION_METHODS
end

def check_method_node(node)

def check_method_node(node)
  _receiver, method_name, *_args = *node
  return unless offending_method?(method_name)
  add_offense(node, :selector,
              format(MSG,
                     preferred_method(method_name),
                     method_name)
             )
end

def good_methods

def good_methods
  style == :action ? ACTION_METHODS : FILTER_METHODS
end

def offending_method?(method_name)

def offending_method?(method_name)
  bad_methods.include?(method_name)
end

def on_block(node)

def on_block(node)
  method, _args, _body = *node
  check_method_node(method)
end

def on_send(node)

def on_send(node)
  receiver, _method_name, *_args = *node
  check_method_node(node) if receiver.nil?
end

def preferred_method(method)

def preferred_method(method)
  good_methods[bad_methods.index(method.to_sym)]
end