class RuboCop::Cop::Rails::Validation

This cop checks for the use of old-style attribute validation macros.

Constants

BLACKLIST
MSG
WHITELIST

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/rails/validation.rb, line 34
def on_send(node)
  receiver, method_name, *_args = *node
  return unless receiver.nil? && BLACKLIST.include?(method_name)

  add_offense(node,
              :selector,
              format(MSG,
                     preferred_method(method_name),
                     method_name))
end

Private Instance Methods

preferred_method(method) click to toggle source
# File lib/rubocop/cop/rails/validation.rb, line 47
def preferred_method(method)
  WHITELIST[BLACKLIST.index(method.to_sym)]
end