Class: Rails::Cops::ModelCustomValidationMethodName
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Rails::Cops::ModelCustomValidationMethodName
- Defined in:
- lib/rails/cops/model_custom_validation_method_name.rb
Overview
This is for custom rubocop rule
Constant Summary collapse
- MSG =
'You are using model validation method name without _validation, please add suffix _validation to the method name'.freeze
Instance Method Summary collapse
-
#on_send(node) ⇒ Object
event handler.
Instance Method Details
#on_send(node) ⇒ Object
event handler
15 16 17 18 19 20 |
# File 'lib/rails/cops/model_custom_validation_method_name.rb', line 15 def on_send(node) custom_validation(node) do |method_name, _args| method_node = node.children[2] add_offense(method_node, message: MSG) unless method_name.end_with?('_validation') end end |