feat(aa): add merge methods to the rule interface.

This commit is contained in:
Alexandre Pujol 2024-06-22 20:59:43 +01:00
parent a91e2ddf56
commit 6791dcde28
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
14 changed files with 192 additions and 11 deletions

View file

@ -26,6 +26,23 @@ func boolToInt(b bool) int {
return 0
}
func merge(kind Kind, key string, a, b []string) []string {
a = append(a, b...)
switch kind {
case FILE:
slices.SortFunc(a, compareFileAccess)
case VARIABLE:
slices.SortFunc(a, func(s1, s2 string) int {
return compare(s1, s2)
})
default:
slices.SortFunc(a, func(i, j string) int {
return requirementsWeights[kind][key][i] - requirementsWeights[kind][key][j]
})
}
return slices.Compact(a)
}
func compare(a, b any) int {
switch a := a.(type) {
case int: