-
-
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
Auto-correction of argument indentation bug #448
Comments
Here's how I've been thinking about this problem. The key-value pairs that get misaligned are not individual parameters, so they really deserve a cop of their own that checks key alignment in multi-line hash literals. But they were aligned from the start, and the Any opinions? |
I think we should have a separate cop about the alignment of literals like |
I will start by adding cops for literal alignment. I will come back to the question of how to solve the problem of one autocorrection changing things so another correction is required. It looks very tricky. But first I want to ask about code that we currently have in RuboCop, e.g. @output_hash = {
metadata: metadata_hash,
files: [],
summary: { offence_count: 0 }
} This uses a symmetrical alignment around the colon. My question is, should we allow this? @yujinakayama @bbatsov ? |
I wrote it. :) @output_hash = {
metadata: metadata_hash,
files: [],
summary: { offence_count: 0 }
}
@output_hash = {
metadata: metadata_hash,
files: [],
summary: { offence_count: 0 }
}
@output_hash = {
metadata: metadata_hash,
files: [],
summary: { offence_count: 0 }
} I feel the first style is most readable and beautiful. In my opinion, it would be a bit inconvenient if we don't allow the style. |
I agree that the first style is very readable, but I don't think it's very common in the ruby world, so it can't be our only enforced style. Since this cop will support auto-correction I think we have three choices:
|
👍 for option 3. I think that the 3rd style should be the default one, since it's the most common. Our checks should obviously work for |
My plan was to not really distinguish between 2nd and 3rd style, just leaving it as it is. Do you want auto-correction to change 2nd style into 3rd, @bbatsov? And do you want the configuration option to allow a choice between all three styles? |
It'd be better if both styles are treated separated, so we could have proper auto-corrections for them. I'd suggest having a config option with 3 different values - the names of the 3 styles. |
Good point. I'll do it like that. |
👍 for option 3 too. |
Part of a solution for rubocop#448.
[Fix #448] Auto-correct multi-line parameters in AlignParameters.
Code like this:
If auto-corrected to:
The second line's indentation is corrected, but others remain with an incorrect indentation.
The text was updated successfully, but these errors were encountered: