Class: RuboCop::Cop::PunctuationCorrector
- Inherits:
-
Object
- Object
- RuboCop::Cop::PunctuationCorrector
- Defined in:
- lib/rubocop/cop/correctors/punctuation_corrector.rb
Overview
This autocorrects punctuation
Class Method Summary collapse
- .add_space(corrector, token) ⇒ Object
- .remove_space(corrector, space_before) ⇒ Object
- .swap_comma(corrector, range) ⇒ Object
Class Method Details
.add_space(corrector, token) ⇒ Object
12 13 14 |
# 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) ⇒ Object
8 9 10 |
# 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) ⇒ Object
16 17 18 19 20 21 22 23 |
# 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 |