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

Lilly

08/25/2021, 1:09 PM
Hi did someone work with spotless. I'm not sure if I should go with spotless or detekt (both have ktlint integrated, while spotless has also ktfmt and diktat on board). Can someone give me an advice?
b

Big Chungus

08/25/2021, 1:13 PM
I tried using spotless with ktlint, but it never formatted my files...
j

Javier

08/25/2021, 3:54 PM
I am using detekt for code analysis, spotless with ktfmt for code formatting. There is a dedicated gradle plugin for ktfmt too https://github.com/cortinico/ktfmt-gradle.
❤️ 1
if you plan to use ktlint for formatting, I would go with detekt only
g

gammax

08/25/2021, 4:52 PM
Spotless is useful if you happen to have other languages to format also
2
l

Lilly

08/26/2021, 10:01 AM
I'm not sure if I set it up correctly but I don't like the reporter of spotless. Sometimes it's not clear why it's complaining, for example it has complained about every line in one file. It might be better to use each of the integrated tools separately (ktfmt, diktat + ktlint)
@gammax I currently noticed you are the maintainer of ktfmt gradle plugin. Could you please bump the version of kmt to 0.28. That would be pleasant. There is also an issue about that.
j

Javier

08/26/2021, 10:04 AM
Not sure what you mean, spotlessApply should fix all problems excepts bugs, so if your CI run spotlessCheck and it fails, you only have to update your PR running spotlessApply
last ktfmt version is 0.28, I thought indeed that should be great to have a nightly checker which update the ktfmt dependency
something like dependabot
l

Lilly

08/26/2021, 10:19 AM
I'm just playing around with the stuff. I mean the task
spotlessCheck
. I tend to have a look what problems it catches before I run the formatter and the output was confusing. So for now I will test the specific tools in isolation without spotless and check what I get there
I have edited my answer. It's now 0.28. 0.25 seems to be the first version that supports Gradle 7.2
g

gammax

08/26/2021, 11:07 AM
Please keep the discussion related to ktfmt inside #ktfmt. As a side note: 0.28 was released 2 days ago. Feel free to send a PR and if everything is green, I can definitely merge it 👍
j

Javier

08/26/2021, 11:10 AM
PR created, can you enable GitHub Actions for me in your repo?
g

gammax

08/26/2021, 11:18 AM
Done, but it’s red. Is not as easy as just bumping the version sadly
j

Javier

08/26/2021, 11:21 AM
Ah, I will take a look this afternoon then, I created it via GitHub web
Locally
preMerge
task is passing
CI error:
Copy code
* What went wrong:
'java.lang.String org.jetbrains.kotlin.cli.common.PropertiesKt.getKOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY()'
Classical it works on my machine XD
l

Lilly

08/26/2021, 11:31 AM
@gammax As an advice for improvement: please ditch
buildSrc
for gradle version catalog.
buildSrc
ist just a pain in the ass + redundant work
j

Javier

08/26/2021, 11:36 AM
he is using buildSrc for more things, not only deps
Ah, I thought there were multiple ore compiled plugins for publishing and so on
l

Lilly

08/26/2021, 11:41 AM
I guess
buildSrc
is fine for the rest. I'm not so deep into gradle stuff
g

gammax

08/26/2021, 12:16 PM
Thanks for your suggestion, I’ll stick with buildSrc for now 👍
j

Javier

08/26/2021, 12:32 PM
@gammax can be a problem related to JDK? All issues I see in Google are mentioning changing the jdk should fix the problem
g

gammax

08/30/2021, 5:07 PM
FYI
201 Views