Skip to content

Commit

Permalink
fix(SpdxDocumentFile): Ensure to collect all issues
Browse files Browse the repository at this point in the history
Issues that can not be mapped to a `packageId` also have to be added to
the result to avoid dropping issues.

Signed-off-by: Marcel Bochtler <[email protected]>
  • Loading branch information
MarcelBochtler committed Jul 8, 2024
1 parent 4a191b1 commit d5f09b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ class SpdxDocumentFile(
scopeDependencies = scopes
)

return listOf(ProjectAnalyzerResult(project, packages))
return listOf(ProjectAnalyzerResult(project, packages, transitiveDocument.getIssuesWithoutSpdxPackage()))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ internal data class SpdxResolvedDocument(
return pkg
}

/**
* Retrieve the issues from [issuesByReferenceId] that are not associated with any package [packagesById]. These
* issues can be related to general issues with the SPDX document.
*/
fun getIssuesWithoutSpdxPackage(): List<Issue> {
return issuesByReferenceId.filterKeys { referenceId ->
packagesById.keys.none { packageId ->
packageId.startsWith("$referenceId:")

Check warning on line 143 in plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt

View check run for this annotation

Codecov / codecov/patch

plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt#L141-L143

Added lines #L141 - L143 were not covered by tests
}
}.values.toList()

Check warning on line 145 in plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt

View check run for this annotation

Codecov / codecov/patch

plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt#L145

Added line #L145 was not covered by tests
}

/**
* Return the local definition file in which the package with the given [identifier] is declared. If the package
* cannot be resolved or if it has not been declared in a local file, return *null*.
Expand Down

0 comments on commit d5f09b6

Please sign in to comment.