Class: RuboCop::Cop::SpaceCorrector
- Inherits:
-
Object
- Object
- RuboCop::Cop::SpaceCorrector
- Extended by:
- SurroundingSpace
- Defined in:
- lib/rubocop/cop/correctors/space_corrector.rb
Overview
This auto-corrects whitespace
Constant Summary
Constants included from SurroundingSpace
RuboCop::Cop::SurroundingSpace::NO_SPACE_COMMAND, RuboCop::Cop::SurroundingSpace::SPACE_COMMAND
Class Attribute Summary collapse
-
.processed_source ⇒ Object
readonly
Returns the value of attribute processed_source.
Class Method Summary collapse
- .add_space(processed_source, corrector, left_token, right_token) ⇒ Object
- .remove_space(processed_source, corrector, left_token, right_token) ⇒ Object
Class Attribute Details
.processed_source ⇒ Object (readonly)
Returns the value of attribute processed_source.
10 11 12 |
# File 'lib/rubocop/cop/correctors/space_corrector.rb', line 10 def processed_source @processed_source end |
Class Method Details
.add_space(processed_source, corrector, left_token, right_token) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/rubocop/cop/correctors/space_corrector.rb', line 23 def add_space(processed_source, corrector, left_token, right_token) @processed_source = processed_source unless left_token.space_after? corrector.insert_after(left_token.pos, ' ') end return if right_token.space_before? corrector.insert_before(right_token.pos, ' ') end |
.remove_space(processed_source, corrector, left_token, right_token) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rubocop/cop/correctors/space_corrector.rb', line 12 def remove_space(processed_source, corrector, left_token, right_token) @processed_source = processed_source if left_token.space_after? range = side_space_range(range: left_token.pos, side: :right) corrector.remove(range) end return unless right_token.space_before? range = side_space_range(range: right_token.pos, side: :left) corrector.remove(range) end |