Class: RuboCop::Cop::SketchupRequirements::LanguageHandlerGlobals

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

Overview

Avoid using globals in general, but especially these which are known to be in use by other extensions made by SketchUp. They are still in use due to compatibility reasons.

Constant Summary collapse

MSG =
'Avoid globals in general, but especially these which are known '\
'to be in use.'
LH_GLOBALS =
%i[
  $dc_strings
  $devl_strings
  $exStrings
  $fs_strings
  $make_pano_string
  $oceanStrings
  $sn_strings
  $ssf_strings
  $suStrings
  $tStrings
  $unitsStrings
  $uStrings
  $wt_strings
].freeze

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

#hl_global_var?(global_var) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb', line 32

def hl_global_var?(global_var)
  LH_GLOBALS.include?(global_var)
end

#on_gvasgn(node) ⇒ Object



36
37
38
39
40
41
# File 'lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb', line 36

def on_gvasgn(node)
  global_var, = *node
  return unless hl_global_var?(global_var)

  add_offense(node, location: :name)
end