is no longer experimental and runs always in code style
ktlint-official
.
j
Johan
01/27/2025, 1:41 PM
Old message here Paul, wouldn't it be nice with a new line between class row definition and next line?
Copy code
class FooBar {
val foo2 = "foo2"
To
Copy code
class FooBar {
val foo2 = "foo2"
Disabling this rule would allow
Copy code
val foo3 = "foo3"
fun bar1() {
And that I do want to prevent
p
Paul Dingemans
02/15/2025, 1:45 PM
HI Johan, I forgot to respond on this. It is an explicit choice to disallow the blank line before the first declaration in a class. In some cases it would help readability, in other case it would not help, or lead to inconsistencies. For example, why would a blank line before the declaration of
foo2
make sense, while no blank line is allowed before the closing brace of the class.
Thanks for following up!
I would say the ending line just has a closing brace, which does not include any other characters. And the indent is at another level which makes a lot of difference. The goal is to prevent characters/text not being "directly connected" to each other to have space.
At the same time one could argue that there should be an empty line before the closing brace.
p
Paul Dingemans
02/15/2025, 7:29 PM
I understand your arguments. It is impossible to let ktlint produce every format that any developer wants, and keeping it maintainable at the same time. I don't think this is important enough to add a new option, let alone to change the default behavior.
j
Johan
02/15/2025, 8:01 PM
Should be default, no opt in 😉
At the same time I would argue that there shouldn't be a new line after function declaration which is almost the same thing but still not 😆