Class: RuboCop::Cop::Obsession::Rails::ValidationMethodName

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

Overview

This cop checks for validation methods that do not start with ‘validate_`.

Examples:


# bad
validate :at_least_one_admin

# good
validate :validate_at_least_one_admin

Constant Summary collapse

MSG =
'Prefix custom validation method with validate_'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



23
24
25
26
27
# File 'lib/rubocop/cop/obsession/rails/validation_method_name.rb', line 23

def on_send(node)
  on_validate_callback(node) do |method_name|
    add_offense(node) if !method_name.start_with?('validate_')
  end
end