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

Big Chungus

11/19/2021, 12:18 PM
I see from the docs that detekt can validate formatting via ktlint, but can it also format files with it?
g

gammax

11/19/2021, 12:28 PM
Yes we do have the autoCorrect flag exactly for that
b

Big Chungus

11/19/2021, 12:35 PM
What would gradle cmdline look like for this?
j

Javier

11/19/2021, 12:38 PM
when I was using detekt with the autoformatting, I think just running detekt was autoformatting everything, but not sure, that was long time ago
hope ktfmt being integrated into detekt tho 🙂
b

Big Chungus

11/19/2021, 12:38 PM
Oh? Is there a way to separate out formatting and checking?
j

Javier

11/19/2021, 12:39 PM
not sure tbh, that was long time ago
g

gammax

11/19/2021, 1:47 PM
The gradle cmq line for autocorrect will be
--auto-correct
but will be available in Detekt 1.19.0 (the next release).
K 1
b

Big Chungus

11/19/2021, 1:54 PM
Btw, I've always been curious how custon cli args are implemented in gradle. Could you point me to some code?
g

gammax

11/19/2021, 1:56 PM
b

Big Chungus

11/19/2021, 2:00 PM
Wow, can't believe how simple this is
😃 1
j

Javier

11/19/2021, 2:06 PM
--auto-correct
works so because it is a boolean, if it was an string, I think it was
--some-task-prop=someString
That was the reason I moved the kamp implementation to Gradle tasks hahah, it was easier to use
b

Big Chungus

11/19/2021, 2:07 PM
Ah, just read in gradle docs today that
=
is recommended, but optional
j

Javier

11/19/2021, 2:07 PM
--auto-correct if the variable is a boolean set it as true
but if the variable is a string you need to indicate the value, so you need the equals I think
or you mean you can add an space?
Copy code
--some-task-prop someString // this?
I havent tried it tbh
b

Big Chungus

11/19/2021, 2:08 PM
I meant
--my-option="value"
is understood as identical to
--my-option "value"
by gradle
j

Javier

11/19/2021, 2:08 PM
interesting, TIL
b

Big Chungus

11/19/2021, 2:09 PM
But gradle recommends using
=
. Maybe they have plans to make it mandatory in the future 🤷
6 Views