Fix a false positive for Layout/EmptyLineAfterGuardClause#13455
Merged
koic merged 1 commit intorubocop:masterfrom Nov 14, 2024
Merged
Conversation
This PR fixes a false positive for `Layout/EmptyLineAfterGuardClause` when using a guard clause outside oneliner block. It avoids the following infinit loop error: ```console $ cat example.rb return if condition; foo do bar end $ bundle exec rubocop --only Layout/EmptyLineAfterGuardClause,Layout/EmptyLinesAroundBlockBody -a Inspecting 1 file C Offenses: example.rb:1:1: C: [Corrected] Layout/EmptyLineAfterGuardClause: Add empty line after guard clause. return if condition; foo do ^^^^^^^^^^^^^^^^^^^ example.rb:2:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning. 0 files inspected, 2 offenses detected, 2 offenses corrected Infinite loop detected in /Users/koic/src/github.com/koic/rubocop-issues/block/example.rb and caused by Layout/EmptyLineAfterGuardClause -> Layout/EmptyLinesAroundBlockBody Hint: Please update to the latest RuboCop version if not already in use, and report a bug if the issue still occurs on this version. Please check the latest version at https://rubygems.org/gems/rubocop. ```
6d6d29a to
4cfcb87
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a false positive for
Layout/EmptyLineAfterGuardClausewhen using a guard clause outside oneliner block.It avoids the following infinit loop error:
Before submitting the PR make sure the following are checked:
[Fix #issue-number](if the related issue exists).master(if not - rebase it).bundle exec rake default. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.mdif the new code introduces user-observable changes. See changelog entry format for details.