Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model: Improve and align OrtResult.getIssues() #8507

Merged
merged 9 commits into from
Apr 12, 2024
Merged

Conversation

fviernau
Copy link
Member

Align with getRuleViolations() and getVulnerabilities() and make the API more flexible.
This prepares for filtering the issues by their affected path in a following change.

Context: #7921.

@fviernau fviernau requested a review from a team as a code owner April 10, 2024 14:36
@fviernau fviernau force-pushed the model-align-test-issues branch 2 times, most recently from 1b88b8b to 6dd0c4e Compare April 11, 2024 06:18
model/src/main/kotlin/OrtResult.kt Outdated Show resolved Hide resolved
issues.filterTo(mutableSetOf()) { !omitResolved || !isResolved(it) }
issues.filterTo(mutableSetOf()) {
(!omitResolved || !isResolved(it)) && it.severity >= minSeverity
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all, this could now look something like this:

    return allIssues.mapNotNull { (id, issues) ->
        if (omitExcluded && isExcluded(id)) return@mapNotNull null

        val filteredIssues = issues.filterTo(mutableSetOf()) {
            (!omitResolved || !isResolved(it)) && it.severity >= minSeverity
        }

        filteredIssues.takeUnless { it.isEmpty() }?.let { id to it }
    }.toMap()

model/src/main/kotlin/OrtResult.kt Show resolved Hide resolved
model/src/main/kotlin/OrtResult.kt Outdated Show resolved Hide resolved
model/src/test/kotlin/OrtResultTest.kt Outdated Show resolved Hide resolved
model/src/test/kotlin/OrtResultTest.kt Outdated Show resolved Hide resolved
@fviernau fviernau force-pushed the model-align-test-issues branch 2 times, most recently from 3f4084a to 4c547b1 Compare April 11, 2024 15:05
@@ -260,13 +260,15 @@ data class OrtResult(

val allIssues = analyzerIssues.zipWithCollections(scannerIssues).zipWithCollections(advisorIssues)

return allIssues.mapValues { (_, issues) ->
issues.filterTo(mutableSetOf()) {
return allIssues.mapNotNull { (id, issues) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hunk seems to have gone to the wrong commit.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
The same issue can occur for different identifiers, for example when a
scan of a specific provenance corresponds to multiple identifiers. So,
return only distinct issues.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Avoid dealing with a nullable `minSeverity` in the same way as in
`getIssues()`.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Remove the a performance optimization to simplify the code.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
@fviernau fviernau merged commit 6f3af0d into main Apr 12, 2024
20 of 21 checks passed
@fviernau fviernau deleted the model-align-test-issues branch April 12, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants