class RuboCop::Cop::SketchupRequirements::LoadPath

Do not modify the load path. Modifying `$LOAD_PATH` is bad practice because it can cause extensions to inadvertently load the wrong file.

Constants

LOAD_PATH_ALIASES
MSG
MUTATORS

Public Instance Methods

load_path?(sym) click to toggle source
# File lib/rubocop/sketchup/cop/requirements/load_path.rb, line 58
def load_path?(sym)
  LOAD_PATH_ALIASES.include?(sym)
end
mutator?(sym) click to toggle source
# File lib/rubocop/sketchup/cop/requirements/load_path.rb, line 62
def mutator?(sym)
  MUTATORS.include?(sym)
end
on_gvasgn(node) click to toggle source
# File lib/rubocop/sketchup/cop/requirements/load_path.rb, line 66
def on_gvasgn(node)
  global_var, = *node
  return unless load_path?(global_var)

  add_offense(node, location: :expression)
end
on_send(node) click to toggle source
# File lib/rubocop/sketchup/cop/requirements/load_path.rb, line 73
def on_send(node)
  method_name = load_path_mutator?(node)
  return unless method_name

  add_offense(node, location: :expression)
end