Emanuel Moecklin
02/20/2024, 2:00 AMpaid
) I need to run two different Detekt tasks to get full coverage:
1. ./gradlew detektPaidDebug
only finds defects in the app module but not in library modules
2. ./gradlew detektDebug
only finds defects in library modules but not in the app module
When I run ./gradlew detekt
it finds defects in all modules. However we want to run with type resolution. Is this a known issue or am I doing something wrong?
As a reference, the configuration
subprojects {
apply plugin: "io.gitlab.arturbosch.detekt"
// includes the custom rules module
dependencies {
detektPlugins(project(":lib-code-quality"))
}
def baseDir = rootProject.projectDir
def baseLineFile = file("$baseDir/config/detekt/${project.name}/detekt-baseline.xml")
def reportPath = "$baseDir/build/reports/detekt/${project.name}"
detekt {
debug = false
parallel = true
config.setFrom(file("$baseDir/config/detekt/detekt-config.yml"))
baseline = baseLineFile
buildUponDefaultConfig = true
allRules = true
}
tasks.withType(Detekt).configureEach {
reports {
html.required.set(true)
html.outputLocation.set(file("$reportPath/detekt.html"))
txt.required.set(true)
txt.outputLocation.set(file("$reportPath/detekt.txt"))
xml.required.set(false)
md.required.set(false)
sarif.required.set(false)
}
}
tasks.withType(DetektCreateBaselineTask).configureEach {
baseline.set(baseLineFile)
}
}
Brais Gabin
02/20/2024, 10:26 AM./gradlew detektMain detektTest
Emanuel Moecklin
02/20/2024, 4:07 PMdetektMain
runs all combinations (~15) of build types and flavors we have, I don't want to run it on most of themBrais Gabin
02/20/2024, 4:24 PMdetektAll
.
fun Project.setupDetekt(vararg buildVariants: String) {
val detektAll = tasks.register("detektAll") {
group = "verification"
description = "Run detekt analysis in all the modules."
dependsOn(
if (buildVariants.isEmpty()) {
listOf(
project.tasks.named("detektMain"),
project.tasks.named("detektTest"),
)
} else {
buildVariants.flatMap { variant ->
listOf(
project.tasks.named("detekt$variant"),
project.tasks.named("detekt${variant}UnitTest"),
)
}
},
)
}
Brais Gabin
02/20/2024, 4:26 PMapp
I call setupDetekt
. With the variant that I want and in the others I just use the detektMain
(all my modules have debug
build variant disable by default to avoid that repetition, not only with detekt but also with test
and others).