Is there a reason why I’m seeing the same violatio...
# detekt
k
Is there a reason why I’m seeing the same violation printout out twice in console?
Copy code
> Task ...ui:detektDebug FAILED
.../label/Label.kt:162:19: Top level constant names should match the pattern: [A-Z][_A-Z0-9]* [TopLevelPropertyNaming]

.../label/Label.kt - 5min debt
        TopLevelPropertyNaming - [Top level constant names should match the pattern: [A-Z][_A-Z0-9]*] at .../label/Label.kt:162:19

Overall debt: 5min

naming - 5min debt
        TopLevelPropertyNaming - [Top level constant names should match the pattern: [A-Z][_A-Z0-9]*] at .../label/Label.kt:162:19

Overall debt: 5min
g
mmmm that could be a bug in the rule 🤔
s
Would be good to have a reproducer. Do you see issues twice for other rules? Do you see issues also twice in other reports (e.g. HTML) than the console one?
k
I have all reporters disabled
I’m seeing this with all other rules, perhaps there’s something about how I’m configuring detekt
I’ve got a KMP multi module plugin where I apply detekt plugin in every module using custom build logic plugin
In my build logic plugin this is how I am configuring it, roughly:
Copy code
// Common plugin configuration
detekt {
  autoCorrect = false
  parallel = true
  config = files(rootProject.file("detekt/config.yml"))
  buildUponDefaultConfig = true
}
Copy code
// Configure Detekt Gradle task
tasks.withType<Detekt>().configureEach {
  // Configure sources
  setSource(detektSources)
  include(detektIncludes)
  exclude(detektExcludes)

  // TODO: generate serif report and add to GHA
  // Configure reports
  reports {
    html.required.set(false)
    sarif.required.set(false)
    xml.required.set(false)
    txt.required.set(false)
    md.required.set(false)
  }
detektSources
,
detektIncludes
,
detektExcludes
are just filters for directories and file types that I want detekt to run on
Copy code
// Sources to analyze
val detektSources = listOf(
  DEFAULT_SRC_DIR_JAVA,
  DEFAULT_SRC_DIR_KOTLIN,
  // Kotlin Multiplatform
  "src/commonMain/kotlin",
  "src/androidMain/kotlin",
  "src/iosMain/kotlin",
  "src/commonJvmMain/kotlin",
  "src/jvmMain/kotlin"
)
// Analyze Kotlin files only
val detektIncludes = listOf(
  "**/*.kt",
  "**/*.kts"
)

val detektExcludes = listOf(
  "**/resources/**",
  "**/generated/**",
  "**/_build/**"
oh an I’m applying the plugin as well at the top of the build logic plugin:
Copy code
pluginManager.apply<DetektPlugin>()
the base of my detekt config looks like this:
Copy code
config:
  validation: true
  checkExhaustiveness: true
  warningsAsErrors: true

build:
  maxIssues: 0
  excludeCorrectable: false

console-reports:
  active: true
  exclude:
    - 'ProjectStatisticsReport'
    - 'ComplexityReport'
    - 'NotificationReport'

processors:
  active: true
  exclude:
    - 'DetektProgressListener'
    - 'KtFileCountProcessor'
    - 'PackageCountProcessor'
    - 'ClassCountProcessor'
    - 'FunctionCountProcessor'
    - 'PropertyCountProcessor'
    - 'ProjectComplexityProcessor'
    - 'ProjectCognitiveComplexityProcessor'
    - 'ProjectLLOCProcessor'
    - 'ProjectCLOCProcessor'
    - 'ProjectLOCProcessor'
    - 'ProjectSLOCProcessor'
    - 'LicenseHeaderLoaderExtension'
And I’m running detekt tasks like this:
Copy code
gradle detekt detektDebug detektAndroidDebug --continue
Actually now that I’m looking at it, I don’t even know what
detekt
task is doing, it doesn’t seem to validate anything?
s
You seem to run detekt twice. That's why it (correctly) reports the issue twice.
The following page should guide in choosing the right detekt task to run. https://detekt.dev/docs/gettingstarted/gradle#available-plugin-tasks