-
Notifications
You must be signed in to change notification settings - Fork 501
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
Indentation of inheritance with parameters #2661
Comments
Code style
The super class With the other code styles, the old way of formatting is still available:
Code style |
Considering that function calls look like this: foos.map {
it + 1
}.bar()
.baz() or foo(
bar = "bar",
).bar()
.baz() I would say that the inheritance example is not fully consistent. It becomes even weirder. This is the formatted behavior when breaking the first inheritance: class Foo(
foo1: Int,
foo2: Int,
) :
Foobar1(
a = 1,
b = 2,
),
Foobar2,
Foobar3 {
fun foo() = "foo"
} Otherwise is it possible to use |
I think we have had discussions like this before. You have to disclose your With
No that is not supported, and will not be supported. |
@paul-dingemans I have mostly worked with the unit test provided above. I experimented a bit locally and it seems that a missing experimental rule is the reason the join to the previous line is not enforced. I still believe that the indentation rule by itself (deactivated This config for 1.2.1:
|
Ah good remark. Indeed the
The
Your second example is:
I have no idea how this should be written more nicely, given that the arguments of For shorter chains, the following is accepted by ktlint and might be a workaround:
Another, but worse workaround, is to write it like:
For now this example can not be marked as a 'bug', until a solution can be defined what formatting would work. Your last example is caused by missing the
You're right that the behavior of the |
I think the last comment was in the wrong ticket or rather a mix between tickets. In general I reckon we can close these tickets for now. Sidenote and personal opinion: val foos =
foos
.foo()
.bar()
.baz()
.qux() seems a lot less readable than val foos = foos.foo()
.bar()
.baz()
.qux() |
With short identifiers it seems indeed a waste of space. In real life, identifiers can also become (very) long. val foos =
foosfoosfoosfoosfoosfoosfoosfoosfoosfoosfoosfoos
.foofoofoo()
.bar()
.baz()
.qux() which makes val foos = foosfoosfoosfoosfoosfoosfoosfoosfoosfoosfoosfoos.foofoofoo()
.bar()
.baz()
.qux() As with a lot of decisions regarding formatting it is subjective what reads better. I always try to look at extreme examples when to decide what format to use. |
Indentation for inheritance implementation does not look correct.
For example
Expected Behavior
Current Behavior
Additional information
The text was updated successfully, but these errors were encountered: