From 61dd80258a505d05214ebe77998b2be3dc5b040a Mon Sep 17 00:00:00 2001 From: uzzu Date: Sun, 17 Dec 2023 21:42:51 +0900 Subject: [PATCH] fix detekt merged report name; Use sarif format --- .github/workflows/pull-request.yml | 2 +- build.gradle.kts | 24 ++++++++++++++---------- gradle/detekt.yml | 1 - 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c74a7c2..c5f2385 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,7 @@ jobs: - name: Run reviewdog if: always() run: | - find . -type f -name "ktlint*Check.xml" -exec sh -c "cat {} | reviewdog -f=checkstyle -name='ktlint' -reporter=github-pr-review" \; + cat build/reports/detekt/detekt-merged-report.sarif | reviewdog -f=sarif -name="detekt" -reporter="github-check" -level="error" -filter-mode="nofilter" -fail-on-error - name: Gradle publish to mavenLocal run: | ./gradlew publishToMavenLocal diff --git a/build.gradle.kts b/build.gradle.kts index e9d2f9b..3a7c8dd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,18 +14,25 @@ plugins { alias(libs.plugins.gradle.plugin.publish) apply false } -detektConfigurationRoot() +val reportMerge by tasks.registering(ReportMergeTask::class) { + output.set(rootProject.layout.buildDirectory.file("reports/detekt/detekt-merged-report.sarif")) +} + +detektConfigurationRoot(reportMerge) subprojects { apply(plugin = "io.gitlab.arturbosch.detekt") - detektConfigurationShared() + detektConfigurationShared(reportMergeTask = reportMerge) } // region detekt configuration -fun Project.detektConfigurationRoot() { +fun Project.detektConfigurationRoot( + reportMergeTask: TaskProvider, +) { val allKtsFiles = allKtsFiles() detektConfigurationShared( + reportMergeTask = reportMergeTask, source = allKtsFiles + allBuildSrcKtFiles() + files("src"), @@ -33,6 +40,7 @@ fun Project.detektConfigurationRoot() { } fun Project.detektConfigurationShared( + reportMergeTask: TaskProvider, source: List = listOf(files("src")), detektConfig: File = rootProject.file("./gradle/detekt.yml"), ) { @@ -45,17 +53,13 @@ fun Project.detektConfigurationShared( parallel = true } - val reportMerge by tasks.registering(ReportMergeTask::class) { - output.set(rootProject.layout.buildDirectory.file("reports/detekt/merge.xml")) - } - tasks.withType().configureEach { finalizedBy(reportMerge) - reports.xml.required = true + reports.sarif.required = true } - reportMerge { - input.from(tasks.withType().map { it.xmlReportFile }) + reportMergeTask { + input.from(tasks.withType().map { it.sarifReportFile }) } } diff --git a/gradle/detekt.yml b/gradle/detekt.yml index 09f6f02..c7362dd 100644 --- a/gradle/detekt.yml +++ b/gradle/detekt.yml @@ -47,7 +47,6 @@ output-reports: - 'TxtOutputReport' - 'HtmlOutputReport' - 'MdOutputReport' - - 'SarifOutputReport' comments: active: true