module Rubocop::Cop::Style::SpaceInside

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

Constants

MSG

Public Instance Methods

inspect(source_buffer, source, tokens, sexp, comments) click to toggle source
# File lib/rubocop/cop/style/surrounding_space.rb, line 225
def inspect(source_buffer, source, tokens, sexp, comments)
  @source = source
  left, right, kind = specifics
  tokens.each_cons(2) do |t1, t2|
    if t1.type == left || t2.type == right
      if t2.pos.line == t1.pos.line && space_between?(t1, t2)
        space_range = Parser::Source::Range.new(source_buffer,
                                                t1.pos.end_pos,
                                                t2.pos.begin_pos)
        add_offence(:convention, space_range, format(MSG, kind))
      end
    end
  end
end