Had to setup detekt on a new project again and the...
# detekt
c
Had to setup detekt on a new project again and the docs (again) leave me confused with where to actually set it up. I'm using https://detekt.dev/docs/gettingstarted/gradle#configuration and even under the android section its confusing too. This snippet looks like I should add the plugin in my root build.gradle file
But then the very next section talks about the desl for detekt. but if you do that, then you error because you dont have the plugin setup in the app module itself.
So I guess my question is. Do we need detekt in the main app module at all? Seems like no
e
detekt type resolution only works when applied to each module
I tend to still have single detekt task at the top-level configured to check all the
*.gradle.kts
scripts, since those won't get picked up otherwise, but that's a lot less important than on the main code
c
Understood. so if i just wanted it on the app module, i can omit the plugin in the root build file?
e
yes
c
interesting. ok. so I did try that, and I got a
Plugin [id: 'io.gitlab.arturbosch.detekt'] was not found in any of the following sources
oh interesting. if I just add a version to it then it's found. I guess I was just omitting the version because plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' } dont have versions.
e
you need to specify the versions somewhere, either in settings or the buildscript classpath (which is inherited from parent projects) or in the plugin declaration
(or version catalog, which I've been using for most plugins)
c
gotcha. so i guess for com.android.app and kotlin.android plugins... the versions are already found so thats why i dont declare them
TIL!
b
Any PR to improve the documentation is more than welcome. Write documentation is hard because, usually, it is wrote by someone that knows the topic. That's good but somwone like that usually omit things because "that's obvious". So any PR from someone that just read the documenttnion and make it work is great.
f
you are right, "the obvious for me is not the obvious for you"