Class: RuboCop::Cop::Legion::Extension::DefinitionCallMismatched
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Legion::Extension::DefinitionCallMismatched
- Defined in:
- lib/rubocop/cop/legion/extension/definition_call_mismatched.rb
Overview
Detects ‘definition :method_name` DSL calls inside runner modules where no corresponding `def method_name` exists. A mismatched definition means the framework advertises a runner function that doesn’t exist, causing a NoMethodError at dispatch time.
Constant Summary collapse
- MSG =
'`definition :%<name>s` has no matching `def %<name>s` method.'
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubocop/cop/legion/extension/definition_call_mismatched.rb', line 34 def on_send(node) return unless node.method_name == :definition return unless node.receiver.nil? return unless node.first_argument&.sym_type? defined_name = node.first_argument.value enclosing = enclosing_module_or_class(node) return unless enclosing return if defines_method?(enclosing, defined_name) add_offense(node, message: format(MSG, name: defined_name)) end |