Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::SpaceInside

Common functionality for checking for spaces inside various kinds of parentheses.

Constants

MSG

Public Instance Methods

autocorrect(range) click to toggle source
# File lib/rubocop/cop/mixin/space_inside.rb, line 28
def autocorrect(range)
  @corrections << ->(corrector) { corrector.remove(range) }
end
investigate(processed_source) click to toggle source
# File lib/rubocop/cop/mixin/space_inside.rb, line 10
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.