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 #8621] Helpful Infinite Loop message #8701

Merged
merged 1 commit into from Sep 14, 2020
Merged

Conversation

iSarCasm
Copy link
Contributor

@iSarCasm iSarCasm commented Sep 11, 2020

Closes #8621

Adds the information about which Cops exactly caused an infinite loop

Tracks the corrected offenses on each iteration.

In the case of exceeding MAX_ITERATIONS, it just returns cop names from the latest iteration.
In the case of duplicated sources, it returns a list of iterations (with cop names) starting from the first time this exact source has already been generated. In most cases, I imagine there would only be 2 or 3 iterations between looped states but it should handle all cases.

Examples:

  • Test/ClassMustBeAModuleCop -> Test/ModuleMustBeAClassCop
  • Test/ClassMustBeAModuleCop, Test/AtoB -> Test/ModuleMustBeAClassCop, Test/BtoA
  • Test/AtoB -> Test/BtoC -> Test/CtoA

Before submitting the PR make sure the following are checked:

  • 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.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 13, 2020

The proposed changes look good to me overall. Let's also hear what @marcandre and @koic think about them, though.

lib/rubocop/runner.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@marcandre marcandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabulous! ♥️

Only nitpick is that I would convert an array to string with .join(', ') instead of .to_s. In the typical cases, Some/Cop -> Some/OtherCop is nicer than [Some/Cop] -> [Some/OtherCop].

@iSarCasm
Copy link
Contributor Author

iSarCasm commented Sep 13, 2020

Fabulous! ♥️

Only nitpick is that I would convert an array to string with .join(', ') instead of .to_s. In the typical cases, Some/Cop -> Some/OtherCop is nicer than [Some/Cop] -> [Some/OtherCop].

@marcandre So in case of more than 1 conflicting cop it should be Test/ClassMustBeAModuleCop, Test/AtoB ->Test/ModuleMustBeAClassCop, Test/AtoB instead of ["Test/ClassMustBeAModuleCop", "Test/AtoB"] -> ["Test/ModuleMustBeAClassCop", "Test/BtoA"], right?

P.S: Updated it already

Closes rubocop#8621

Adds the information about which Cops exactly caused an infinite loop
@marcandre
Copy link
Contributor

P.S: Updated it already

Cool, LGTM 👍

Copy link
Member

@koic koic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I think this information can be a good hint to solve the infinite loop error 👍

@bbatsov bbatsov merged commit d9e04a7 into rubocop:master Sep 14, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 14, 2020

Thanks!

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.

Infinite Loop message is not helpful
4 participants