From 8dbb01fcbc2bca40fbf3ebd741f1127cef9215c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivo=20=C5=A0m=C3=ADd?= Date: Mon, 22 Mar 2021 18:52:08 +0100 Subject: [PATCH] SarifOutputReportSpec: Correctly detect Windows root directory on local development machine (#3584) * SarifOutputReportSpec: Correctly detect Windows root directory on local development machine * Update detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt Co-authored-by: Chao Zhang --- README.md | 1 + .../io/github/detekt/report/sarif/SarifOutputReportSpec.kt | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f6342507..a103c5c9c 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ If you contributed to detekt but your name is not in the list, please feel free - [Severn Everett](https://github.com/severn-everett) - New rule: SleepInsteadOfDelay - [Adam Kobor](https://github.com/adamkobor) - New rule: MultilineLambdaItParameter - [Slawomir Czerwinski](https://github.com/sczerwinski) - Rule improvement: FunctionOnlyReturningConstant +- [Ivo Smid](https://github.com/bedla) - Fix Local development on Windows ### Mentions diff --git a/detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt b/detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt index dd2a04519..6d2322fc5 100644 --- a/detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt +++ b/detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt @@ -56,9 +56,10 @@ class SarifOutputReportSpec : Spek({ val expectedReport = readResourceContent("relative_path.sarif.json") .stripWhitespace() - // Note: On Github CI, windows file URI is on D: drive + // Note: Github CI uses D: drive, but it could be any drive for local development val systemAwareExpectedReport = if (whichOS().startsWith("windows", ignoreCase = true)) { - expectedReport.replace("file:///", "file://D:/") + val winRoot = Paths.get("/").toAbsolutePath().toString().replace("\\", "/") + expectedReport.replace("file:///", "file://$winRoot") } else { expectedReport }