All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gitlab.arturbosch.detekt.report.SarifReportMerger.kt Maven / Gradle / Ivy

There is a newer version: 1.23.7
Show newest version
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