-
-
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
Infinite loop when running with the --auto-correct and --stdin options #2502
Comments
Please post the code which you are running RC on, or at least a small excerpt which can be used to reproduce the problem. |
@alexdowad I ran the command given: echo 'p $/' | rubocop --auto-correct --only="Style/SpecialGlobalVars" --format=simple --stdin - and got the same error. |
OK. The problem here is that "autocorrecting" code from stdin is a nonsensical thing to do. After each round of autocorrections, RC writes the corrected code to the original source. So you know what it does in this case? ...It writes it out to a file called RC should probably refuse to "autocorrect" code which comes from stdin. Other contributors, what do you think? |
That sounds like a good idea to me. It might be a cool to have RC be able to correct code coming from |
The trouble is that stdout is normally used for the diagnostic output. Or is it written to stderr? I'm not sure. |
I miss understood the initial issue. When I run
The output is:
I thought the issue was that RuboCop was running forever. In actuality, RuboCop is detecting that what it is doing will produce an infinite loop and aborting. I wonder how difficult it would be to isolate this situation from other infinite loops (not sure what causes other infinite loops), and finish running successfully instead of blowing up. |
The reason why it detects an "infinite loop" is because after it autocorrects the source and writes it to a file called |
We should exit with an error message if both |
I'm doing the latter right now. |
(And it's not really hard, by the way. You'll see the PR in 15 minutes or so.) |
OK, just pushed a fix here. What do you think of |
Perfect, thank you for the quick fix ! :) |
@alexdowad the For now this seems the best workaround |
Rubocop detects an infinite loop when running the
Style/SpecialGlobalVars
code with the--auto-correct
and--stdin
option (rubocop version:0.35.1
).To reproduce:
The backtrace:
The text was updated successfully, but these errors were encountered: