Class: RuboCop::Cop::Style::IfCorrector
- Inherits:
-
Object
- Object
- RuboCop::Cop::Style::IfCorrector
- Extended by:
- ConditionalAssignmentHelper, ConditionalCorrectorHelper
- Defined in:
- lib/rubocop/cop/style/conditional_assignment.rb
Overview
Corrector to correct conditional assignment in ‘if` statements.
Constant Summary
Constants included from ConditionalAssignmentHelper
ConditionalAssignmentHelper::ALIGN_WITH, ConditionalAssignmentHelper::END_ALIGNMENT, ConditionalAssignmentHelper::EQUAL, ConditionalAssignmentHelper::KEYWORD
Class Method Summary collapse
Methods included from ConditionalCorrectorHelper
assignment, correct_branches, correct_if_branches, remove_whitespace_in_branches, replace_branch_assignment, white_space_range
Methods included from ConditionalAssignmentHelper
end_with_eq?, expand_elses, expand_when_branches, indent, lhs, tail
Class Method Details
.correct(corrector, cop, node) ⇒ Object
562 563 564 |
# File 'lib/rubocop/cop/style/conditional_assignment.rb', line 562 def correct(corrector, cop, node) correct_if_branches(corrector, cop, node) end |
.move_assignment_inside_condition(corrector, node) ⇒ Object
566 567 568 569 570 571 572 573 574 575 576 |
# File 'lib/rubocop/cop/style/conditional_assignment.rb', line 566 def move_assignment_inside_condition(corrector, node) column = node.source_range.column condition = node.send_type? ? node.last_argument : node.expression assignment = assignment(node) corrector.remove(assignment) condition.branches.flatten.each do |branch| move_branch_inside_condition(corrector, branch, condition, assignment, column) end end |