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

rocketraman

12/20/2021, 8:31 PM
Re. multiplatform support I see from the previous message support is in beta -- anyone have any specific examples? • I'm looking to enable detekt across all source sets in a kvision style project: frontendMain, commonMain, backendMain • I'd like to enable the formatter/ktlint plugin for all source sets • I'd like to customize detekt ideally once for all source sets in the entire project • Detekt should run with type support
👀 1
g

gammax

12/20/2021, 11:04 PM
I don’t have a concrete example to link, but if your project is OSS, it could be the best candidate to become a reference for the Detekt + KMP ecosystem
• I’m looking to enable detekt across all source sets in a kvision style project: frontendMain, commonMain, backendMain
You should have all the Detekt tasks already created for you
• I’d like to enable the formatter/ktlint plugin for all source sets
This is supported and “should work” out of the box
• I’d like to customize detekt ideally once for all source sets in the entire project
Same as above, you should be able to specify the
detekt{}
configuration at the same level where you apply the
kotlin("multiplatform")
Gradle plugin
• Detekt should run with type support
That’s the tricky point. TR works so far onyl with Android & JVM targets only
r

rocketraman

12/20/2021, 11:24 PM
You should have all the Detekt tasks already created for you
I am missing the
detektCommonMain
task. I do have
detektMetadataCommonMain
. I do also have the expected
detektBackendMain
and
detektFrontendMain
tasks.
> I’d like to enable the formatter/ktlint plugin for all source sets
This is supported and “should work” out of the box
I had to explicitly specify
source
i.e.:
Copy code
source = files("src/backendMain/kotlin", "src/backendTest/kotlin", "src/commonMain/kotlin", "src/frontendMain/kotlin")
Is that to be expected or am I doing something wrong? I was also unable to add the formatter plugin -- trying to add
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0"
at the
all
in the multiplatform dependencies declaration did not work. I didn't try to add it to each source set independently -- not sure if that would work.
g

gammax

12/20/2021, 11:32 PM
What do you mean with "did not work"? You got an error message?
Also is your project open source?
r

rocketraman

12/21/2021, 2:23 AM
Copy code
Line 65:         detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0")
                   ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
Not open source, sorry
Looks like it works if declared in a top-level
dependencies
block, not inside the
sourceSets
.
Still missing detektCommonMain for some reason though
Though it is "detecting" issues in commonMain nonetheless
9 Views