1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 05:40:11 +01:00

Exchange slice with util.set for mistakes in checkMissing

This commit is contained in:
JanHoefelmeyer 2023-08-23 12:29:05 +02:00
parent 7651dc2a05
commit 4b56f3e837

View file

@ -24,7 +24,6 @@ import (
"net/url" "net/url"
"path/filepath" "path/filepath"
"regexp" "regexp"
"slices"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@ -1117,7 +1116,7 @@ func (p *processor) checkMissing(string) error {
v := p.alreadyChecked[f] v := p.alreadyChecked[f]
var where []string var where []string
// mistake contains which requirements are broken // mistake contains which requirements are broken
var mistake []string mistake := util.Set[whereType]{}
for mask := rolieMask; mask <= listingMask; mask <<= 1 { for mask := rolieMask; mask <= listingMask; mask <<= 1 {
if maxMask&mask == mask { if maxMask&mask == mask {
var in string var in string
@ -1126,22 +1125,22 @@ func (p *processor) checkMissing(string) error {
} else { } else {
in = "not in" in = "not in"
// Which file is missing entries? // Which file is missing entries?
mistake = append(mistake, mask.String()) mistake.Add(mask)
} }
where = append(where, in+" "+mask.String()) where = append(where, in+" "+mask.String())
} }
} }
// List error in all appropriate categories // List error in all appropriate categories
if slices.Contains(mistake, "ROLIE") { if mistake.Contains(rolieMask) {
p.badROLIEFeed.error("%s %s", f, strings.Join(where, ", ")) p.badROLIEFeed.error("%s %s", f, strings.Join(where, ", "))
} }
if slices.Contains(mistake, "index.txt") { if mistake.Contains(indexMask) {
p.badIndices.error("%s %s", f, strings.Join(where, ", ")) p.badIndices.error("%s %s", f, strings.Join(where, ", "))
} }
if slices.Contains(mistake, "changes.csv") { if mistake.Contains(changesMask) {
p.badChanges.error("%s %s", f, strings.Join(where, ", ")) p.badChanges.error("%s %s", f, strings.Join(where, ", "))
} }
if slices.Contains(mistake, "directory listing") { if mistake.Contains(listingMask) {
p.badDirListings.error("%s %s", f, strings.Join(where, ", ")) p.badDirListings.error("%s %s", f, strings.Join(where, ", "))
} }
// reset mistake // reset mistake