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 <marcel.bochtler@bosch.com>
  • Loading branch information
MarcelBochtler committed Jul 17, 2024
1 parent 89fe68d commit c8eb52a
Show file tree
Hide file tree
Showing 2 changed files with 10 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,15 @@ 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 within the SPDX document.
*/
fun getIssuesWithoutSpdxPackage() =
issuesByReferenceId.mapNotNull { (id, issue) ->
if (packagesById[id] == null) issue else null
}

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

Please sign in to comment.