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/db, backoff, circuitbreaker #1859

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 5 additions & 25 deletions internal/backoff/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"context"
"os"
"reflect"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -88,7 +87,6 @@ func Test_backoff_addJitter(t *testing.T) {
dur float64
}
type fields struct {
wg sync.WaitGroup
backoffFactor float64
initialDuration float64
jittedInitialDuration float64
Expand Down Expand Up @@ -148,7 +146,6 @@ func Test_backoff_addJitter(t *testing.T) {
checkFunc = defaultCheckFunc
}
b := &backoff{
wg: test.fields.wg,
backoffFactor: test.fields.backoffFactor,
initialDuration: test.fields.initialDuration,
jittedInitialDuration: test.fields.jittedInitialDuration,
Expand All @@ -170,9 +167,7 @@ func Test_backoff_addJitter(t *testing.T) {

func Test_backoff_Close(t *testing.T) {
t.Parallel()
type fields struct {
wg sync.WaitGroup
}
type fields struct{}
type want struct{}
type test struct {
name string
Expand All @@ -187,11 +182,9 @@ func Test_backoff_Close(t *testing.T) {
}
tests := []test{
{
name: "success backoff Close",
fields: fields{
wg: sync.WaitGroup{},
},
want: want{},
name: "success backoff Close",
fields: fields{},
want: want{},
},
}

Expand All @@ -210,9 +203,7 @@ func Test_backoff_Close(t *testing.T) {
if test.checkFunc == nil {
checkFunc = defaultCheckFunc
}
b := &backoff{
wg: test.fields.wg,
}
b := &backoff{}
hlts2 marked this conversation as resolved.
Show resolved Hide resolved

b.Close()
if err := checkFunc(test.want); err != nil {
Expand All @@ -229,7 +220,6 @@ func Test_backoff_Do(t *testing.T) {
f func(ctx context.Context) (val interface{}, retryable bool, err error)
}
type fields struct {
wg sync.WaitGroup
backoffFactor float64
initialDuration float64
jittedInitialDuration float64
Expand Down Expand Up @@ -307,7 +297,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 0,
initialDuration: 0,
jittedInitialDuration: 0,
Expand Down Expand Up @@ -337,7 +326,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 0,
initialDuration: 0,
jittedInitialDuration: 0,
Expand Down Expand Up @@ -372,7 +360,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 0,
initialDuration: 0,
jittedInitialDuration: 0,
Expand Down Expand Up @@ -407,7 +394,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 0,
initialDuration: 0,
jittedInitialDuration: 0,
Expand Down Expand Up @@ -436,7 +422,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 0,
initialDuration: 0,
jittedInitialDuration: 0,
Expand Down Expand Up @@ -466,7 +451,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 0,
initialDuration: 0,
jittedInitialDuration: 0,
Expand Down Expand Up @@ -496,7 +480,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 0,
initialDuration: 0,
jittedInitialDuration: 0,
Expand Down Expand Up @@ -530,7 +513,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 0,
initialDuration: 0,
jittedInitialDuration: 0,
Expand Down Expand Up @@ -564,7 +546,6 @@ func Test_backoff_Do(t *testing.T) {
f: f,
},
fields: fields{
wg: sync.WaitGroup{},
backoffFactor: 1.1,
initialDuration: float64(time.Millisecond * 5),
jittedInitialDuration: 0,
Expand Down Expand Up @@ -598,7 +579,6 @@ func Test_backoff_Do(t *testing.T) {
checkFunc = defaultCheckFunc
}
b := &backoff{
wg: test.fields.wg,
backoffFactor: test.fields.backoffFactor,
initialDuration: test.fields.initialDuration,
jittedInitialDuration: test.fields.jittedInitialDuration,
Expand Down
3 changes: 0 additions & 3 deletions internal/circuitbreaker/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package circuitbreaker
import (
"context"
"reflect"
"sync"
"testing"

"github.com/vdaas/vald/internal/errors"
Expand Down Expand Up @@ -107,7 +106,6 @@ func Test_breakerManager_Do(t *testing.T) {
fn func(ctx context.Context) (interface{}, error)
}
type fields struct {
m sync.Map
opts []BreakerOption
}
type want struct {
Expand Down Expand Up @@ -188,7 +186,6 @@ func Test_breakerManager_Do(t *testing.T) {
checkFunc = defaultCheckFunc
}
bm := &breakerManager{
m: test.fields.m,
opts: test.fields.opts,
}

Expand Down
2 changes: 1 addition & 1 deletion internal/db/nosql/cassandra/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var clientComparatorOpts = []comparator.Option{
return reflect.ValueOf(x).Pointer() == reflect.ValueOf(y).Pointer()
}),

comparator.Comparer(func(x, y tls.Config) bool {
comparator.Comparer(func(x, y *tls.Config) bool {
return reflect.DeepEqual(x, y)
}),
}
Expand Down