https://kotlinlang.org logo
#detekt
Title
# detekt
c

Charles

07/29/2020, 2:28 PM
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

pedro

07/29/2020, 2:43 PM
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

Brais Gabin

07/29/2020, 2:51 PM
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

pedro

07/29/2020, 2:54 PM
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

Charles

07/29/2020, 3:25 PM
Yeah, I knew it was ktlint causing it, and figured it was the continuation indent. I'll check that editor config
c

Charles

07/29/2020, 3:40 PM
Adding an editor config file with that set, and/or turning off the rule per that link isn't helping
b

Brais Gabin

07/29/2020, 3:42 PM
What’s the problem exactly?
c

Charles

07/29/2020, 3:42 PM
That new Indentation rule is still showing up everywhere
b

Brais Gabin

07/29/2020, 3:43 PM
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

Charles

07/29/2020, 3:47 PM
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

Brais Gabin

07/29/2020, 4:08 PM
I recommend you to run detekt in format mode so it fixes all the problems. Then it should work.
30 Views