Skip to content

Commit

Permalink
golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Icarus Wu <[email protected]>
  • Loading branch information
Icarus9913 committed Dec 23, 2024
1 parent 2d5bf1d commit 8035df6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
6 changes: 0 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ issues:
- linters:
- gocritic
text: "appendAssign: append result not assigned to the same slice" # None of the instances of this in Kuma were bugs.
- linters:
- gocritic
text: "elseif: can replace 'else {if cond {}}' with 'else if cond {}'" # None of the instances of this in Kuma were bugs.
- linters:
- gosimple
text: "S1008: should use 'return overlapKeyCount != 0' instead of 'if overlapKeyCount == 0 { return false }; return true'" # Ignore this to better read the code
- linters:
- staticcheck
text: "SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated" # https://github.com/kumahq/kuma/issues/2460
Expand Down
17 changes: 5 additions & 12 deletions pkg/plugins/policies/core/rules/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ func (ss Subset) ContainsElement(element Element) bool {
return true
}

overlapKeyCount := 0
hasOverlapKey := false
for _, tag := range ss {
tmpVal, ok := element[tag.Key]
if ok {
overlapKeyCount++
hasOverlapKey = true

// contradict
if tag.Value == tmpVal && tag.Not {
Expand All @@ -161,20 +161,13 @@ func (ss Subset) ContainsElement(element Element) bool {
if tag.Value != tmpVal && !tag.Not {
return false
}
} else {
} else if !tag.Not {
// for those items that don't exist in element should not make an impact
if !tag.Not {
return false
}
return false
}
}

// no overlap means no connections
if overlapKeyCount == 0 {
return false
}

return true
return hasOverlapKey
}

// IsSubset returns true if 'other' is a subset of the current set.
Expand Down

0 comments on commit 8035df6

Please sign in to comment.