Skip to content

Commit

Permalink
feat(cli): Improve scanner comparison in CompareCommand
Browse files Browse the repository at this point in the history
If the scanners used for the packages are different, only show the
entries that actually are different, not the whole lists.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Dec 8, 2023
1 parent 99472dc commit 47c1c0c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/commands/compare/src/main/kotlin/CompareCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,19 @@ private fun ScannerRun?.diff(other: ScannerRun?, context: SemanticDiffContext):
config = if (context.ignoreConfig) null else config.diff(other.config),
provenancesA = (provenances - other.provenances).takeUnless { it.isEmpty() },
provenancesB = (other.provenances - provenances).takeUnless { it.isEmpty() },
scannersA = scanners.takeIf { it != other.scanners },
scannersB = other.scanners.takeIf { it != scanners },
scannersA = scanners.diff(other.scanners).takeUnless { it.isEmpty() },
scannersB = other.scanners.diff(scanners).takeUnless { it.isEmpty() },
filesA = if (context.ignoreFileList) null else (files - other.files).takeUnless { it.isEmpty() },
filesB = if (context.ignoreFileList) null else (other.files - files).takeUnless { it.isEmpty() },
scanResultDiff = differentResults.takeUnless { it.isEmpty() }
)
}
}

private fun Map<Identifier, Set<String>>.diff(other: Map<Identifier, Set<String>>): Map<Identifier, Set<String>> {
return filter { (id, values) -> other[id] != values }
}

private fun ScannerConfiguration?.diff(other: ScannerConfiguration?): ScannerConfigurationDiff? {
if (this == other) return null

Expand Down

0 comments on commit 47c1c0c

Please sign in to comment.