Class: Rubocop::Cop::AvoidPerlisms
- Defined in:
- lib/rubocop/cop/avoid_perlisms.rb
Constant Summary collapse
- PREFERRED_VARS =
{ '$:' => '$LOAD_PATH', '$"' => '$LOADED_FEATURES', '$0' => '$PROGRAM_NAME', '$1' => 'MatchData', '$2' => 'MatchData', '$3' => 'MatchData', '$4' => 'MatchData', '$5' => 'MatchData', '$6' => 'MatchData', '$7' => 'MatchData', '$8' => 'MatchData', '$9' => 'MatchData', '$!' => '$ERROR_INFO', '$@' => '$ERROR_POSITION', '$;' => '$FIELD_SEPARATOR', '$,' => '$OUTPUT_FIELD_SEPARATOR', '$/' => '$INPUT_RECORD_SEPARATOR', '$\\' => 'OUTPUT_RECORD_SEPARATOR', '$.' => '$INPUT_LINE_NUMBER', '$_' => '$LAST_READ_LINE', '$>' => '$DEFAULT_OUTPUT', '$<' => '$DEFAULT_INPUT', '$$' => '$PROCESS_ID', '$?' => '$CHILD_STATUS', '$~' => '$LAST_MATCH_INFO', '$=' => '$IGNORECASE', '$*' => '$ARGV', '$&' => '$MATCH', '$`' => '$PREMATCH', '$\'' => 'POSTMATCH', '$+' => '$LAST_PAREN_MATCH' }
Instance Attribute Summary
Attributes inherited from Cop
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, #has_report?, inherited, #initialize
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#inspect(file, source, tokens, sexp) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubocop/cop/avoid_perlisms.rb', line 40 def inspect(file, source, tokens, sexp) each(:@gvar, sexp) do |s| global_var = s[1] if PREFERRED_VARS[global_var] add_offence( :convention, s[2].lineno, "Prefer #{PREFERRED_VARS[global_var]} over #{global_var}." ) end end end |