how are you using Detekt on multiplatform projects...
# detekt
f
how are you using Detekt on multiplatform projects these days? I was hoping to find a single task that would sweep my entire project but from what I see this doesn’t exist and is being tracked here, so the options I see are: • create this task myself (any directions on how I could do that?) • do something like this, it seems to work great (basically setting the module root to be the source so all source sets are considered) • run multiple tasks: ◦
detektMain
to sweep non-multiplatform stuff with type resolution ◦
detektMetadataMain
to sweep
commonMain
on all modules (found this one here) ◦
detektAndroidDebug
and
detektAndroidRelease
to sweep Android code in multiplatform modules ◦ …and how do I sweep iOS code in multiplatform modules? I’ve tried
detektMetadataIosMain
,
detektIosX64Main
,
detektIosArm64Main
and
detektIosSimulatorArm64Main
but they all seem to fail to find issues on code inside
iosMain
— should I file an issue or am I missing something? I have a minimum reproducible example here: https://github.com/tfcporciuncula/detekt-kmm-issue (this commit summarizes everything) • any other option?
👀 2
m
Really eager to hear about this, and maybe we should add some valid info into somewhere in documentation
g
• run multiple tasks:
That’s the current status. We generate tasks for each module and for each Multiplatform sourceset.
should I file an issue or am I missing something?
Potentially yes + a reproducer would be gold. We added KMP support ~1/2 years ago and never received any feedback if it actually worked or was valuable for users, so happy to iterate on it.
m
was valuable for users
Definitely is, I think the reason of lacking feedback due to not having successful KMP adaptation by developers Maybe we should create a new single task that depend on the relevant tasks in activated platforms ? I can file an issue for that.
f
just filed an issue about not being able to detect issues on `iosMain`: https://github.com/detekt/detekt/issues/5609 is there any disadvantage of following the strategy of adding the module root as the Detekt source? I’m moving forward with it for now as it seems to work pretty well:
Copy code
tasks.withType<io.gitlab.arturbosch.detekt.Detekt> detekt@{
  setSource(files(project.projectDir))
  exclude("**/*.kts")
  exclude("**/build/**")
}
with this I can just run
detekt
and make sure it covers the entire project (with no type resolution)
e
I've been using detekt with multiplatform since it was supported. Other than not having a task that runs all detekt tasks I'm very happy with it
I did have to write something to create detekt tasks for intermediate source sets, but that's been running well too
997 Views