lib/rubocop/cop/style/special_global_vars.rb in rubocop-0.47.1 vs lib/rubocop/cop/style/special_global_vars.rb in rubocop-0.48.0
- old
+ new
@@ -17,23 +17,23 @@
:$: => [:$LOAD_PATH],
:$" => [:$LOADED_FEATURES],
:$0 => [:$PROGRAM_NAME],
:$! => [:$ERROR_INFO],
:$@ => [:$ERROR_POSITION],
- :$; => [:$FIELD_SEPARATOR, :$FS],
- :$, => [:$OUTPUT_FIELD_SEPARATOR, :$OFS],
- :$/ => [:$INPUT_RECORD_SEPARATOR, :$RS],
- :$\ => [:$OUTPUT_RECORD_SEPARATOR, :$ORS],
- :$. => [:$INPUT_LINE_NUMBER, :$NR],
+ :$; => %i($FIELD_SEPARATOR $FS),
+ :$, => %i($OUTPUT_FIELD_SEPARATOR $OFS),
+ :$/ => %i($INPUT_RECORD_SEPARATOR $RS),
+ :$\ => %i($OUTPUT_RECORD_SEPARATOR $ORS),
+ :$. => %i($INPUT_LINE_NUMBER $NR),
:$_ => [:$LAST_READ_LINE],
:$> => [:$DEFAULT_OUTPUT],
:$< => [:$DEFAULT_INPUT],
- :$$ => [:$PROCESS_ID, :$PID],
+ :$$ => %i($PROCESS_ID $PID),
:$? => [:$CHILD_STATUS],
:$~ => [:$LAST_MATCH_INFO],
:$= => [:$IGNORECASE],
- :$* => [:$ARGV, :ARGV],
+ :$* => %i($ARGV ARGV),
:$& => [:$MATCH],
:$` => [:$PREMATCH],
:$' => [:$POSTMATCH],
:$+ => [:$LAST_PAREN_MATCH]
}
@@ -49,16 +49,16 @@
)
ENGLISH_VARS.each { |_, v| v.freeze }.freeze
PERL_VARS.each { |_, v| v.freeze }.freeze
# Anything *not* in this set is provided by the English library.
- NON_ENGLISH_VARS = Set.new([
- :$LOAD_PATH,
- :$LOADED_FEATURES,
- :$PROGRAM_NAME,
- :ARGV
- ]).freeze
+ NON_ENGLISH_VARS = Set.new(%i(
+ $LOAD_PATH
+ $LOADED_FEATURES
+ $PROGRAM_NAME
+ ARGV
+ )).freeze
def on_gvar(node)
global_var, = *node
return unless (preferred = preferred_names(global_var))
@@ -124,10 +124,10 @@
def replacement(node, global_var)
parent_type = node.parent && node.parent.type
preferred_name = preferred_names(global_var).first
- unless [:dstr, :xstr, :regexp].include?(parent_type)
+ unless %i(dstr xstr regexp).include?(parent_type)
return preferred_name.to_s
end
if style == :use_english_names
return english_name_replacement(preferred_name, node)