Autocorrect nested UnlessElse causing "Parser::Source::TreeRewriter detected clobbering" #10375
Juniors can be so creative in how poor they can write code
Running this snippet:
causes this message:
adding -d to obtain a backtrace:
Happens with -a and -A. Seems related to having nested uses of the cop.
1.25.0 (using Parser 18.104.22.168, rubocop-ast 1.15.1, running on ruby 2.6.3 x86_64-linux)
rubocop -d --config path_to_my_conf -a path_to_snippet.rb
The text was updated successfully, but these errors were encountered:
An unless/else nested inside another unless/else would cause rewrite clobbering when auto-correcting both offenses. By ignoring the node after correcting it and skipping auto-correction for inner nodes with the same offense, we avoid this problem. The auto-correct loop will pick up the remaining offense and fix it. No test case is added for this particular aspect, but it's standard RuboCop behavior.