Skip to content

Commit

Permalink
CuratedPackage: Conditionally lower the severity of unmapped licenses
Browse files Browse the repository at this point in the history
If a concluded license is set, declared licenses are likely not taken
into account at all (depending on policy rules), so lower the severity of
unmapped declared licneses in this case.

Fixes #4081.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed May 28, 2021
1 parent a215986 commit 7c6a80e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions model/src/main/kotlin/CuratedPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ data class CuratedPackage(
/**
* Check if this package contains any erroneous data.
*/
fun collectIssues(): List<OrtIssue> =
pkg.declaredLicensesProcessed.unmapped.map { unmappedLicense ->
fun collectIssues(): List<OrtIssue> {
val severity = pkg.concludedLicense?.let { Severity.HINT } ?: Severity.WARNING
return pkg.declaredLicensesProcessed.unmapped.map { unmappedLicense ->
OrtIssue(
severity = Severity.WARNING,
severity = severity,
source = pkg.id.toCoordinates(),
message = "The declared license '$unmappedLicense' could not be mapped to a valid license or " +
"parsed as an SPDX expression."
)
}
}

/**
* Return a [Package] representing the same package as this one but which does not have any curations applied.
Expand Down

0 comments on commit 7c6a80e

Please sign in to comment.