-
-
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
Add auto-correction to RedundantBegin cop #964
Conversation
👍 for having auto-correct in this cop. Not sure about the implementation, though. Ideally the auto-correct should leave the code in a clean state, as people might not be using whitespace-related cops. @jonas054 Thoughts? |
Yes. Much better if indentation is in a good state after the change. @tamird So please make the example code in the spec a little longer (and do the necessary adjustments in |
@jonas054 is there an existing facility with this kind of block unwrapping? |
one question: how can you know what the correct indentation here will be? presumably you guys wanted me to assume that the user has indented inside the begin bit, but we really don't know that. I think this cop should probably not correct the whitespace at all, and leave that to another cop (which doesn't exist at the moment, i believe). WDYT? |
Doesn't really matter how the |
Alright, this code is much uglier now, but it does the whitespace stuff. PTAL |
The code looks good to me, but I also see two unrelated commits in the PR. |
They both fix the same issue, just two different cops. Would you like this split into two PRs? |
oh, sorry, mistook this for the other PR. i'll leave those changes up to you to do elsewhere |
I think you're looking at the wrong PR. :-) |
Fixed! |
Btw, something did came to mind. You might add an example showing what will happen to a single-line
|
yeah, this code doesn't fix that case very well at all. I'll add a test case to the cop as well and take another stab |
@bbatsov added |
the code actually handles it fine, it just takes some special syntax to get the same AST |
Add auto-correction to RedundantBegin cop
👍 Looks good! Keeps those improvements coming! :-) |
This correction leaves some whitespace around, but other cops should handle that, right?