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
When autocorrecting a Style/Next offense with nested conditionals, it results in invalid code. It seems like the inner conditional is erroneously targeted for the correction. See example below.
Expected behavior
RuboCop autocorrects to:
foos.each do |foo|
next if foo[:bar]
if baz
do_something
else
do_something_else
end
end
Actual behavior
RuboCop autcorrects to:
foos.each do |foo|
unless foo[:bar]
next unless baz
do_something
else
do_something_else
end
end
(Note the missing end.)
Steps to reproduce the problem
Run bundle exec rubocop -a on:
foos.each do |foo|
unless foo[:bar]
if baz
do_something
else
do_something_else
end
end
end
…d conditionals
When inspecting and auto-correcting code with nested conditionals where
the inner conditional has an `else` statement, but the outer conditional
does not, the auto-correct messes up:
```
foos.each do |foo|
unless foo[:bar]
if baz
do_something
else
do_something_else
end
end
end
```
was corrected to:
```
foos.each do |foo|
unless foo[bar]
next unless baz
do_something
else
do_something_else
end
end
```
This change fixes that.
When autocorrecting a
Style/Next
offense with nested conditionals, it results in invalid code. It seems like the inner conditional is erroneously targeted for the correction. See example below.Expected behavior
RuboCop autocorrects to:
Actual behavior
RuboCop autcorrects to:
(Note the missing
end
.)Steps to reproduce the problem
Run
bundle exec rubocop -a
on:RuboCop version
The text was updated successfully, but these errors were encountered: