Sha256: 5e67b97c96dc2736e4e0e71ababf2cdb6363d1f157617bbcd4d24bd4b0fcbb16
Contents?: true
Size: 884 Bytes
Versions: 8
Compression:
Stored size: 884 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| next unless kind(t1) && t1.pos.line == t2.pos.line && t2.pos.column == t1.pos.column + offset && ![:tRPAREN, :tRBRACK].include?(t2.type) add_offense(t1, t1.pos, format(MSG, kind(t1))) end end # The normal offset, i.e., the distance from the punctuation # token where a space should be, is 1. def offset 1 end def autocorrect(token) @corrections << lambda do |corrector| corrector.replace(token.pos, token.pos.source + ' ') end end end end end
Version data entries
8 entries across 8 versions & 2 rubygems