Hi! I'm setting up detekt in my project where I ne...
# detekt
d
Hi! I'm setting up detekt in my project where I need to include app flavors sources directories. All configurations I apply to detekt tasks, but I didn't find any way to configure sources via task. So I configure sources through the DetektExtension. Is this the correct approach? Does detekt correctly merge settings from tasks and extension?
Also can I just add android app sources to the detekt sources to analyse flavors code? Or do I need to explicitly call detekt<Variant> tasks?
b
It depends.
detekt
and
detektDebug
(for example) are different
detekt
doesn't only checks the files without resolving types. the other tasks
detekt
with "surname" revolves types so way more rules run.
So, in general I recommend to use
detektVariant
.
d
Ok, then a few more questions: 1. Do you have plans to add more friendly tasks to run detekt? Imo it would be great to have
detekt*WithTypes*
task that run detekt against all source sets with type checks. Then
detekt*WithoutTypes*
, and finally
detektAll
that run both tasks above? 2. My initial question: is it right approach to configure detekt with combination of task and DetektExtension? 3. For some reason I have an error running detekt for specific KMP module with compose. If I directly run
./gradlew :module:detekt
I face this problem, but if I run detekt for all modules (
./gradlew detekt
) there is no such problem. What I’m doing wrong?
Copy code
An exception occurred applying plugin request [id: 'com.android.library', version: '8.0.2']
> Failed to apply plugin 'com.android.internal.library'.
   > Accessing GradleBuildProject.Builder through AnalyticsConfiguratorService is not allowed after AnalyticsService is created.
And do the running all
detekt*Variant*
tasks for application module equals to running
detekt
with extra running type checking rules? Or do I need to run both?
After reading a lot of articles, documentation and plans concluded that currently I can use just
detekt
task, and after releasing detekt 2.0 with compiler plugin a lot of problems from message above would be resolved.
@Brais Gabin sorry, but still getting
AnalyticsConfiguratorService
error for modules with kotlin multiplatofrm. Though can’t generate baseline for this modules. Do you have any idea how to fix this?
b
No idea to be honest, maybe you can open a conversation in the detekt repo and see if you can get more help there.
About the plans. Yes, we want to improve our support to KMP. We welcome any contribution in that regard. It's ok to configure detekt with a mix, yes. The detektExtension will be use as default value on the tasks so you can override them
👍 1
d
Ok. Is there a sample project with a detekt and KMP? Or maybe I need to configure something differently for KMP?
b
I know that there are people out there with detekt configured on KMP projects so I would bet that some of them are open source
I would add that question outside this thread. Just ask for KMP projects using detekt. I assume that you will get some links
👌 1
d
Solved this problem. First problem was kotlin 1.9.10 and second — detekt should be applied after configuring kotlin plugin