Class: RuboCop::Cop::SketchupRequirements::GlobalConstants

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

Overview

Extensions in SketchUp all share the same Ruby environment on the user’s machine. Because of this it’s important that each extension isolate itself to avoid clashing with other extensions.

Extensions submitted to Extension Warehouse is expected to not define global constants.

Constant Summary collapse

MSG =
'Do not introduce global constants.'

Constants included from SketchUp

SketchUp::CONFIG, SketchUp::VERSION

Constants inherited from SketchUp::Cop

SketchUp::Cop::SKETCHUP_DEPARTMENT_SEVERITY

Constants included from SketchUp::Config

SketchUp::Config::DEFAULT_CONFIGURATION

Instance Method Summary collapse

Methods inherited from SketchUp::Cop

inherited, #relevant_file?

Instance Method Details

#on_casgn(node) ⇒ Object

Constant assignment.



26
27
28
29
30
31
32
33
# File 'lib/rubocop/sketchup/cop/requirements/global_constants.rb', line 26

def on_casgn(node)
  return if namespaced_constant?(node)

  namespace = Namespace.new(node.parent_module_name)
  return unless namespace.top_level?

  add_offense(node, location: :name)
end