-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Abort when auto-correct causes an infinite loop. #1492
Conversation
e877e6a
to
99a023f
Compare
You might add a few comments here and there, as casual readers might not realise what this code's for. |
👍 Nicely done! But keep the line length down. |
0dcaef5
to
2ac3063
Compare
This is good to merge. I've also added Another change is to make |
@dblock I mostly agree. The first commit is all good. We've seen this problem a number of times, so a solution is most welcome. The problem solved by the second commit is more rare, I think, but I seem to recall that it has happened before that corrections just add more and more space, for example, without end. But I really wish we could find a solution where we don't add another command line option. It seems an excessive measure for a rare problem. If we base the max loop count on the initial number of correctable offenses, wouldn't it be possible to choose a number that will not need customization? |
I am totally open for suggestions, but I don't think there's any way to derive a number of max loops. You're looking at a misbehaving cop that keeps making a correction, no in a loop, but in the "adding a space each time" way. My spec does just that, it changes a class name to something random, so it will loop forever. So what's the maximum number there? We could just hard-code the number at something high, like 128, just cause it's a power of 2, that would be just fine. In the usual case you don't have this problem anyway, so this is just a precaution. Let me know what you want to do to move this PR forward (including ripping that part out). |
c21599f
to
e309731
Compare
I removed the questionable part about the second commit, so this is now only detecting infinite loops where the cop autocorrects something and then comes back to the original source. I will PR that later separately and we can discuss it there. |
🍏 |
no_color: 'Disable color output.', | ||
version: 'Display version.', | ||
verbose_version: 'Display verbose version.' | ||
only: 'Run only the given cop(s).', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change whitespace only now? Seems unnecessary then.
@dblock Good idea! The changes look good to me, apart from some added spaces. |
`-V/--verbose-version` | Displays the current version plus the version of Parser and Ruby | ||
`-F/--fail-fast` | Inspects in modification time order and stops after first file with offenses | ||
`-d/--debug` | Displays some extra debug output | ||
`-v/--version` | Displays the current version and exits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The readme changes seem totally unrelated to me.
0dfcf88
to
8d8a129
Compare
8d8a129
to
90bbb07
Compare
Ok, cleaned this up, removed unrelated things (will make separate PRs), fixed the rest of the comments. |
Abort when auto-correct causes an infinite loop.
This avoids future situations such as the one described in #1484. At the very least when you run into an infinite loop RuboCop won't hang and tell you where the loop occurs so you can go correct it, exclude a cop or report it as a bug.
Also maybe we should call
InfiniteCorrectionLoop
something else, likeLifetimeSentenceLoop
;)