Maxime Michel
07/09/2025, 11:46 AMmy-project:
-> android
|-> androidApp (Android application module)
|-> other android specific modules
-> build-logic
|-> convention
|-> Detekt.kt (Detekt specific configurations are contained here)
|-> MultiplatformLibraryConventionPlugin.kt
-> ios (iOS application)
-> kmp
|-> data
|-> domain
|-> presentation
-> testing
|-> detekt
|-> konsist
This is a somewhat generic KMP project structure I think (but this works without issues so I'm not planning on changing this structure).
The contents of the :testing:detekt
module is attached as an image.
I followed the documentation and updated my Detekt.kt
file to apply (or so I thought) the new rule I created:
internal fun Project.configureDetekt() {
configure<DetektExtension> {
source.from(files("$projectDir/src"))
config.from(files(
"$rootDir/config/quality/detekt/detekt-config.yml",
"$rootDir/testing/detekt/src/main/resources/config/config.yml",
))
baseline = file("$rootDir/config/quality/detekt/baseline.xml")
autoCorrect = true
}
tasks.withType<Detekt> {
exclude("**/test/")
exclude(".*/tmp/.*")
dependsOn(":testing:detekt:assemble")
}
dependencies {
CONFIGURATION_DETEKT_PLUGINS(libs.findLibrary("detekt.cli").get())
CONFIGURATION_DETEKT_PLUGINS(libs.findLibrary("detekt.formatting").get())
CONFIGURATION_DETEKT_PLUGINS(libs.findLibrary("detekt.libraries").get())
CONFIGURATION_DETEKT_PLUGINS(project(":testing:detekt"))
}
}
In my custom rule, I added an override for the visitKtFile
function that simply prints the file name but this does nothing and I see no logs when running the detekt task.Maxime Michel
07/09/2025, 1:47 PM