Skip to content

Commit

Permalink
chore(scanoss): Directly map to sets
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Aug 18, 2024
1 parent d1ee3dd commit 58deae0
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,24 @@ private fun getSnippets(details: ScanFileDetails): Set<Snippet> {
val url = requireNotNull(details.url)
val purls = requireNotNull(details.purls)

val licenses = details.licenseDetails.orEmpty().map { license ->
val licenses = details.licenseDetails.orEmpty().mapTo(mutableSetOf()) { license ->
SpdxExpression.parse(license.name)
}.toSet()
}

val score = matched.substringBeforeLast("%").toFloat()
val snippetLocation = convertLines(fileUrl, ossLines)
// TODO: No resolved revision is available. Should a ArtifactProvenance be created instead ?
val snippetProvenance = RepositoryProvenance(VcsInfo(VcsType.UNKNOWN, url, ""), ".")

return purls.map {
return purls.mapTo(mutableSetOf()) {
Snippet(
score,
snippetLocation,
snippetProvenance,
it,
licenses.distinct().reduce(SpdxExpression::and).sorted()
)
}.toSet()
}
}

/**
Expand Down

0 comments on commit 58deae0

Please sign in to comment.