Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deepsource: VET-V0008 Lock erroneously passed by value (internal/test, singleflight, observability) #1863

Merged
merged 3 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions internal/observability/metrics/agent/sidecar/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package sidecar
import (
"context"
"reflect"
"sync"
"testing"

"github.com/vdaas/vald/internal/errors"
Expand Down Expand Up @@ -96,7 +95,6 @@ func Test_sidecarMetrics_Register(t *testing.T) {
storageTypeKey string
bucketNameKey string
filenameKey string
mu sync.Mutex
info *observer.BackupInfo
}
type want struct {
Expand Down Expand Up @@ -129,7 +127,6 @@ func Test_sidecarMetrics_Register(t *testing.T) {
storageTypeKey: "",
bucketNameKey: "",
filenameKey: "",
mu: nil,
info: nil,
},
want: want{},
Expand All @@ -149,7 +146,6 @@ func Test_sidecarMetrics_Register(t *testing.T) {
storageTypeKey: "",
bucketNameKey: "",
filenameKey: "",
mu: nil,
info: nil,
},
want: want{},
Expand Down Expand Up @@ -178,7 +174,6 @@ func Test_sidecarMetrics_Register(t *testing.T) {
storageTypeKey: test.fields.storageTypeKey,
bucketNameKey: test.fields.bucketNameKey,
filenameKey: test.fields.filenameKey,
mu: test.fields.mu,
info: test.fields.info,
}

Expand All @@ -199,7 +194,6 @@ func Test_sidecarMetrics_BeforeProcess(t *testing.T) {
storageTypeKey string
bucketNameKey string
filenameKey string
mu sync.Mutex
info *observer.BackupInfo
}
type want struct {
Expand Down Expand Up @@ -237,7 +231,6 @@ func Test_sidecarMetrics_BeforeProcess(t *testing.T) {
storageTypeKey: "",
bucketNameKey: "",
filenameKey: "",
mu: nil,
info: nil,
},
want: want{},
Expand All @@ -258,7 +251,6 @@ func Test_sidecarMetrics_BeforeProcess(t *testing.T) {
storageTypeKey: "",
bucketNameKey: "",
filenameKey: "",
mu: nil,
info: nil,
},
want: want{},
Expand Down Expand Up @@ -287,7 +279,6 @@ func Test_sidecarMetrics_BeforeProcess(t *testing.T) {
storageTypeKey: test.fields.storageTypeKey,
bucketNameKey: test.fields.bucketNameKey,
filenameKey: test.fields.filenameKey,
mu: test.fields.mu,
info: test.fields.info,
}

Expand All @@ -308,7 +299,6 @@ func Test_sidecarMetrics_AfterProcess(t *testing.T) {
storageTypeKey string
bucketNameKey string
filenameKey string
mu sync.Mutex
info *observer.BackupInfo
}
type want struct {
Expand Down Expand Up @@ -342,7 +332,6 @@ func Test_sidecarMetrics_AfterProcess(t *testing.T) {
storageTypeKey: "",
bucketNameKey: "",
filenameKey: "",
mu: nil,
info: nil,
},
want: want{},
Expand All @@ -363,7 +352,6 @@ func Test_sidecarMetrics_AfterProcess(t *testing.T) {
storageTypeKey: "",
bucketNameKey: "",
filenameKey: "",
mu: nil,
info: nil,
},
want: want{},
Expand Down Expand Up @@ -392,7 +380,6 @@ func Test_sidecarMetrics_AfterProcess(t *testing.T) {
storageTypeKey: test.fields.storageTypeKey,
bucketNameKey: test.fields.bucketNameKey,
filenameKey: test.fields.filenameKey,
mu: test.fields.mu,
info: test.fields.info,
}

Expand All @@ -409,7 +396,6 @@ func Test_sidecarMetrics_View(t *testing.T) {
storageTypeKey string
bucketNameKey string
filenameKey string
mu sync.Mutex
info *observer.BackupInfo
}
type want struct {
Expand Down Expand Up @@ -442,7 +428,6 @@ func Test_sidecarMetrics_View(t *testing.T) {
storageTypeKey: "",
bucketNameKey: "",
filenameKey: "",
mu: nil,
info: nil,
},
want: want{},
Expand All @@ -459,7 +444,6 @@ func Test_sidecarMetrics_View(t *testing.T) {
storageTypeKey: "",
bucketNameKey: "",
filenameKey: "",
mu: nil,
info: nil,
},
want: want{},
Expand Down Expand Up @@ -488,7 +472,6 @@ func Test_sidecarMetrics_View(t *testing.T) {
storageTypeKey: test.fields.storageTypeKey,
bucketNameKey: test.fields.bucketNameKey,
filenameKey: test.fields.filenameKey,
mu: test.fields.mu,
info: test.fields.info,
}

Expand Down
8 changes: 2 additions & 6 deletions internal/singleflight/singleflight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ func Test_group_Do(t *testing.T) {
key string
fn func() (interface{}, error)
}
type fields struct {
m sync.Map
}
type fields struct{}
vankichi marked this conversation as resolved.
Show resolved Hide resolved
type want struct {
wantV interface{}
wantShared bool
Expand Down Expand Up @@ -278,9 +276,7 @@ func Test_group_Do(t *testing.T) {
test.beforeFunc(test.args)
}

g := &group{
m: test.fields.m,
}
g := &group{}

execFunc := defaultExecFunc
if test.execFunc != nil {
Expand Down
6 changes: 6 additions & 0 deletions internal/test/comparator/comparators.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ var (
return reflect.DeepEqual(x, y)
})

// skipcq: VET-V0008
MutexComparer = Comparer(func(x, y sync.Mutex) bool {
// skipcq: VET-V0008
return reflect.DeepEqual(x, y)
})

Expand All @@ -37,11 +39,15 @@ var (
return errors.Is(x, y)
})

// skipcq: VET-V0008
OnceComparer = Comparer(func(x, y sync.Once) bool {
// skipcq: VET-V0008
return reflect.DeepEqual(x, y)
})

// skipcq: VET-V0008
WaitGroupComparer = Comparer(func(x, y sync.WaitGroup) bool {
// skipcq: VET-V0008
return reflect.DeepEqual(x, y)
})
)