Skip to content

Commit a4eadb6

Browse files
committed
refactor(spdx): Add an overload for toSpdxId()
Allow for passing just the `type` as alternative to passing `infix` and `suffix` separately, to slightly simplify the caller code. Signed-off-by: Frank Viernau <[email protected]>
1 parent 0d385b9 commit a4eadb6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugins/reporters/spdx/src/main/kotlin/Extensions.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ internal fun Identifier.toSpdxId(infix: String = "Package", suffix: String = "")
8181
if (suffix.isNotEmpty()) append("-$suffix")
8282
}.toSpdxId()
8383

84+
/**
85+
* Convert an [Identifier]'s coordinates to an SPDX reference ID for the specified [type].
86+
*/
87+
internal fun Identifier.toSpdxId(type: SpdxPackageType): String = toSpdxId(type.infix, type.suffix)
88+
8489
/**
8590
* Get the text with all Copyright statements associated with the package of the given [id], or return `NONE` if there
8691
* are no associated Copyright statements.
@@ -145,7 +150,7 @@ internal fun Package.toSpdxPackage(
145150
}
146151

147152
return SpdxPackage(
148-
spdxId = id.toSpdxId(type.infix, type.suffix),
153+
spdxId = id.toSpdxId(type),
149154
checksums = when (type) {
150155
SpdxPackageType.BINARY_PACKAGE -> listOfNotNull(binaryArtifact.hash.toSpdxChecksum())
151156
SpdxPackageType.SOURCE_PACKAGE -> listOfNotNull(sourceArtifact.hash.toSpdxChecksum())

0 commit comments

Comments
 (0)