-
-
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
Problem with autocorrect Style/Tab and Style/IndentationConsistency #1928
Comments
…nd_tabs [Fix #1928] Auto-correct one offense at a time if there are tabs
Hi If I copy the input code from above and paste into a new file, `be rubocop --auto-correct spec/temp_spec.rb`` |
@obromios I get the same result. Sorry about that. I didn't check that my fix resolves the original problem. I'll take another look. |
That's alright, I am sorry I have such messy code. On Friday, June 12, 2015, Jonas Arvidsson notifications@github.com wrote:
|
I stumbled upon a similar issue with def method
a = 1
if something
if a
b
if test.nil?
end
end
end
end |
Yes, the problem is not directly related to tab characters. Rather it's the fact that cops that deal with alignment typically change more than one offending line in |
[Fix #1928] Avoid two changes overwriting in AutocorrectAlignment
The latest patch has improved things, but I regret I am still having trouble. Here is an example of what is going wrong:
is ending up as
and
is ending up as
|
@obromios Are you sure? I get exactly the results you describe when I run on |
I will give that a go. Chris On Tue, Jul 28, 2015 at 5:59 PM, Jonas Arvidsson notifications@github.com
|
... and it worked. It is strange though, I had checked rubygems and it showed 0.32.1 as being released. Anyway, my code now looks beautiful and the test for that particular file all passed. I will now try rubocop --autocorrect on the whole app and get back to you if there is a problem. Thank you. |
In e0fce7e, jonas054 adjusted autocorrection to only correct a single offense at a time (rather than all offenses for a single cop) if the source file contains tabs. The comments indicate that autocorrecting files which contains tabs may be problematic somehow, but it's hard to see how that is the case. All specs, including the specs which were added in e0fce7e, still pass when the added code is removed. What prompted the addition of that code in the first place? It was made in response to GH issue rubocop#1928. BUt all the "problem" code which was posted in that thread is still autocorrected without problems, even when this "fix" is removed. Why is removing this code desirable? Because, simply put, it flushes autocorrection performance right down the toilet, and straight into the sewer. It's hard to overstate how bad it is for perf. It takes what was just mildly terrible and makes it appallingly, disastrously horrendous. And when I say "horrendous", what I mean is "hideously atrocious". If we still have trouble with tabs, it would be better to do a pass which replaces tabs first, before any other cops get a crack at autocorrection. But it remains to be seen whether that is actually necessary.
When I run rubocop --autocorrect on my project with Style/Tab and Style/IndentationConsistency enabled I get many errors, due to rubocop splitting up words. A boiled down example file is:
The output is as follows:
Note the split
do
after thebefore(:each)
. It not only splits up keywords, but symbols, literals, i.e. it seems to do it pretty much everywhere.The text was updated successfully, but these errors were encountered: