Class: RuboCop::Cop::PunctuationCorrector
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rubocop/cop/correctors/punctuation_corrector.rb |
Overview
This autocorrects punctuation
Class Method Summary
Class Method Details
.add_space(corrector, token)
[ GitHub ]# File 'lib/rubocop/cop/correctors/punctuation_corrector.rb', line 12
def add_space(corrector, token) corrector.replace(token.pos, "#{token.pos.source} ") end
.remove_space(corrector, space_before)
[ GitHub ]# File 'lib/rubocop/cop/correctors/punctuation_corrector.rb', line 8
def remove_space(corrector, space_before) corrector.remove(space_before) end
.swap_comma(corrector, range)
[ GitHub ]# File 'lib/rubocop/cop/correctors/punctuation_corrector.rb', line 16
def swap_comma(corrector, range) return unless range case range.source when ',' then corrector.remove(range) else corrector.insert_after(range, ',') end end