Using `detekt` + `ktlint` I'm used to using the An...
# detekt
c
Using
detekt
+
ktlint
I'm used to using the Android Studio shortcuts to format a file to fix basic issues. After attempting to upgrade to
1.10.0
this no longer seems to fix the new
Indentation
issue being reported. If a file format command doesn't fix that we can't reasonably upgrade our projects. Any ideas?
p
I have faced this problem too. I found some posts suggesting I should change my code style “continuation indent” to 4 (from the default 8 ) but this wasn’t enough for me… So I ended up with a couple of
// @formatter:off
tags 😓
b
This problem is related with
ktlint
instead of
detekt
. Anyway, if you want continuation indent of 4 you can use
.editorconfig
and set
continuation_indent_size = 4
In 1.10.0 we updated to the last version of ktlint that have a new indentation algorithm. You should probably need some configuration in your IDE or
ktlint
p
I just wanted the IDE and ktlint to agree on the code style 👼 I couldn’t make intellij format the same way that ktlint wants. (I haven’t seen anything saying the problem is caused by detekt)
c
Yeah, I knew it was ktlint causing it, and figured it was the continuation indent. I'll check that editor config
c
Adding an editor config file with that set, and/or turning off the rule per that link isn't helping
b
What’s the problem exactly?
c
That new Indentation rule is still showing up everywhere
b
That’s normal. If you don’t want that rule you should disable it from the detekt config (if you uses ktlint through detetk)
The new indentation in ktlint is much more aggresive
If you don’t like it you need to disable it.
And, if you want the old one, you need to use an old version of ktlint because they removed the old algorithm from it’s code base
c
I definitely want the rule. And I have the detekt config set up with the same indent/continuation sizes as before. But the report seems to indicate that those sizes aren't making it to ktlint
b
I recommend you to run detekt in format mode so it fixes all the problems. Then it should work.
110 Views