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 detected with trailing private keyword in controller #6566
Labels
Comments
8 tasks
Thanks for the feedback. I opened a PR #6576. |
koic
added a commit
to koic/rubocop
that referenced
this issue
Dec 14, 2018
…ccessModifier` Fixes rubocop#6566. This PR fixes a false positive for `Layout/EmptyLinesAroundAccessModifier` when at the end of specifying a superclass is missing blank line. The following is originally no offense code. (It is probably a regression by rubocop#6307) ```console % cat example.rb class SomeController < SomeOtherController def index; end private end % rubocop example.rb --only Layout/EmptyLinesAroundAccessModifier -a Inspecting 1 file C Offenses: example.rb:4:3: C: [Corrected] Layout/EmptyLinesAroundAccessModifier: Keep a blank line before and after private. private ^^^^^^^ 1 file inspected, 1 offense detected, 1 offense corrected ``` Auto-correct adds a blank line after `private`. This is due to false positives. ```diff % cat example.rb class SomeController < SomeOtherController def index; end private + end ``` This caused the infinite loop in `Layout/EmptyLinesAroundAccessModifier` and `Layout/EmptyLinesAroundClassBody`. ```console % rubocop example.rb --only Layout/EmptyLinesAroundClassBody -a Inspecting 1 file C Offenses: example.rb:5:1: C: [Corrected] Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body end. 1 file inspected, 1 offense detected, 1 offense corrected ``` Auto-correct removes the blank line from after of `private`. ```diff % cat example.rb class SomeController < SomeOtherController def index; end private - end ``` It loops to the first code. This PR fixes the infinite loop.
bbatsov
pushed a commit
that referenced
this issue
Dec 14, 2018
…difier` Fixes #6566. This PR fixes a false positive for `Layout/EmptyLinesAroundAccessModifier` when at the end of specifying a superclass is missing blank line. The following is originally no offense code. (It is probably a regression by #6307) ```console % cat example.rb class SomeController < SomeOtherController def index; end private end % rubocop example.rb --only Layout/EmptyLinesAroundAccessModifier -a Inspecting 1 file C Offenses: example.rb:4:3: C: [Corrected] Layout/EmptyLinesAroundAccessModifier: Keep a blank line before and after private. private ^^^^^^^ 1 file inspected, 1 offense detected, 1 offense corrected ``` Auto-correct adds a blank line after `private`. This is due to false positives. ```diff % cat example.rb class SomeController < SomeOtherController def index; end private + end ``` This caused the infinite loop in `Layout/EmptyLinesAroundAccessModifier` and `Layout/EmptyLinesAroundClassBody`. ```console % rubocop example.rb --only Layout/EmptyLinesAroundClassBody -a Inspecting 1 file C Offenses: example.rb:5:1: C: [Corrected] Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body end. 1 file inspected, 1 offense detected, 1 offense corrected ``` Auto-correct removes the blank line from after of `private`. ```diff % cat example.rb class SomeController < SomeOtherController def index; end private - end ``` It loops to the first code. This PR fixes the infinite loop.
Nyangawa
pushed a commit
to Nyangawa/rubocop
that referenced
this issue
Jan 24, 2019
…ccessModifier` Fixes rubocop#6566. This PR fixes a false positive for `Layout/EmptyLinesAroundAccessModifier` when at the end of specifying a superclass is missing blank line. The following is originally no offense code. (It is probably a regression by rubocop#6307) ```console % cat example.rb class SomeController < SomeOtherController def index; end private end % rubocop example.rb --only Layout/EmptyLinesAroundAccessModifier -a Inspecting 1 file C Offenses: example.rb:4:3: C: [Corrected] Layout/EmptyLinesAroundAccessModifier: Keep a blank line before and after private. private ^^^^^^^ 1 file inspected, 1 offense detected, 1 offense corrected ``` Auto-correct adds a blank line after `private`. This is due to false positives. ```diff % cat example.rb class SomeController < SomeOtherController def index; end private + end ``` This caused the infinite loop in `Layout/EmptyLinesAroundAccessModifier` and `Layout/EmptyLinesAroundClassBody`. ```console % rubocop example.rb --only Layout/EmptyLinesAroundClassBody -a Inspecting 1 file C Offenses: example.rb:5:1: C: [Corrected] Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body end. 1 file inspected, 1 offense detected, 1 offense corrected ``` Auto-correct removes the blank line from after of `private`. ```diff % cat example.rb class SomeController < SomeOtherController def index; end private - end ``` It loops to the first code. This PR fixes the infinite loop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
No Infinite loop detected error as the controller otherwise works fine.
This was produced by a mistake as you can probably tell by the example below, I don't know if there's a cop already warning about trailing private keywords, maybe the expected behavior is to get an error there.
Actual behavior
Infinite loop detected error when my controller has a trailing private keyword.
Steps to reproduce the problem
My controller looks like this:
RuboCop version
0.60.0 (using Parser 2.5.3.0, running on ruby 2.5.1 x86_64-linux)
The text was updated successfully, but these errors were encountered: