[#1671] Use slices.ContainsFunc() where possible
All checks were successful
DCO action / DCO (pull_request) Successful in 29s
Vulncheck / Vulncheck (pull_request) Successful in 1m0s
Build / Build Components (pull_request) Successful in 1m25s
Tests and linters / Run gofumpt (pull_request) Successful in 1m16s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m28s
Tests and linters / Staticcheck (pull_request) Successful in 2m8s
Tests and linters / Tests (pull_request) Successful in 2m26s
Tests and linters / Lint (pull_request) Successful in 2m45s
Tests and linters / gopls check (pull_request) Successful in 2m49s
Tests and linters / Tests with -race (pull_request) Successful in 3m9s

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2025-03-13 09:34:59 +03:00
parent 803a550c1f
commit 14837b17c6
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg
5 changed files with 16 additions and 28 deletions

View file

@ -3,6 +3,7 @@ package helper
import (
"errors"
"fmt"
"slices"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
@ -118,11 +119,8 @@ func MergeNetmapConfig(roInvoker *invoker.Invoker, md map[string]any) error {
return err
}
for k, v := range m {
for _, key := range NetmapConfigKeys {
if k == key {
md[k] = v
break
}
if slices.Contains(NetmapConfigKeys, k) {
md[k] = v
}
}
return nil

View file

@ -3,6 +3,7 @@ package network
import (
"errors"
"fmt"
"slices"
"sort"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
@ -164,10 +165,8 @@ func WriteToNodeInfo(g AddressGroup, ni *netmap.NodeInfo) {
// at least one common address.
func (x AddressGroup) Intersects(x2 AddressGroup) bool {
for i := range x {
for j := range x2 {
if x[i].equal(x2[j]) {
return true
}
if slices.ContainsFunc(x2, x[i].equal) {
return true
}
}

View file

@ -4,6 +4,7 @@ import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"slices"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl"
@ -91,13 +92,7 @@ func TestIsVerbCompatible(t *testing.T) {
for op, list := range table {
for _, verb := range verbs {
var contains bool
for _, v := range list {
if v == verb {
contains = true
break
}
}
contains := slices.Contains(list, verb)
tok.ForVerb(verb)

View file

@ -4,6 +4,7 @@ import (
"bytes"
"context"
"errors"
"slices"
"sort"
"testing"
"time"
@ -226,10 +227,8 @@ func TestProcessObject(t *testing.T) {
return nil, err
}
}
for _, i := range ti.objHolders {
if index == i {
return nil, nil
}
if slices.Contains(ti.objHolders, index) {
return nil, nil
}
return nil, new(apistatus.ObjectNotFound)
}

View file

@ -340,14 +340,11 @@ func (s *Service) GetNodeByPath(ctx context.Context, req *GetNodeByPathRequest)
} else {
var metaValue []KeyValue
for _, kv := range m.Items {
for _, attr := range b.GetAttributes() {
if kv.Key == attr {
metaValue = append(metaValue, KeyValue{
Key: kv.Key,
Value: kv.Value,
})
break
}
if slices.Contains(b.GetAttributes(), kv.Key) {
metaValue = append(metaValue, KeyValue{
Key: kv.Key,
Value: kv.Value,
})
}
}
x.Meta = metaValue