class RuboCop::Cop::Layout::SpaceAfterComma

Checks for comma (,) not followed by some kind of space.

@example

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

Public Instance Methods

kind(token) click to toggle source
# File lib/rubocop/cop/layout/space_after_comma.rb, line 26
def kind(token)
  'comma' if token.comma? && !before_semicolon?(token)
end
space_style_before_rcurly() click to toggle source
# File lib/rubocop/cop/layout/space_after_comma.rb, line 21
def space_style_before_rcurly
  cfg = config.for_cop('Layout/SpaceInsideHashLiteralBraces')
  cfg['EnforcedStyle'] || 'space'
end

Private Instance Methods

before_semicolon?(token) click to toggle source
# File lib/rubocop/cop/layout/space_after_comma.rb, line 32
def before_semicolon?(token)
  tokens = processed_source.tokens

  tokens[tokens.index(token) + 1].semicolon?
end