Replies: 1 comment
-
Ktlint indeed does not comply with Kotlin Coding Conventions in this regard. Allowing the first line in a class to be blank is not consistent with disallowing the first line in a function to be blank. Also, it would be inconsistent to allow a blank line as first line in the class, but disallowing a blank line as last line in the class. Wrapping the opening brace to a separate line is not consistent with the way braces are used in all other block like situations. Let's move this issue to the discussion section about ktlint configurability. Maybe the rule
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Expected Behavior
Class header & body are separated after a long class header. Compliant examples from Kotlin coding conventions:
In the above example, there is a blank line between the opening brace and the class body.
In the above example, there is no blank line between the opening brace and the class body, but the opening brace is on its own line.
ktlint should enforce this rule.
Observed Behavior
As far as I can tell, ktlint does not support this. Some non-compliant examples from the docs (dev-snapshot) follow.
Class signature
In this example, the
// body
sits against the header. There are other examples in class signature code samples.No blank lines in list
In this example, body sits against the class header. I would call this a "long" class header as it's multi-line.
I note that this proposal conflicts with "No empty first line at start in class body" so would have to be disabled or enabled only in part when ktlint_official rule style is used.
Steps to Reproduce
Your Environment
.editorconfig
settingsBeta Was this translation helpful? Give feedback.
All reactions