Class: RuboCop::Cop::SketchupRequirements::LoadPath
Overview
Do not modify the load path. Modifying ‘$LOAD_PATH` is bad practice because it can cause extensions to inadvertently load the wrong file.
Constant Summary
collapse
- MSG =
'Do not modify the load path.'
- LOAD_PATH_ALIASES =
%i[
$: $LOAD_PATH
].freeze
- MUTATORS =
%i[
<<
[]=
clear
collect!
compact!
concat
delete
delete_at
delete_if
drop
drop_while
fill
flatten!
insert
keep_if
map!
pop
push
reject!
replace
reverse!
rotate!
select!
shift
shuffle!
slice!
sort!
sort_by!
uniq!
unshift
].freeze
SketchUp::Cop::SKETCHUP_DEPARTMENT_SEVERITY
SketchUp::Config::DEFAULT_CONFIGURATION
Instance Method Summary
collapse
inherited, #relevant_file?
Instance Method Details
#load_path?(sym) ⇒ Boolean
58
59
60
|
# File 'lib/rubocop/sketchup/cop/requirements/load_path.rb', line 58
def load_path?(sym)
LOAD_PATH_ALIASES.include?(sym)
end
|
#mutator?(sym) ⇒ Boolean
62
63
64
|
# File 'lib/rubocop/sketchup/cop/requirements/load_path.rb', line 62
def mutator?(sym)
MUTATORS.include?(sym)
end
|
#on_gvasgn(node) ⇒ Object
66
67
68
69
70
71
|
# 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) ⇒ Object
73
74
75
76
77
78
|
# 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
|