Hey guys, I have a very very specific issue with D...
# detekt
m
Hey guys, I have a very very specific issue with Detekt currently and I'm wondering if any eagle-eyed amongst you would be able to help me identify the source of the problem and hopefully a possible fix ^^ I'm currently working on a KMP project and this project uses Compose Multiplatform (CMP). I have also set up convention plugins to help centralise the behaviour of each module. Here is a global overview of the project structure omitting anything that doesn't help understand the issue.
Copy code
my-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:
Copy code
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.
This is going to sound peculiar but it started working out of nowhere 😂 Guess I just needed to spam Sync and run detekt again and again