Class: RuboCop::Cop::SketchupRequirements::GlobalMethods

Inherits:
RuboCop::Cop
  • Object
show all
Includes:
OnMethodDef, NoCommentDisable, RuboCop::Cop::SketchUp
Defined in:
lib/rubocop/sketchup/requirements/global_methods.rb

Constant Summary collapse

MSG =
'Do not introduce global methods.'.freeze

Instance Method Summary collapse

Instance Method Details

#on_method_def(node, method_name, _args, _body) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/rubocop/sketchup/requirements/global_methods.rb', line 40

def on_method_def(node, method_name, _args, _body)
  class_method_parent = class_method(node)
  if class_method_parent
    namespace = Namespace.new(class_method_parent.to_s)
  else
    namespace = Namespace.new(node.parent_module_name)
  end
  add_offense(node, :name, nil, :error) if namespace.top_level?
end