Class: Rubocop::Cop::VariableInterpolation
- Defined in:
- lib/rubocop/cop/variable_interpolation.rb
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
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubocop/cop/variable_interpolation.rb', line 6 def inspect(file, source, tokens, sexp) each(:string_dvar, sexp) do |s| interpolation = s[1][0] == :@backref ? s[1] : s[1][1] var = interpolation[1] lineno = interpolation[2].lineno add_offence( :convention, lineno, "Replace interpolated var #{var} with expression \#{#{var}}." ) end end |