Skip to content

Commit

Permalink
refactor(reporters): Drop an unnecessary condition
Browse files Browse the repository at this point in the history
The set `allLicenses` only contains values returned by
`SpdxExpression.licenses()` which excludes exceptions.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau authored and sschuberth committed Sep 13, 2023
1 parent 057e078 commit 913ea14
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions plugins/reporters/spdx/src/main/kotlin/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import org.ossreviewtoolkit.utils.ort.ProcessedDeclaredLicense
import org.ossreviewtoolkit.utils.spdx.SpdxConstants
import org.ossreviewtoolkit.utils.spdx.SpdxExpression
import org.ossreviewtoolkit.utils.spdx.SpdxLicense
import org.ossreviewtoolkit.utils.spdx.SpdxLicenseException
import org.ossreviewtoolkit.utils.spdx.calculatePackageVerificationCode
import org.ossreviewtoolkit.utils.spdx.model.SpdxChecksum
import org.ossreviewtoolkit.utils.spdx.model.SpdxDocument
Expand Down Expand Up @@ -232,9 +231,7 @@ internal fun SpdxDocument.addExtractedLicenseInfo(licenseTextProvider: LicenseTe
}
}.flatMapTo(mutableSetOf()) { SpdxExpression.parse(it).licenses() }

val nonSpdxLicenses = allLicenses.filter {
SpdxConstants.isPresent(it) && SpdxLicense.forId(it) == null && SpdxLicenseException.forId(it) == null
}
val nonSpdxLicenses = allLicenses.filter { SpdxConstants.isPresent(it) && SpdxLicense.forId(it) == null }

val extractedLicenseInfo = nonSpdxLicenses.sorted().mapNotNull { license ->
licenseTextProvider.getLicenseText(license)?.let { text ->
Expand Down

0 comments on commit 913ea14

Please sign in to comment.