Skip to content

Commit

Permalink
refactor(scanners): Rename a snippet's license to singular
Browse files Browse the repository at this point in the history
While the expression could contain compound sub-expressions, it is still
a single expression. This aligns with `LicenseFinding` and also helps to
distinguish from a list of expressions in an upcoming change.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Aug 24, 2024
1 parent e191061 commit a28a503
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions model/src/main/kotlin/Snippet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ data class Snippet(
val purl: String,

/**
* The license of the component the code snippet is commit from.
* The SPDX license expression of the component the code snippet is coming from.
*/
val licenses: SpdxExpression,
val license: SpdxExpression,

/**
* A map for scanner-specific snippet data that cannot be mapped into any generalized property, but still needs to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class FreemarkerTemplateProcessor(
*/
@Suppress("UNUSED") // This function is used in the templates.
fun collectLicenses(snippetsFindings: Collection<SnippetFinding>): Set<String> =
snippetsFindings.flatMap { findings -> findings.snippets }.map { snippet -> snippet.licenses.toString() }
snippetsFindings.flatMap { findings -> findings.snippets }.map { snippet -> snippet.license.toString() }
.toSet()

/**
Expand Down
4 changes: 2 additions & 2 deletions plugins/scanners/fossid/src/main/kotlin/FossIdScanResults.kt
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ private fun getLicenseFindingFromSnippetChoice(
return if (isSnippetChoice) {
logger.info {
"Adding snippet choice for ${sourceLocation.prettyPrint()} " +
"with license ${snippet.licenses} to the license findings."
"with license ${snippet.license} to the license findings."
}

LicenseFinding(snippet.licenses, sourceLocation)
LicenseFinding(snippet.license, sourceLocation)
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class FossIdLicenseMappingTest : WordSpec({
findings should haveSize(1)
findings.first() shouldNotBeNull {
snippets.first() shouldNotBeNull {
licenses.toString() shouldBe "Apache-2.0"
license.toString() shouldBe "Apache-2.0"
}
}
}
Expand All @@ -96,7 +96,7 @@ class FossIdLicenseMappingTest : WordSpec({
findings should haveSize(1)
findings.first() shouldNotBeNull {
snippets.first() shouldNotBeNull {
licenses.toString() shouldBe "GFDL-1.2-only"
license.toString() shouldBe "GFDL-1.2-only"
}
}
}
Expand All @@ -118,7 +118,7 @@ class FossIdLicenseMappingTest : WordSpec({
findings should haveSize(1)
findings.first() shouldNotBeNull {
snippets.first() shouldNotBeNull {
licenses.toString() shouldBe "Apache-2.0"
license.toString() shouldBe "Apache-2.0"
}
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ class FossIdLicenseMappingTest : WordSpec({
findings should haveSize(1)
findings.first() shouldNotBeNull {
snippets.first() shouldNotBeNull {
licenses shouldBe SpdxConstants.NOASSERTION.toSpdx()
license shouldBe SpdxConstants.NOASSERTION.toSpdx()
}
}
}
Expand Down

0 comments on commit a28a503

Please sign in to comment.