-
Notifications
You must be signed in to change notification settings - Fork 512
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
Indention Rule: Parameters should be aligned vertically #118
Indention Rule: Parameters should be aligned vertically #118
Conversation
Enforce that parameters should be aligned. This is how default IntelliJ formatter works. This approach is listed on: https://ktlint.github.io/#rule-indentation https://kotlinlang.org/docs/reference/coding-conventions.html#class-header-formatting https://android.github.io/kotlin-guides/style.html#functions
Because rule is more strict now
Unless I'm reading it wrong, class ClassA(paramA: String, paramB: String,
paramC: String)
class ClassB(paramA: String, paramB: String, paramC: String) should be formatted as class ClassA(
paramA: String,
paramB: String,
paramC: String
)
class ClassB(paramA: String, paramB: String, paramC: String) (per "Classes with longer headers should be formatted so that each primary constructor argument is in a separate line with indentation" and "When a function signature does not fit on a single line, break each parameter declaration onto its own line"). Would you be willing to update PR to reflect this? (having this + #126 would be awesome) |
# Conflicts: # ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt
Parameters should be placed either on one line, either each parameter on new line Extracted indention size definition in separate class. This allows to avoid duplication between rules
Should this really be applied for methods too? Seems like it's a bit of overkill. |
@shyiko it's even more strict than what I wanted to do. But I'm fine with that :) I'd like to completely clarify what is done. There are two rules.
|
@vanniktech good question. @shyiko what do you think? |
This becomes really verbose really quickly especially when you have a large function call. I'd like to have a flag for this so that you can either enable or disable this for parameters. |
Sorry, for my previous "too quick" response. Actually, this is aligned with
|
I like the way it'll be done in kotlinpoet - square/kotlinpoet#281 |
@vanniktech I'm not sure what you mean exactly. Decide wrap or not according to line length? If yes, we should definitely do that. But I would prefer to do it in separate PR. Just to keep current one smaller and merge it earlier. @shyiko I'm looking forward for your feedback :) |
Then let's do it in a different PR. |
@shyiko 👍 |
# Conflicts: # ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/IndentationRule.kt
These changes are included into #137 |
Enforce that parameters should be aligned. This is how default IntelliJ
formatter works. This approach is listed on:
https://ktlint.github.io/#rule-indentation
https://kotlinlang.org/docs/reference/coding-conventions.html#class-header-formatting
https://android.github.io/kotlin-guides/style.html#functions
This allows to prevent stuff like that
@shyiko Sorry, initially I was fully confident that "align parameters" is how rule is designed (https://ktlint.github.io/#rule-indentation). But just before creating PR, I've noticed that error message actually allow not aligned parameters.
Feel free to close this PR, if you actually want to preserve that option.