-
-
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
ExtraSpacing Double Checks #2109
Comments
@jfelchner Thanks for the detailed description. The infinite correction loop is of course a bug. Your suggested correction for the other false positive problems sounds reasonable. I'll try it out. The false negative is less of a problem, I agree. |
@jonas054 would you like me to make a separate issue for the bug? |
@jfelchner Yes, that would be good. Please include an example of a hash literal that triggers the bug. |
[Fix #2109] Consider indentation in ExtraSpacing
Deleted my wall of text - I'm an idiot. |
@jonas054 I wanted to throw out a few
ExtraSpacing
offenses and possible false negatives and make sure the cop is working as intended.Before I get started, I just wanted to say that this cop is 10,000 times better now and caught a bunch of errors. As it stands, in our project, we still can't currently enable it by default, but we can run it selectively to catch the correct misspacings.
Alignment with Previous Line
In the majority of cases, the current behavior is what I would want. So that if you had:
it would consider those to not have any extra spacing.
However, it causes a wrinkle with something like:
In this example, the extra spacing before the
on
in the:update
line is caught, but the space before theon
on the:create
line is not because (I'm assuming) it's looking at howname
is aligned above it.Alignment with Method Calls on the Previous Line
In this case I want to keep all the method calls lined up but
ExtraSpacing
wants to collapse the first lines.Multiline Alignment
A lot of the alignment I do is that which spans multiple lines. It makes the code much easier to scan.
Currently when
ExtraSpacing
sees the following code:it wants to turn it into this:
Alignment of Hash Values
Currently it appears that
ExtraSpacing
conflicts (possibly?) with theAlignHash
cop's autocorrection. It seems as thoughExtraSpacing
is trying to correct spacing on hash values which I believe it should be prohibited from doing since that's the job of theAlignHash
cop.When I attempt to run it, I get:
Proposed Solution
So even though it looks like a lot, I think that the solution is actually pretty simple. I think that, when
ExtraSpacing
is trying to determine whether alignment is being attempted, rather than looking on the previous line, it needs to look at the previous line with the same indentation as the current line.If it does that, I think it will solve all of my issues (with the exception of the first one which is not that big of a deal IMO, but I wanted to make you aware).
Thank You
Thanks for making this cop so awesome @jonas054. It caught a ton of errors in our code. 😀
The text was updated successfully, but these errors were encountered: