Skip to content

Commit 13705a1

Browse files
committed
fix(spdx-reporter): Do not try to add empty license texts
The `SpdxExtractedLicenseInfo` class requires that the license text is not empty. However, in some situations it can be that a license text from a `LicenseFactProvider` is empty, for example, if a ScanCode license text contains only YAML front matter, or if a custom license text file is empty. To not fail the SPDX reporter in this situation, simply check if a license text is empty before creating the `SpdxExtractedLicenseInfo`. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
1 parent 2155566 commit 13705a1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ internal fun SpdxDocument.addExtractedLicenseInfo(licenseFactProvider: LicenseFa
242242
val nonSpdxLicenses = allLicenses.filter { SpdxConstants.isPresent(it) && SpdxLicense.forId(it) == null }
243243

244244
val extractedLicenseInfo = nonSpdxLicenses.sorted().mapNotNull { license ->
245-
licenseFactProvider.getLicenseText(license)?.let { text ->
245+
licenseFactProvider.getLicenseText(license)?.takeIf { it.isNotBlank() }?.let { text ->
246246
SpdxExtractedLicenseInfo(
247247
licenseId = license,
248248
extractedText = text

0 commit comments

Comments
 (0)