Module: Rubocop::Cop::SpaceInside
- Includes:
- SurroundingSpace
- Included in:
- SpaceInsideBrackets, SpaceInsideParens
- Defined in:
- lib/rubocop/cop/surrounding_space.rb
Defined Under Namespace
Classes: Paren
Instance Method Summary collapse
Methods included from SurroundingSpace
Instance Method Details
#check_unwanted_space(tokens, ix) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rubocop/cop/surrounding_space.rb', line 93 def check_unwanted_space(tokens, ix) paren = get_paren prev, t, nxt = tokens.values_at(ix - 1, ix, ix + 1) offence_detected = case t.type when paren.left nxt.type == :on_sp when paren.right if prev.type == :on_sp prev_ns = previous_non_space(tokens, ix) prev_ns && prev_ns.pos.lineno == tokens[ix].pos.lineno && # Avoid double reporting prev_ns.type != paren.left end end if offence_detected add_offence(:convention, t.pos.lineno, "Space inside #{paren.kind} detected.") end end |