Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix #6566] Fix a false positive for `Layout/EmptyLinesAroundAccessMo…
…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.
- Loading branch information