I'm very confused about the indentation rules rela...
# ktlint
k
I'm very confused about the indentation rules related to the superclass constructor call in subclass definitions. It seems that the indentation superclass constructor parameters depends on whether the subclass has any parameters. See code in thread.
The following code shows indentation the way ktlint likes it:
Copy code
open class Base(a: Int)

class Derived1 : Base(
    123, // This level of indentation looks reasonable
)

class Derived2 :
    Base(
        123, // Ok, Base is at 4, so parameter indented at 8
    )    

class Derived3(
    a: Int,
) : Base(
        123, // Now why should this be at 8?
    ) // And why should this be at 4?

class Derived4(
    a: Int,
) :
    Base( // Indented at 4 on new line just to show example
            123, // Why is this indented at 12? Shouldn't it be 8?
        ) // Shouldn't this be at same level as "Base" (i.e. 4)?
Can you explain what the exact rules are?
p
The exact rules are very hard to describe in words. Please consult the code and/or unit tests of the rule. Also, there were some heated debates about this on the issue tracker/discussions. See https://github.com/pinterest/ktlint/discussions.
thank you color 1