Class: RuboCop::Cop::ParenthesesCorrector

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/correctors/parentheses_corrector.rb

Overview

This auto-corrects parentheses

Class Method Summary collapse

Class Method Details

.correct(node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/rubocop/cop/correctors/parentheses_corrector.rb', line 8

def correct(node)
  lambda do |corrector|
    corrector.remove(node.loc.begin)
    corrector.remove(node.loc.end)

    if ternary_condition?(node) && next_char_is_question_mark?(node)
      corrector.insert_after(node.loc.end, ' ')
    end
  end
end