Module: Rubocop::Cop::SpaceInside

Includes:
SurroundingSpace
Included in:
SpaceInsideBrackets, SpaceInsideParens
Defined in:
lib/rubocop/cop/surrounding_space.rb

Constant Summary collapse

MSG =
'Space inside %s detected.'

Instance Method Summary collapse

Methods included from SurroundingSpace

#build_token_table, #index_of_first_token, #index_of_last_token, #space_between?

Instance Method Details

#inspect(source, tokens, sexp, comments) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
# File 'lib/rubocop/cop/surrounding_space.rb', line 211

def inspect(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)
        add_offence(:convention, t1.pos.line, MSG % kind)
      end
    end
  end
end