Skip to content

Commit

Permalink
chore(scanoss): Make skipping of "none" file details explicit
Browse files Browse the repository at this point in the history
Instead of implicitly ignoring unsupported file detail IDs, handle "none"
explicitly and throw on unsupported IDs to uncover any issues.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Aug 18, 2024
1 parent 97ece6d commit e5303d7
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions plugins/scanners/scanoss/src/main/kotlin/ScanOssResultParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,29 @@ internal fun generateSummary(startTime: Instant, endTime: Instant, results: List

results.forEach { result ->
result.fileDetails.forEach { details ->
if (details.id == "file") {
licenseFindings += getLicenseFindings(details)
copyrightFindings += getCopyrightFindings(details)
}
when (details.id) {
"file" -> {
licenseFindings += getLicenseFindings(details)
copyrightFindings += getCopyrightFindings(details)
}

if (details.id == "snippet") {
val file = requireNotNull(details.file)
val lines = requireNotNull(details.lines)
val sourceLocation = convertLines(file, lines)
val snippets = getSnippets(details)
"snippet" -> {
val file = requireNotNull(details.file)
val lines = requireNotNull(details.lines)
val sourceLocation = convertLines(file, lines)
val snippets = getSnippets(details)

snippets.forEach {
// TODO: Aggregate the snippet by source file location.
snippetFindings += SnippetFinding(sourceLocation, setOf(it))
snippets.forEach {
// TODO: Aggregate the snippet by source file location.
snippetFindings += SnippetFinding(sourceLocation, setOf(it))
}
}

"none" -> {
// Skip if no details are available.
}

else -> throw IllegalArgumentException("Unsupported file details id '${details.id}'.")
}
}
}
Expand Down

0 comments on commit e5303d7

Please sign in to comment.