class RuboCop::Cop::PunctuationCorrector

This auto-corrects punctuation

Public Class Methods

add_space(token) click to toggle source
# File lib/rubocop/cop/correctors/punctuation_corrector.rb, line 12
def add_space(token)
  ->(corrector) { corrector.replace(token.pos, token.pos.source + ' ') }
end
remove_space(space_before) click to toggle source
# File lib/rubocop/cop/correctors/punctuation_corrector.rb, line 8
def remove_space(space_before)
  ->(corrector) { corrector.remove(space_before) }
end
swap_comma(range) click to toggle source
# File lib/rubocop/cop/correctors/punctuation_corrector.rb, line 16
def swap_comma(range)
  return unless range

  lambda do |corrector|
    case range.source
    when ',' then corrector.remove(range)
    else          corrector.insert_after(range, ',')
    end
  end
end