Module: Rubocop::Cop::Style::SpaceInside
- Includes:
- SurroundingSpace
- Included in:
- SpaceInsideBrackets, SpaceInsideParens
- Defined in:
- lib/rubocop/cop/style/surrounding_space.rb
Overview
Common functionality for checking for spaces inside various kinds of parentheses.
Constant Summary collapse
- MSG =
'Space inside %s detected.'
Instance Method Summary collapse
Methods included from SurroundingSpace
#index_of_first_token, #index_of_last_token, #space_between?, #token_table
Instance Method Details
#investigate(processed_source) ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/rubocop/cop/style/surrounding_space.rb', line 250 def investigate(processed_source) @processed_source = processed_source left, right, kind = specifics processed_source.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) range = Parser::Source::Range.new(processed_source.buffer, t1.pos.end_pos, t2.pos.begin_pos) convention(nil, range, format(MSG, kind)) end end end end |