Skip to content

Commit 012f099

Browse files
committed
chore(CycloneDxReporterFunTest): Simplify patching code
The limitation to the header is not actually needed when also limiting replacement to the first occurrence, so remove that code to simplify things. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 7250e66 commit 012f099

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

plugins/reporters/cyclonedx/src/funTest/kotlin/CycloneDxReporterFunTest.kt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,14 @@ class CycloneDxReporterFunTest : WordSpec({
168168
}
169169
})
170170

171-
private fun String.patchCycloneDxResult(): String {
172-
val headerEnd = indexOf("components").takeUnless { it < 0 } ?: length
173-
return substring(0, headerEnd)
174-
.replaceFirst(
175-
"""urn:uuid:[a-f0-9]{8}(?:-[a-f0-9]{4}){4}[a-f0-9]{8}""".toRegex(),
176-
"urn:uuid:01234567-0123-0123-0123-01234567"
177-
)
178-
.replaceFirst(
179-
"""(timestamp[>"](\s*:\s*")?)\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z""".toRegex(),
180-
"$11970-01-01T00:00:00Z"
181-
)
182-
.replaceFirst(
183-
"""(version[>"](\s*:\s*")?)[\w.+-]+""".toRegex(),
184-
"$1deadbeef"
185-
) + substring(headerEnd)
186-
}
171+
private fun String.patchCycloneDxResult(): String =
172+
replaceFirst(
173+
"""urn:uuid:[a-f0-9]{8}(?:-[a-f0-9]{4}){4}[a-f0-9]{8}""".toRegex(),
174+
"urn:uuid:01234567-0123-0123-0123-01234567"
175+
).replaceFirst(
176+
"""(timestamp[>"](\s*:\s*")?)\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z""".toRegex(),
177+
"$11970-01-01T00:00:00Z"
178+
).replaceFirst(
179+
"""(version[>"](\s*:\s*")?)[\w.+-]+""".toRegex(),
180+
"$1deadbeef"
181+
)

0 commit comments

Comments
 (0)