Does it make sense to have a rule that can enforce to put(or not put) a new line between the class body and the first member declaration? I raised a similar issue in Detekt and it seems that such a rule must be a part of ktlint.
Example if the rule is set up to enforces no newline then:
class A {
private val i = 0
}
class A {
private val i = 0
}
A newline is extremely helpful when the class (or method) signature is extremely complex and wraps to multiple lines.
Also the Android Kotlin style guide explicitly allows a single newline here: https://android.github.io/kotlin-guides/style.html#vertical (number 3)
For big classes and nested classes the extra blank line can be helpful. We have a single blank line before the first member and after the last member of the class body. Had to create a custom rule in ktlint for that... would be super helpful to have this as a configurable setting.
Does it need to be configurable? 0 or 1 lines should be allowed and never normalized for class members at the top and bottom. 0 or 1 lines should be allowed and never normalozed for function bodies at the top.
For formatting any amount of lines greater than 1 should become 1
From my perspective, it doesn't need to be configurable, but if you want to enforce a certain style then it's a good option to have.
I would like it to be configurable as I prefer the "non-compliant" case.
I'm also more a fan of the noncompliant version here. This should be configurable in my opinion.
Having a config option seems like a good idea. I'd almost always prefer the Compliant code.
Both are compliant and subjective based on the complexity of the class
declaration header. Forcing one is wrong. Disallowing either is wrong.
On Sun, Apr 22, 2018, 3:47 PM Niklas Baudy notifications@github.com wrote:
Having a config option seems like a good idea. I'd almost always prefer
the Compliant code.—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/shyiko/ktlint/issues/191#issuecomment-383407326, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEEZ5nX4woVJPyVFRsEVB29fq63mp0ks5trN48gaJpZM4Tcbqo
.
Most helpful comment
Both are compliant and subjective based on the complexity of the class
declaration header. Forcing one is wrong. Disallowing either is wrong.
On Sun, Apr 22, 2018, 3:47 PM Niklas Baudy notifications@github.com wrote: