New issue
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
Infinite loop in --fix #289
Labels
rubocop bug 🚨
An apparent bug in RuboCop
Comments
That's a real weird I think any infinite loop condition should be filed against since we're only configuring built-in rules. Is that true, @koic? https://github.com/rubocop/rubocop |
@searls This issue has been reproduced as a bug in RuboCop. I will take it. Thank you for your mention! |
8 tasks
I opened rubocop/rubocop#9777 to solve this issue. |
Thanks @koic! |
You are welcome @jmkoni! |
koic
added a commit
to koic/rubocop
that referenced
this issue
May 7, 2021
This PR fixes an incorrect auto-correct for `Style/RedundantBegin` when using multi-line `if` in `begin` block. And fixes standardrb/standard#289 that is causing the following infinite loop error due to `Style/RedundantBegin` with `Style/MultilineMemoization`. ```ruby % cat example.rb @memo ||= begin if condition do_something end end % bundle exec rubocop -a --only Style/RedundantBegin,Style/MultilineMemoization (snip) Inspecting 1 file C Offenses: example.rb:1:1: C: [Corrected] Style/MultilineMemoization: Wrap multiline memoization blocks in begin and end. @memo ||= (if condition ... ^^^^^^^^^^^^^^^^^^^^^^^ example.rb:1:11: C: [Corrected] Style/RedundantBegin: Redundant begin block detected. @memo ||= begin ^^^^^ 0 files inspected, 2 offenses detected, 2 offenses corrected Infinite loop detected in /Users/koic/src/github.com/koic/rubocop-issues/289/example.rb and caused by Style/MultilineMemoization /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/runner.rb:285:in `block in iterate_until_no_changes' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/runner.rb:281:in `loop' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/runner.rb:281:in `iterate_until_no_changes' ```
bbatsov
pushed a commit
to rubocop/rubocop
that referenced
this issue
May 7, 2021
This PR fixes an incorrect auto-correct for `Style/RedundantBegin` when using multi-line `if` in `begin` block. And fixes standardrb/standard#289 that is causing the following infinite loop error due to `Style/RedundantBegin` with `Style/MultilineMemoization`. ```ruby % cat example.rb @memo ||= begin if condition do_something end end % bundle exec rubocop -a --only Style/RedundantBegin,Style/MultilineMemoization (snip) Inspecting 1 file C Offenses: example.rb:1:1: C: [Corrected] Style/MultilineMemoization: Wrap multiline memoization blocks in begin and end. @memo ||= (if condition ... ^^^^^^^^^^^^^^^^^^^^^^^ example.rb:1:11: C: [Corrected] Style/RedundantBegin: Redundant begin block detected. @memo ||= begin ^^^^^ 0 files inspected, 2 offenses detected, 2 offenses corrected Infinite loop detected in /Users/koic/src/github.com/koic/rubocop-issues/289/example.rb and caused by Style/MultilineMemoization /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/runner.rb:285:in `block in iterate_until_no_changes' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/runner.rb:281:in `loop' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/runner.rb:281:in `iterate_until_no_changes' ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Only crashes with --fix.
The text was updated successfully, but these errors were encountered: