Skip to content

Commit

Permalink
fix(ctrlx-reporter): Only use real SPDX IDs
Browse files Browse the repository at this point in the history
The `License`'s `spdx` field should not contain any license name, but
only a real SPDX ID, if any.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Aug 14, 2024
1 parent 46aa773 commit b194374
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.ossreviewtoolkit.model.licenses.LicenseView
import org.ossreviewtoolkit.reporter.Reporter
import org.ossreviewtoolkit.reporter.ReporterInput
import org.ossreviewtoolkit.utils.spdx.SpdxConstants
import org.ossreviewtoolkit.utils.spdx.SpdxLicense

class CtrlXAutomationReporter : Reporter {
companion object {
Expand Down Expand Up @@ -71,9 +72,10 @@ class CtrlXAutomationReporter : Reporter {
input.ortResult.getRepositoryLicenseChoices()
)
val licenses = effectiveLicense?.decompose()?.map {
val id = it.toString()
val text = input.licenseTextProvider.getLicenseText(id)
License(name = id, spdx = id, text = text.orEmpty())
val name = it.toString()
val spdxId = SpdxLicense.forId(name)?.id
val text = input.licenseTextProvider.getLicenseText(name)
License(name = name, spdx = spdxId, text = text.orEmpty())
}

// The specification requires at least one license.
Expand Down

0 comments on commit b194374

Please sign in to comment.