Class: Rubocop::Cop::SpaceAfterCommaEtc
- Defined in:
- lib/rubocop/cop/space_after_comma_etc.rb
Constant Summary collapse
- ERROR_MESSAGE =
'Space missing after %s.'
Instance Attribute Summary
Attributes inherited from Cop
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, enabled?, #has_report?, inherited, #initialize, #inspect_source
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 19 20 21 |
# File 'lib/rubocop/cop/space_after_comma_etc.rb', line 6 def inspect(file, source, tokens, sexp) tokens.each_index { |ix| pos, name, text = tokens[ix] kind = case name when :on_comma then 'comma' when :on_label then 'colon' when :on_op then 'colon' if text == ':' when :on_semicolon then 'semicolon' end if kind and not [:on_sp, :on_ignored_nl].include?(tokens[ix + 1][1]) index = pos[0] - 1 add_offence(:convention, index, source[index], ERROR_MESSAGE % kind) end } end |