Sha256: 79ec5c70914230c4681f06e98a694753906d4fb58f3d20a7a0aea29862a0ac6f
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# encoding: utf-8 module Rubocop module Cop # Common functionality for checking for spaces inside various # kinds of parentheses. module SpaceInside include SurroundingSpace MSG = 'Space inside %s detected.' def investigate(processed_source) @processed_source = processed_source left, right, kind = specifics processed_source.tokens.each_cons(2) do |t1, t2| next unless t1.type == left || t2.type == right # If the second token is a comment, that means that a line break # follows, and that the rules for space inside don't apply. next if t2.type == :tCOMMENT next unless t2.pos.line == t1.pos.line && space_between?(t1, t2) range = Parser::Source::Range.new(processed_source.buffer, t1.pos.end_pos, t2.pos.begin_pos) add_offense(range, range, format(MSG, kind)) end end def autocorrect(range) @corrections << ->(corrector) { corrector.remove(range) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.22.0 | lib/rubocop/cop/mixin/space_inside.rb |