Skip to content

Commit 4c9f14e

Browse files
committed
Refactor static code analysis gradle task.
1 parent 0d29bc3 commit 4c9f14e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

buildSrc/src/main/kotlin/scripts/quality.gradle.kts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tasks.register("jacocoReport", JacocoReport::class) {
2727
dependsOn("test${Default.BUILD_VARIANT}UnitTest")
2828

2929
val buildVariantClassPath = "${Default.BUILD_FLAVOR}${Default.BUILD_TYPE.capitalize()}"
30-
val outputDir = "${project.buildDir}/testCoverage/html"
30+
val outputDir = "${project.buildDir}/testCoverage"
3131

3232
reports {
3333
xml.isEnabled = true
@@ -77,24 +77,31 @@ tasks.register("runTestCoverage") {
7777

7878
val detektAll by tasks.registering(Detekt::class) {
7979
group = "Quality"
80-
description = "Runs a detekt code analysis ruleset on the Android codebase."
80+
description = "Runs a detekt code analysis on the Android codebase."
8181
parallel = true
8282
buildUponDefaultConfig = true
8383

84+
val outputFile = "${project.buildDir}/staticAnalysis/index.html"
85+
8486
setSource(files(rootProject.projectDir))
85-
config.setFrom(project.rootDir.resolve("config/detekt/detekt.yml"))
87+
config.setFrom("${project.rootDir}/config/detekt/detekt.yml")
8688

8789
include("**/*.kt")
8890
exclude("**/*.kts", "*/build/*", "/buildSrc")
8991

9092
reports {
91-
xml.enabled = true
9293
html.enabled = true
94+
html.destination = file(outputFile)
95+
xml.enabled = false
9396
txt.enabled = false
9497
}
98+
99+
doLast {
100+
println("Static Analysis Report: $outputFile")
101+
}
95102
}
96103

97-
tasks.register("runStaticCodeAnalysis") {
104+
tasks.register("runStaticAnalysis") {
98105
description = "Run static analysis on the Android codebase."
99106
dependsOn(detektAll)
100107
}

0 commit comments

Comments
 (0)