Class: RuboCop::Cop::Obsession::Rails::ShortValidate

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/obsession/rails/short_validate.rb

Overview

This cop checks for ‘validate` declarations that could be shorter.

Examples:


# bad
validate :validate_url, on: %i(create update)

# good
validate :validate_url

Constant Summary collapse

MSG =
'The `on:` argument is not needed in this validate.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



29
30
31
# File 'lib/rubocop/cop/obsession/rails/short_validate.rb', line 29

def on_send(node)
  add_offense(node) if validate_with_unneeded_on?(node)
end