Module: Rubocop::Cop::SpaceAfterCommaEtc

Included in:
SpaceAfterColon, SpaceAfterComma, SpaceAfterSemicolon
Defined in:
lib/rubocop/cop/space_after_comma_etc.rb

Constant Summary collapse

MSG =
'Space missing after %s.'

Instance Method Summary collapse

Instance Method Details

#inspect(source, tokens, ast, comments) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rubocop/cop/space_after_comma_etc.rb', line 10

def inspect(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.line, sprintf(MSG, kind(t1)))
    end
  end
end

#offset(token) ⇒ Object

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



21
22
23
# File 'lib/rubocop/cop/space_after_comma_etc.rb', line 21

def offset(token)
  1
end