Skip to content

Commit 233ed6e

Browse files
authored
Remove duplicates in SARIF report (#474)
1 parent f47e064 commit 233ed6e

File tree

1 file changed

+9
-4
lines changed
  • utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator

1 file changed

+9
-4
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/TestGenerator.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,26 @@ object TestGenerator {
133133
}
134134
}
135135

136-
private fun mergeSarifReports(model: GenerateTestsModel, sarifReportsPath : Path) {
136+
private fun mergeSarifReports(model: GenerateTestsModel, sarifReportsPath: Path) {
137+
val mergedReportFile = sarifReportsPath
138+
.resolve("${model.project.name}Report.sarif")
139+
.toFile()
140+
// deleting the old report so that `sarifReports` does not contain it
141+
mergedReportFile.delete()
142+
137143
val sarifReports = sarifReportsPath.toFile()
138144
.walkTopDown()
139145
.filter { it.extension == "sarif" }
140146
.map { it.readText() }
141147
.toList()
142148

143149
val mergedReport = SarifReport.mergeReports(sarifReports)
144-
val mergedReportPath = sarifReportsPath.resolve("${model.project.name}Report.sarif")
145-
mergedReportPath.toFile().writeText(mergedReport)
150+
mergedReportFile.writeText(mergedReport)
146151

147152
// notifying the user
148153
SarifReportNotifier.notify(
149154
info = """
150-
SARIF report was saved to ${toHtmlLinkTag(mergedReportPath.toString())}$HTML_LINE_SEPARATOR
155+
SARIF report was saved to ${toHtmlLinkTag(mergedReportFile.path)}$HTML_LINE_SEPARATOR
151156
You can open it using the VS Code extension "Sarif Viewer"
152157
""".trimIndent()
153158
)

0 commit comments

Comments
 (0)