Class: RuboCop::Cop::Rake::ClassDefinitionInTask
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rake::ClassDefinitionInTask
- Defined in:
- lib/rubocop/cop/rake/class_definition_in_task.rb
Overview
This cop detects class or module 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 %<type>s in rake task, because it will be defined to the top level.'
Instance Method Summary collapse
- #on_class(node) ⇒ Object (also: #on_module)
Instance Method Details
#on_class(node) ⇒ Object Also known as: on_module
34 35 36 37 38 39 |
# File 'lib/rubocop/cop/rake/class_definition_in_task.rb', line 34 def on_class(node) return if Helper::ClassDefinition.in_class_definition?(node) return unless Helper::TaskDefinition.in_task_or_namespace?(node) add_offense(node, message: format(MSG, type: node.type)) end |