Class: RuboCop::Cop::SketchupRequirements::GlobalMethods
- Inherits:
-
SketchUp::Cop
- Object
- SketchUp::WorkaroundCop
- SketchUp::Cop
- RuboCop::Cop::SketchupRequirements::GlobalMethods
- Includes:
- SketchUp, SketchUp::NoCommentDisable
- Defined in:
- lib/rubocop/sketchup/cop/requirements/global_methods.rb
Constant Summary collapse
- MSG =
'Do not introduce global methods.'.freeze
Constants included from SketchUp
SketchUp::CONFIG, SketchUp::VERSION
Constants included from SketchUp::Config
SketchUp::Config::DEFAULT_CONFIGURATION
Instance Method Summary collapse
- #on_def(node) ⇒ Object (also: #on_defs)
Methods inherited from SketchUp::Cop
Instance Method Details
#on_def(node) ⇒ Object Also known as: on_defs
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rubocop/sketchup/cop/requirements/global_methods.rb', line 39 def on_def(node) if class_method?(node) class_method_parent = class_method(node) namespace = Namespace.new(class_method_parent.to_s) else # If a method is defined inside a block then parent_module_name # will return nil. return if node.parent_module_name.nil? namespace = Namespace.new(node.parent_module_name) end add_offense(node, location: :name, severity: :error) if namespace.top_level? end |