Skip to content

Commit

Permalink
fix(scanoss): Properly deal with empty licenses for snippets
Browse files Browse the repository at this point in the history
This avoids

    UnsupportedOperationException: Empty collection can't be reduced.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Aug 18, 2024
1 parent b1caae2 commit 5fff408
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.ossreviewtoolkit.model.VcsInfo
import org.ossreviewtoolkit.model.VcsType
import org.ossreviewtoolkit.utils.spdx.SpdxConstants
import org.ossreviewtoolkit.utils.spdx.SpdxExpression
import org.ossreviewtoolkit.utils.spdx.SpdxLicenseIdExpression

/**
* Generate a summary from the given SCANOSS [result], using [startTime], [endTime] as metadata. This variant can be
Expand Down Expand Up @@ -147,7 +148,7 @@ private fun getSnippets(details: ScanFileDetails): Set<Snippet> {
snippetLocation,
snippetProvenance,
it,
licenses.reduce(SpdxExpression::and).sorted()
licenses.reduceOrNull(SpdxExpression::and)?.sorted() ?: SpdxLicenseIdExpression(SpdxConstants.NOASSERTION)
)
}
}
Expand Down

0 comments on commit 5fff408

Please sign in to comment.