Module: Rubocop::Cop::Style::SpaceAfterCommaEtc
- Included in:
- SpaceAfterColon, SpaceAfterComma, SpaceAfterSemicolon
- Defined in:
- lib/rubocop/cop/style/space_after_comma_etc.rb
Overview
Common functionality for cops checking for missing space after punctuation.
Constant Summary collapse
- MSG =
'Space missing after %s.'
Instance Method Summary collapse
- #investigate(processed_source) ⇒ Object
-
#offset(token) ⇒ Object
The normal offset, i.e., the distance from the punctuation token where a space should be, is 1.
Instance Method Details
#investigate(processed_source) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/rubocop/cop/style/space_after_comma_etc.rb', line 13 def investigate(processed_source) processed_source.tokens.each_cons(2) do |t1, t2| if kind(t1) && t1.pos.line == t2.pos.line && t2.pos.column == t1.pos.column + offset(t1) convention(nil, t1.pos, 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.
24 25 26 |
# File 'lib/rubocop/cop/style/space_after_comma_etc.rb', line 24 def offset(token) 1 end |