Closed bethcutler closed 5 years ago
Slightly wrong in my previous comment, there is no error on line 6 (the "BLUE" entry). If formatted like this, there are no errors:
enum class Color(val displayName: String, val value: Int) {
RED(
displayName = "Red",
value = 1
),
BLUE(
displayName = "Blue",
value = 2
);
}
Has this been released yet? I updated to "0.34.2" but I'm still seeing KtLint format everything back one indentation: https://gist.github.com/AdamMc331/8c6a9ea40ba36803aef3993acfb1e7ce
@AdamMc331 according to changelog it was released: https://github.com/pinterest/ktlint/blob/master/CHANGELOG.md#0342---2019-07-22
You need to enable experimental rules.
I have experimental rules on. I tried changing the KtLint verison number in the gradle plugin, but I wonder if I made a mistake there. I will double check, but I can also just upgrade to the fancy new 9.0.0 which targets the latest KtLint and maybe that will resolve my issue. :D
You can check used ktlint version by running:
$ ./gradlew dependencies --configuration ktlint
Can confirm this was user error, I made a mistake in my gradle file. So sorry! Thanks for checking in though.
Example code, formatted as we would like it to be:
In this case, we get "Unexpected indentation" errors on every line from 3 to 9 (expecting 2 less indentation). We are using 2-space indentation here.
If formatted instead so that the initializer arguments are on one line there are no errors: