Class: RuboCop::Cop::Rake::MethodDefinitionInTask
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rake::MethodDefinitionInTask
- Defined in:
- lib/rubocop/cop/rake/method_definition_in_task.rb
Overview
This cop detects method definition in a task or namespace, because it is defined to the top level. It is confusing because the scope looks in the task or namespace, but actually it is defined to the top level.
Constant Summary collapse
- MSG =
'Do not define a method in rake task, because it will be defined to the top level.'
Instance Method Summary collapse
- #on_def(node) ⇒ Object (also: #on_defs)
Instance Method Details
#on_def(node) ⇒ Object Also known as: on_defs
36 37 38 39 40 41 |
# File 'lib/rubocop/cop/rake/method_definition_in_task.rb', line 36 def on_def(node) return if Helper::ClassDefinition.in_class_definition?(node) return unless Helper::TaskDefinition.in_task_or_namespace?(node) add_offense(node) end |