class Rubocop::Cop::Style::SpaceAfterColon

Checks for colon (:) not follwed by some kind of space.

Public Instance Methods

kind(token) click to toggle source
# File lib/rubocop/cop/style/space_after_comma_etc.rb, line 61
def kind(token)
  case token.type
  when :tLABEL, :tCOLON then 'colon'
  end
end
offset(token) click to toggle source

The colon following a label will not appear in the token array. Instad we get a tLABEL token, whose length we use to calculate where we expect a space.

# File lib/rubocop/cop/style/space_after_comma_etc.rb, line 54
def offset(token)
  case token.type
  when :tLABEL then token.text.length + 1
  when :tCOLON then 1
  end
end