We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In a loop where I conditionally return a value or calling next, rubocop triggers the Lint/UnreachableLoop.
next
Here is an example :
%w[foo bar tao].each do |name| return User.find_by(first_name: name) || next end
If I have a user named tao but no user named foo or bar, this will run 3 times.
tao
foo
bar
Not raising a Lint/UnreachableLoop warning.
Lint/UnreachableLoop
W: Lint/UnreachableLoop: This loop will have at most one iteration. %w[foo bar tao].each do |name| ...
You can use the example above. You can even replace next by something like (puts 'next'; next) to see it iterate.
(puts 'next'; next)
1.13.0
Thanks a lot for your work, you rock! ❤️
The text was updated successfully, but these errors were encountered:
[Fix rubocop#9746] Fix a false positive for Lint/UnreachableLoop
0e1a312
Fixes rubocop#9746. This PR fixes a false positive for `Lint/UnreachableLoop` when using conditional `next` in a loop.
Merge pull request #9747 from koic/fix_false_positive_for_lint_unreac…
65cac52
…hable_loop [Fix #9746] Fix a false positive for `Lint/UnreachableLoop`
Successfully merging a pull request may close this issue.
In a loop where I conditionally return a value or calling
next
, rubocop triggers the Lint/UnreachableLoop.Here is an example :
If I have a user named
tao
but no user namedfoo
orbar
, this will run 3 times.Expected behavior
Not raising a
Lint/UnreachableLoop
warning.Actual behavior
Steps to reproduce the problem
You can use the example above. You can even replace
next
by something like(puts 'next'; next)
to see it iterate.RuboCop version
1.13.0
Thanks a lot for your work, you rock! ❤️
The text was updated successfully, but these errors were encountered: