Skip to content

Commit dbe12c9

Browse files
committed
refactor(scancode): Use the SPDX license expression via the interface
This allows to drop the case distinction based on the version, which actually is a code smell: The model mapper should exclusively use the interfaces in a version-agnostic way, and the implementations of the interfaces should handle the version-specifics. While at it, remove a misleading code comment and adjust a variable name. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 1ae5834 commit dbe12c9

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

plugins/scanners/scancode/src/main/kotlin/ScanCodeResultModelMapper.kt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,11 @@ fun ScanCodeResult.toScanSummary(preferFileLicense: Boolean = false): ScanSummar
117117
)
118118
} else {
119119
licenses.mapTo(licenseFindings) { license ->
120-
// ScanCode uses its own license keys as identifiers in license expressions.
121-
val spdxLicenseExpression = when {
122-
license is LicenseEntry.Version3 && license.spdxLicenseExpression != null -> {
123-
license.spdxLicenseExpression
124-
}
125-
126-
license is LicenseEntry.Version4 && license.licenseExpressionSpdx != null -> {
127-
license.licenseExpressionSpdx
128-
}
129-
130-
else -> license.licenseExpression.mapLicense(scanCodeKeyToSpdxIdMappings)
131-
}
120+
val licenseExpression = license.licenseExpressionSpdx
121+
?: license.licenseExpression.mapLicense(scanCodeKeyToSpdxIdMappings)
132122

133123
LicenseFinding(
134-
license = spdxLicenseExpression,
124+
license = licenseExpression,
135125
location = TextLocation(
136126
path = file.path,
137127
startLine = license.startLine,

0 commit comments

Comments
 (0)