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

Code Lint: Fix lint errors caused by revive check for unused parameters #959

Merged
merged 1 commit into from
Feb 13, 2024
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
2 changes: 1 addition & 1 deletion cephfs/userperm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestUserPerm(t *testing.T) {
uperm.Destroy()
uperm.Destroy()
})
t.Run("tryForceGc", func(t *testing.T) {
t.Run("tryForceGc", func(_ *testing.T) {
func() {
uperm := NewUserPerm(0, 0, nil)
_ = uperm
Expand Down
2 changes: 1 addition & 1 deletion internal/cutil/command_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestCommandInput(t *testing.T) {
t.Run("newAndFree", func(t *testing.T) {
t.Run("newAndFree", func(_ *testing.T) {
ci := NewCommandInput(
[][]byte{[]byte("foobar")},
nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/cutil/ptrguard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestPtrGuard(t *testing.T) {
var pgDone, uDone bool
goPtr := func(b *bool) unsafe.Pointer {
s := "ok"
runtime.SetFinalizer(&s, func(p *string) { *b = true })
runtime.SetFinalizer(&s, func(_ *string) { *b = true })
return unsafe.Pointer(&s)
}
cPtr := Malloc(PtrSize)
Expand Down
2 changes: 1 addition & 1 deletion internal/retry/sizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestSizer(t *testing.T) {
t.Run("exceedsMax", func(t *testing.T) {
var tries int
var err error
WithSizes(1, 1024, func(size int) Hint {
WithSizes(1, 1024, func(_ int) Hint {
tries++
err = errors.New("foo")
return DoubleSize
Expand Down
6 changes: 3 additions & 3 deletions rados/rados_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ func (suite *RadosTestSuite) TestListAcrossNamespaces() {
// count objects in pool
suite.ioctx.SetNamespace(AllNamespaces)
allFoundObjects := 0
err = suite.ioctx.ListObjects(func(oid string) {
err = suite.ioctx.ListObjects(func(_ string) {
allFoundObjects++
})
assert.NoError(suite.T(), err)
Expand Down Expand Up @@ -1289,14 +1289,14 @@ func (suite *RadosTestSuite) TestSetGetNamespace() {
assert.Equal(t, "space1", ns)
})

suite.T().Run("allNamespaces", func(t *testing.T) {
suite.T().Run("allNamespaces", func(_ *testing.T) {
suite.ioctx.SetNamespace(AllNamespaces)
ns, err := suite.ioctx.GetNamespace()
assert.NoError(suite.T(), err)
assert.Equal(suite.T(), AllNamespaces, ns)
})

suite.T().Run("invalidIoctx", func(t *testing.T) {
suite.T().Run("invalidIoctx", func(_ *testing.T) {
i := &IOContext{}
ns, err := i.GetNamespace()
assert.Error(suite.T(), err)
Expand Down
28 changes: 14 additions & 14 deletions rbd/diff_iterate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestDiffIterate(t *testing.T) {
DiffIterateConfig{
Offset: 0,
Length: uint64(1 << 22),
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(_, _ uint64, _ int, _ interface{}) int {
gotCalled++
return 0
},
Expand Down Expand Up @@ -111,7 +111,7 @@ func testDiffIterateBasic(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand All @@ -127,7 +127,7 @@ func testDiffIterateBasic(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand All @@ -146,7 +146,7 @@ func testDiffIterateBasic(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand All @@ -167,7 +167,7 @@ func testDiffIterateBasic(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand All @@ -190,7 +190,7 @@ func testDiffIterateBasic(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand Down Expand Up @@ -256,7 +256,7 @@ func testDiffIterateTwoAtOnce(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
time.Sleep(8 * time.Millisecond)
calls = append(calls, diResult{offset: o, length: l})
return 0
Expand Down Expand Up @@ -326,7 +326,7 @@ func testDiffIterateEarlyExit(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
if o > 1 {
return -5
}
Expand Down Expand Up @@ -372,7 +372,7 @@ func testDiffIterateSnapshot(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand All @@ -389,7 +389,7 @@ func testDiffIterateSnapshot(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand All @@ -411,7 +411,7 @@ func testDiffIterateSnapshot(t *testing.T, ioctx *rados.IOContext) {
SnapName: "ss1",
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand All @@ -438,7 +438,7 @@ func testDiffIterateSnapshot(t *testing.T, ioctx *rados.IOContext) {
SnapName: "ss1",
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, _ interface{}) int {
calls = append(calls, diResult{offset: o, length: l})
return 0
},
Expand Down Expand Up @@ -481,7 +481,7 @@ func testDiffIterateCallbackData(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, x interface{}) int {
if v, ok := x.(int); ok {
assert.EqualValues(t, 77, v)
} else {
Expand All @@ -503,7 +503,7 @@ func testDiffIterateCallbackData(t *testing.T, ioctx *rados.IOContext) {
DiffIterateConfig{
Offset: 0,
Length: isize,
Callback: func(o, l uint64, e int, x interface{}) int {
Callback: func(o, l uint64, _ int, x interface{}) int {
if v, ok := x.(string); ok {
assert.EqualValues(t, "bob", v)
} else {
Expand Down
4 changes: 2 additions & 2 deletions rbd/group_snap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestGroupSnapshots(t *testing.T) {
assert.NoError(t, err)

cc := 0
cb := func(offset, total uint64, v interface{}) int {
cb := func(_, total uint64, v interface{}) int {
cc++
val := v.(int)
assert.Equal(t, 0, val)
Expand Down Expand Up @@ -234,7 +234,7 @@ func TestGroupSnapshots(t *testing.T) {
GroupSnapRollback(nil, gname, "foo")
})
assert.Panics(t, func() {
cb := func(o, t uint64, v interface{}) int { return 0 }
cb := func(_, _ uint64, _ interface{}) int { return 0 }
GroupSnapRollbackWithProgress(nil, gname, "foo", cb, nil)
})
})
Expand Down
2 changes: 1 addition & 1 deletion rbd/resize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestImageResize2(t *testing.T) {
cc := 0
cb := func(offset, total uint64, v interface{}) int {
cb := func(_, total uint64, v interface{}) int {
cc++
val := v.(int)
assert.Equal(t, 0, val)
Expand Down
6 changes: 3 additions & 3 deletions rbd/sparsify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestSparsifyWithProgress(t *testing.T) {
defer func() { assert.NoError(t, img.Close()) }()

cc := 0
cb := func(offset, total uint64, v interface{}) int {
cb := func(_, total uint64, v interface{}) int {
cc++
val := v.(int)
assert.Equal(t, 0, val)
Expand All @@ -53,7 +53,7 @@ func TestSparsifyWithProgress(t *testing.T) {
defer func() { assert.NoError(t, img.Close()) }()

cc := 0
cb := func(offset, total uint64, v interface{}) int {
cb := func(_, total uint64, v interface{}) int {
cc++
val := v.(int)
assert.Equal(t, 0, val)
Expand All @@ -71,7 +71,7 @@ func TestSparsifyWithProgress(t *testing.T) {
assert.NoError(t, img.Close())

cc := 0
cb := func(offset, total uint64, v interface{}) int {
cb := func(_, total uint64, v interface{}) int {
cc++
val := v.(int)
assert.Equal(t, 0, val)
Expand Down
6 changes: 3 additions & 3 deletions rbd/watchers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestWatch(t *testing.T) {
err = image.Close()
require.NoError(t, err)

_, err = image.UpdateWatch(func(d interface{}) {
_, err = image.UpdateWatch(func(_ interface{}) {
}, nil)
assert.Equal(t, ErrImageNotOpen, err)
})
Expand All @@ -158,7 +158,7 @@ func TestWatch(t *testing.T) {
}()

cc := 0
w, err := image.UpdateWatch(func(d interface{}) {
w, err := image.UpdateWatch(func(_ interface{}) {
cc++
}, nil)
assert.NoError(t, err)
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestWatchMultiChannels(t *testing.T) {
defer func() {
assert.NoError(t, img.Close())
}()
w, err := img.UpdateWatch(func(d interface{}) {
w, err := img.UpdateWatch(func(_ interface{}) {
mon <- n
}, nil)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions rgw/admin/bucket_quota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ func (suite *RadosGWTestSuite) TestBucketQuota() {
err = s3.createBucket(suite.bucketTestName)
assert.NoError(suite.T(), err)

suite.T().Run("set bucket quota but no user is specified", func(t *testing.T) {
suite.T().Run("set bucket quota but no user is specified", func(_ *testing.T) {
err := co.SetIndividualBucketQuota(context.Background(), QuotaSpec{})
assert.Error(suite.T(), err)
assert.EqualError(suite.T(), err, errMissingUserID.Error())
})

suite.T().Run("set bucket quota but no bucket is specified", func(t *testing.T) {
suite.T().Run("set bucket quota but no bucket is specified", func(_ *testing.T) {
err := co.SetIndividualBucketQuota(context.Background(), QuotaSpec{UID: "admin"})
assert.Error(suite.T(), err)
assert.EqualError(suite.T(), err, errMissingUserBucket.Error())
})

suite.T().Run("set bucket quota", func(t *testing.T) {
suite.T().Run("set bucket quota", func(_ *testing.T) {
err := co.SetIndividualBucketQuota(context.Background(), QuotaSpec{UID: "admin", Bucket: suite.bucketTestName, MaxSizeKb: &testBucketQuota})
assert.NoError(suite.T(), err)

Expand Down
16 changes: 8 additions & 8 deletions rgw/admin/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,46 @@ func (suite *RadosGWTestSuite) TestBucket() {
err = s3.createBucket(suite.bucketTestName)
assert.NoError(suite.T(), err)

suite.T().Run("list buckets", func(t *testing.T) {
suite.T().Run("list buckets", func(_ *testing.T) {
buckets, err := co.ListBuckets(context.Background())
assert.NoError(suite.T(), err)
assert.Equal(suite.T(), 1, len(buckets))
})

suite.T().Run("info non-existing bucket", func(t *testing.T) {
suite.T().Run("info non-existing bucket", func(_ *testing.T) {
_, err := co.GetBucketInfo(context.Background(), Bucket{Bucket: "foo"})
assert.Error(suite.T(), err)
assert.True(suite.T(), errors.Is(err, ErrNoSuchBucket), err)
})

suite.T().Run("info existing bucket", func(t *testing.T) {
suite.T().Run("info existing bucket", func(_ *testing.T) {
_, err := co.GetBucketInfo(context.Background(), Bucket{Bucket: suite.bucketTestName})
assert.NoError(suite.T(), err)
})

suite.T().Run("get policy non-existing bucket", func(t *testing.T) {
suite.T().Run("get policy non-existing bucket", func(_ *testing.T) {
_, err := co.GetBucketPolicy(context.Background(), Bucket{Bucket: "foo"})
assert.Error(suite.T(), err)
assert.True(suite.T(), errors.Is(err, ErrNoSuchKey), err)
})

suite.T().Run("get policy existing bucket", func(t *testing.T) {
suite.T().Run("get policy existing bucket", func(_ *testing.T) {
_, err := co.GetBucketPolicy(context.Background(), Bucket{Bucket: suite.bucketTestName})
assert.NoError(suite.T(), err)
})

suite.T().Run("remove bucket", func(t *testing.T) {
suite.T().Run("remove bucket", func(_ *testing.T) {
err := co.RemoveBucket(context.Background(), Bucket{Bucket: suite.bucketTestName})
assert.NoError(suite.T(), err)
})

suite.T().Run("list bucket is now zero", func(t *testing.T) {
suite.T().Run("list bucket is now zero", func(_ *testing.T) {
buckets, err := co.ListBuckets(context.Background())
assert.NoError(suite.T(), err)
assert.Equal(suite.T(), 0, len(buckets))
})

suite.T().Run("remove non-existing bucket", func(t *testing.T) {
suite.T().Run("remove non-existing bucket", func(_ *testing.T) {
err := co.RemoveBucket(context.Background(), Bucket{Bucket: "foo"})
assert.Error(suite.T(), err)
if util.CurrentCephVersion() <= util.CephOctopus {
Expand Down
Loading