Class: Rubocop::Cop::FavorJoin
Constant Summary collapse
- ERROR_MESSAGE =
'Favor Array#join over Array#*.'
Instance Attribute Summary
Attributes inherited from Cop
#correlations, #debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, cop_name, #has_report?, inherited, #initialize, #name
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#inspect(file, source, tokens, sexp) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rubocop/cop/favor_join.rb', line 8 def inspect(file, source, tokens, sexp) each(:binary, sexp) do |s| op1 = s[1] operator = s[2] op2 = s[3] # we care only about the * operator next unless matching?(operator, op1, op2) pos = all_positions(s[1]).first lineno = pos.lineno if pos add_offence( :convention, lineno, ERROR_MESSAGE ) if lineno end end |