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.
Juniors can be so creative in how poor they can write code😆
Running this snippet:
causes this message:
An error occurred while Style/UnlessElse cop was inspecting the_snippet.rb
adding -d to obtain a backtrace:
Notes
Happens with -a and -A. Seems related to having nested uses of the cop.
RuboCop version
1.25.0 (using Parser 3.1.0.0, rubocop-ast 1.15.1, running on ruby 2.6.3 x86_64-linux)
RuboCop config
Command line
rubocop -d --config path_to_my_conf -a path_to_snippet.rb
The text was updated successfully, but these errors were encountered: