Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ data class Sarif(
.writerWithDefaultPrettyPrinter()
.writeValueAsString(this)

operator fun plus(other: Sarif): Sarif =
this.copy(runs = this.runs + other.runs)

@JsonIgnore
fun getAllResults(): List<SarifResult> =
runs.flatMap { it.results }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SarifReport(
*/
fun mergeReports(reports: List<String>): String =
reports.fold(Sarif.empty()) { sarif: Sarif, report: String ->
sarif.copy(runs = sarif.runs + Sarif.fromJson(report).runs)
sarif + Sarif.fromJson(report)
}.toJson()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ object SarifReportIdea {
IntelliJApiHelper.run(IntelliJApiHelper.Target.THREAD_POOL, indicator, "Save SARIF report for ${classId.name}") {
try {
val sarifReportAsJson = proc.writeSarif(reportFilePath, testSetsId, generatedTestsCode, sourceFinding)
val sarifReport = Sarif.fromJson(sarifReportAsJson)
srcClassPathToSarifReport[srcClassPath] = sarifReport
val newSarifReport = Sarif.fromJson(sarifReportAsJson)
val oldSarifReport = srcClassPathToSarifReport[srcClassPath] ?: Sarif.empty()
srcClassPathToSarifReport[srcClassPath] = oldSarifReport + newSarifReport
} catch (e: Exception) {
logger.error { e }
} finally {
Expand Down