Sha256: 2347b26f902f84e50a7ae001e5a07efd15f37ef303eca831dd18248e27c60ab3
Contents?: true
Size: 871 Bytes
Versions: 2
Compression:
Stored size: 871 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop # Common functionality for cops checking for missing space after # punctuation. module SpaceAfterPunctuation MSG = 'Space missing after %s.' 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) && t2.type != :tRPAREN add_offense(t1, t1.pos, format(MSG, kind(t1))) end end end # The normal offset, i.e., the distance from the punctuation # token where a space should be, is 1. def offset(token) 1 end def autocorrect(token) @corrections << lambda do |corrector| corrector.insert_after(token.pos, ' ') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | lib/rubocop/cop/mixin/space_after_punctuation.rb |
rubocop-0.19.0 | lib/rubocop/cop/mixin/space_after_punctuation.rb |