Skip to content

Commit

Permalink
chore(ort-utils): Warn if a mapping to an invalid license is configured
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jun 6, 2024
1 parent 0efd110 commit 19cfe2a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions utils/ort/src/main/kotlin/DeclaredLicenseProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,17 @@ object DeclaredLicenseProcessor {
?: SpdxDeclaredLicenseMapping.map(strippedLicense)
?: SpdxDeclaredLicenseMapping.map(strippedLicense.unquote())
?: SpdxDeclaredLicenseMapping.map(strippedLicense.removePrefix(SpdxConstants.TAG).trim())
?: parseLicense(strippedLicense)

return mappedLicense?.normalize()?.takeIf { it.isValid() || it.toString() == SpdxConstants.NONE }
if (mappedLicense?.isValid() == false) {
logger.warn {
"Declared license '$declaredLicense' is configured to map to '$mappedLicense' which is not a valid " +
"SPDX expression."
}
}

val processedLicense = mappedLicense ?: parseLicense(strippedLicense)

return processedLicense?.normalize()?.takeIf { it.isValid() || it.toString() == SpdxConstants.NONE }
}

/**
Expand Down

0 comments on commit 19cfe2a

Please sign in to comment.