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.".freeze
LH_GLOBALS =
%i[
  $dc_strings
  $devl_strings
  $exStrings
  $fs_strings
  $make_pano_string
  $oceanStrings
  $sn_strings
  $ssf_strings
  $suStrings
  $tStrings
  $unitsStrings
  $uStrings
  $wt_strings
]

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)

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

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

#on_gvasgn(node) ⇒ Object


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

def on_gvasgn(node)
  global_var, = *node
  return unless hl_global_var?(global_var)
  add_offense(node, location: :name, severity: :error)
end