-
-
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 Cop to Enforce Alignment of Tokens on Consecutive Lines #2478
Comments
Do you want this specifically for aligning on This is not really aligning on "tokens", as |
@alexdowad I'm fairly sure that I haven't thought through all the use cases yet, so let's do whatever's easiest to align As a bonus, if it could do like the This is super minor, but I thought I would bring it up. 😄 |
I think for now, we should only look at aligning |
@alexdowad for a first pass I agree, although I don't think the indentation thing will be too hard. I'm down to pair on this as well as the bracket alignment with you if you want! :) |
@bbatsov What's up? Why'd this get closed? |
@jfelchner Have a look at the above commit. |
@alexdowad I'm on ioctocat and the commits don't get shown inline. :-/ Thank you so much! 😄 |
No problem -- please clone and try it out! (It is better if we can catch problems before the next gem release.) |
Now that
ExtraSpacing
has been updated (#2035) to work so well (thanks @bbatsov!), the last thing I'd love for rubocop to be able to handle is checking and autofixing alignment of tokens across consecutive lines.For example, if the cop is configured to align on
=
, then the following code would throw an error:And autocorrect would update this to:
Firstly, notice that the
whoomp
line doesn't get autocorrected because it's not on an adjacent line with the first two. Similar toExtraSpacing
, it might be nice to have an option to ignore blank lines when looking for adjacency.Secondly, it aligns on the token itself and not on the operator. In other words, it's the above and not:
The text was updated successfully, but these errors were encountered: