Class: RuboCop::Cop::ParenthesesCorrector
- Inherits:
-
Object
- Object
- RuboCop::Cop::ParenthesesCorrector
- Extended by:
- RangeHelp
- Defined in:
- lib/rubocop/cop/correctors/parentheses_corrector.rb
Overview
This autocorrects parentheses
Constant Summary collapse
- COMMA_REGEXP =
/(?<=\))\s*,/.freeze
Constants included from RangeHelp
RangeHelp::BYTE_ORDER_MARK, RangeHelp::NOT_GIVEN
Class Method Summary collapse
Class Method Details
.correct(corrector, node) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rubocop/cop/correctors/parentheses_corrector.rb', line 12 def correct(corrector, node) buffer = node.source_range.source_buffer corrector.remove(range_with_surrounding_space(range: node.loc.begin, buffer: buffer, side: :right, whitespace: true)) corrector.remove(range_with_surrounding_space(range: node.loc.end, buffer: buffer, side: :left)) handle_orphaned_comma(corrector, node) return unless ternary_condition?(node) && next_char_is_question_mark?(node) corrector.insert_after(node.loc.end, ' ') end |