io.gitlab.arturbosch.detekt.report.SarifReportMerger.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of detekt-gradle-plugin Show documentation
Show all versions of detekt-gradle-plugin Show documentation
Static code analysis for Kotlin
package io.gitlab.arturbosch.detekt.report
import io.github.detekt.sarif4k.SarifSerializer
import java.io.File
/**
* A naive implementation to merge SARIF assuming all inputs are written by detekt.
*/
object SarifReportMerger {
fun merge(inputs: Collection, output: File) {
val sarifs = inputs.filter { it.exists() }.map {
SarifSerializer.fromJson(it.readText())
}
val mergedResults = sarifs.flatMap { it.runs.single().results.orEmpty() }
val mergedSarif = sarifs[0].copy(runs = listOf(sarifs[0].runs.single().copy(results = mergedResults)))
output.writeText(SarifSerializer.toJson(mergedSarif))
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy