Skip to content

Commit

Permalink
refactor(spdx): Add an overload for toSpdxId()
Browse files Browse the repository at this point in the history
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 <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Sep 25, 2023
1 parent 0d385b9 commit a4eadb6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/reporters/spdx/src/main/kotlin/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ internal fun Identifier.toSpdxId(infix: String = "Package", suffix: String = "")
if (suffix.isNotEmpty()) append("-$suffix")
}.toSpdxId()

/**
* Convert an [Identifier]'s coordinates to an SPDX reference ID for the specified [type].
*/
internal fun Identifier.toSpdxId(type: SpdxPackageType): String = toSpdxId(type.infix, type.suffix)

/**
* Get the text with all Copyright statements associated with the package of the given [id], or return `NONE` if there
* are no associated Copyright statements.
Expand Down Expand Up @@ -145,7 +150,7 @@ internal fun Package.toSpdxPackage(
}

return SpdxPackage(
spdxId = id.toSpdxId(type.infix, type.suffix),
spdxId = id.toSpdxId(type),
checksums = when (type) {
SpdxPackageType.BINARY_PACKAGE -> listOfNotNull(binaryArtifact.hash.toSpdxChecksum())
SpdxPackageType.SOURCE_PACKAGE -> listOfNotNull(sourceArtifact.hash.toSpdxChecksum())
Expand Down

0 comments on commit a4eadb6

Please sign in to comment.