detekt / detekt

Static code analysis for Kotlin
https://detekt.dev
Apache License 2.0
6.21k stars 767 forks source link

Unable to configure default #7559

Open realdadfish opened 3 weeks ago

realdadfish commented 3 weeks ago

This is my detekt build convention:

plugins {
    id("io.gitlab.arturbosch.detekt")
}

detekt {
    // Bump this to receive new / adapted rules
    toolVersion = "1.23.6"
    val componentFile = rootProject.file("detekt.yml")
    val globalFile = File(getGitRoot(), "detekt.yml")
    require(componentFile.exists() || globalFile.exists()) { "No detekt.yml found" }
    val configFile = if (componentFile.exists()) componentFile else globalFile
    config.setFrom(configFile)
    buildUponDefaultConfig = true
}

tasks.withType<Detekt>().configureEach {
    // do not run detekt on generated files
    exclude { spec ->
        spec.file.absolutePath.contains("/build/")
    }
    reports {
        // html and xml are by default on, we don't need txt
        txt.required.set(false)
    }
}

and this my detekt.yml which contains this configuration:

naming:
  MatchingDeclarationName:
    active: true
    mustBeFirst: true
    multiplatformTargets:
      - 'android'
      - 'desktop'

I have files underneath desktopMain and androidMain named PlatformUITest.desktop.kt and PlatformUITest.android.kt respectively. Still, Detekt does not acknowledge the configuration above nor does it work with the default set of multiplatformTargets out of the box:

> Task :app:detektMetadataCommonMain FAILED
Property 'naming>MatchingDeclarationName>multiplatformTargets' is misspelled or does not exist.
3flex commented 3 weeks ago

Which version of the plugin are you using?

realdadfish commented 3 weeks ago

1.23.6 as well: io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6