Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix #9731] Fix two autocorrection issues for `Style/NegatedIfElseCon…
…dition`. Previously, when swapping the `if` and `else` branches, if one of the branches only had a single statement, the branch would end up not being spaced out properly. Additionally, when there is a node with a comment inside the `if` that has an identical node with a comment *before* the `if` statement, `CommentsHelp.begin_pos_with_comment` returns an incorrect range, which was causing a clobbering error. I fixed this by creating ranges of the entire body of the if and else branches, so that they can just be swapped without relying on `ProcessedSource#ast_with_comments`.
- Loading branch information
1 parent
93a325f
commit 3ce630f
Showing
3 changed files
with
142 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#9731](https://github.com/rubocop/rubocop/issues/9731): Fix two autocorrection issues for `Style/NegatedIfElseCondition`. ([@dvandersluis][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters