You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an interesting bug indeed. I found an actual issue in Style/NegatedIfElseCondition that I have a fix for, where branches aren't being swapped properly when they are only a single statement.
However, there's also a second issue with how the AST is associated with comments that is being tripped for this specific example because there are two identical nodes (the flag = false lines) that each have an attached comment. The code to swap the if-else branches gets a range for each branch that includes comments, but because of rubocop/rubocop-ast#179, in your specific example it considers this entire part of the code to be the "if branch":
The Style/NegatedIfElseCondition cop bugs with very specific conditions with error
Parser::Source::TreeRewriter detected clobbering
.Steps to reproduce the problem
Create a file with the code below and run rubocop on it:
This seems very specific since it works if you remove the else block, if you remove the comments...
RuboCop version
The text was updated successfully, but these errors were encountered: