https://kotlinlang.org logo
Title
k

Kevin

02/15/2023, 1:11 PM
Hi all, I have a question: I'm running the detekt gradle plugin (version 1.22.0) and the
detekt
task is using different rules than
detektMain
. It's not skipping over any files, but it is applying different rules in the same file. My detekt config in gradle looks like this:
detekt {
    config = files("../detekt.yml")
    buildUponDefaultConfig = true
    source = files("src")
}
And detekt.yml looks like this:
complexity:
  active: true
  CognitiveComplexMethod:
    active: true
    threshold: 5

naming:
  InvalidPackageDeclaration:
    active: false
I'm using gradle 7.5.1 and targeting jdk 11. Namely,
detektMain
includes
UnnecessaryFilter
and
VarCouldBeVal
while
detekt
does not. Is this expected? I didn't find anything on google or in the github issues.
s

Sam

02/15/2023, 1:13 PM
See https://detekt.dev/docs/gettingstarted/type-resolution/, specifically this part:
detekt
- Runs detekt WITHOUT type resolution
detektMain
- Runs detekt with type resolution on the
main
source set
Some rules only work when type resolution is enabled.
k

Kevin

02/15/2023, 1:14 PM
Ah okay, thank you!