class RuboCop::Cop::Rails::ActionFilter
skip_after_filter :do_stuff
append_around_filter :do_stuff
after_filter :do_stuff
# good
skip_after_action :do_stuff
append_around_action :do_stuff
after_action :do_stuff
# bad
@example EnforcedStyle: filter
skip_after_action :do_stuff
append_around_action :do_stuff
after_action :do_stuff
# good
skip_after_filter :do_stuff
append_around_filter :do_stuff
after_filter :do_stuff
# bad
@example EnforcedStyle: action (default)
and that Rails version is no longer supported by RuboCop Rails. This cop will be removed in RuboCop Rails 3.0.
IMPORTANT: This cop is deprecated. Because the ‘*_filter` methods were removed in Rails 4.2,
something_filter methods or the newer something_action methods.
The cop is configurable and can enforce the use of the older
Enforces the consistent use of action filter methods.
def bad_methods
def bad_methods style == :action ? FILTER_METHODS : ACTION_METHODS end
def check_method_node(node)
def check_method_node(node) method_name = node.method_name return unless bad_methods.include?(method_name) message = format(MSG, prefer: preferred_method(method_name), current: method_name) add_offense(node.loc.selector, message: message) do |corrector| corrector.replace(node.loc.selector, preferred_method(node.loc.selector.source)) end end
def good_methods
def good_methods style == :action ? ACTION_METHODS : FILTER_METHODS end
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler check_method_node(node.send_node) end
def on_send(node)
def on_send(node) check_method_node(node) unless node.receiver end
def preferred_method(method)
def preferred_method(method) good_methods[bad_methods.index(method.to_sym)] end