Skip to content
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

Fix an infinite loop for Style/MultilineMethodSignature when line break after def #12763

Conversation

Earlopain
Copy link
Contributor

This undoes a part of #8090, specifically at 448eb96. There don't seem to be any consequences of doing so except for uncovering this bug.

A test case for this issue has already been added in #11768 but after the result has been reached there are still correctors that result in an infinite loop. In practice some other cop comes in first and makes this situation unlikely to actually encounter, unless it is disabled of course.

While I was working on #12753 I got into a similar situation, where my assertions where passing but actually running it on the codebase resulted in an infinite loop.

This PR fixes the ininite loop and makes these situations impossible by only considering a correction done if there are no correctors left.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

…reak after def

This commit removes this exit condition from `expect_correction`. It is now only considered done when there are no correctors anymore.
This has hidden the infinite loop this commit fixes.
@bbatsov bbatsov merged commit 55cbc7f into rubocop:master Mar 10, 2024
33 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 10, 2024

Looks good to me. Thanks!

@Earlopain Earlopain deleted the fix-infitite-loop-for-style-multiline-method-signature branch March 10, 2024 10:07
Earlopain added a commit to Earlopain/rubocop that referenced this pull request Mar 11, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this pull request Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants