Skip to content

Commit

Permalink
fix(SpdxDocumentFile): Ensure to collect issues from external doc refs
Browse files Browse the repository at this point in the history
Before, issues from external document refs, which could not be mapped to
a `packageId`, failed to be added as issue in the ORT result.
Add these missing transitive issues, by explicitly check for any issues
that are not related to known packages.

Signed-off-by: Marcel Bochtler <[email protected]>
  • Loading branch information
MarcelBochtler committed Jul 15, 2024
1 parent d439b72 commit db036d3
Show file tree
Hide file tree
Showing 2 changed files with 11 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,16 @@ 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[referenceId] == null
}.values.toList()
}

/**
* 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 db036d3

Please sign in to comment.