module Rubocop::Cop::Style::SpaceAfterCommaEtc

Common functionality for cops checking for missing space after punctuation.

Constants

MSG

Public Instance Methods

inspect(source_buffer, source, tokens, ast, comments) click to toggle source
# File lib/rubocop/cop/style/space_after_comma_etc.rb, line 13
def inspect(source_buffer, source, tokens, ast, comments)
  tokens.each_cons(2) do |t1, t2|
    if kind(t1) && t1.pos.line == t2.pos.line &&
        t2.pos.column == t1.pos.column + offset(t1)
      add_offence(:convention, t1.pos, sprintf(MSG, kind(t1)))
    end
  end
end
offset(token) click to toggle source

The normal offset, i.e., the distance from the punctuation token where a space should be, is 1.

# File lib/rubocop/cop/style/space_after_comma_etc.rb, line 24
def offset(token)
  1
end