Skip to content

Commit 37735b7

Browse files
Anand Kumarclaude
andcommitted
Fix remaining unused test parameters
- Rename unused 'ns', 'r', and 'ctx' parameters to underscore in test files - Add nolint directives for additional package naming issues in constants.go and apidiscovery_test.go Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 3851819 commit 37735b7

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

pkg/controller/common/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:revive // common is an established package name in this codebase
12
package common
23

34
const (

pkg/controller/istiocsr/certificates_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ func TestCreateOrApplyCertificates(t *testing.T) {
2323
{
2424
name: "reconciliation of certificate fails while checking if exists",
2525
preReq: func(_ *Reconciler, m *fakes.FakeCtrlClient) {
26-
m.GetCalls(func(_ context.Context, ns types.NamespacedName, obj client.Object) error {
26+
m.GetCalls(func(_ context.Context, _ types.NamespacedName, obj client.Object) error {
2727
switch o := obj.(type) {
2828
case *v1alpha1.IstioCSR:
2929
istiocsr := testIstioCSR()
3030
istiocsr.DeepCopyInto(o)
3131
}
3232
return nil
3333
})
34-
m.ExistsCalls(func(_ context.Context, ns types.NamespacedName, obj client.Object) (bool, error) {
34+
m.ExistsCalls(func(_ context.Context, _ types.NamespacedName, obj client.Object) (bool, error) {
3535
switch obj.(type) {
3636
case *certmanagerv1.Certificate:
3737
return false, errTestClient
@@ -44,7 +44,7 @@ func TestCreateOrApplyCertificates(t *testing.T) {
4444
{
4545
name: "reconciliation of certificate fails while restoring to expected state",
4646
preReq: func(_ *Reconciler, m *fakes.FakeCtrlClient) {
47-
m.GetCalls(func(_ context.Context, ns types.NamespacedName, obj client.Object) error {
47+
m.GetCalls(func(_ context.Context, _ types.NamespacedName, obj client.Object) error {
4848
switch o := obj.(type) {
4949
case *v1alpha1.IstioCSR:
5050
istiocsr := testIstioCSR()

pkg/controller/trustmanager/serviceaccounts_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ func TestServiceAccountReconciliation(t *testing.T) {
8181
}{
8282
{
8383
name: "successful apply when not found",
84-
preReq: func(r *Reconciler, m *fakes.FakeCtrlClient) {
85-
m.ExistsCalls(func(ctx context.Context, key client.ObjectKey, obj client.Object) (bool, error) {
84+
preReq: func(_ *Reconciler, m *fakes.FakeCtrlClient) {
85+
m.ExistsCalls(func(_ context.Context, key client.ObjectKey, obj client.Object) (bool, error) {
8686
return false, nil
8787
})
8888
},
@@ -92,7 +92,7 @@ func TestServiceAccountReconciliation(t *testing.T) {
9292
{
9393
name: "skip apply when existing matches desired",
9494
preReq: func(r *Reconciler, m *fakes.FakeCtrlClient) {
95-
m.ExistsCalls(func(ctx context.Context, key client.ObjectKey, obj client.Object) (bool, error) {
95+
m.ExistsCalls(func(_ context.Context, key client.ObjectKey, obj client.Object) (bool, error) {
9696
sa := r.getServiceAccountObject(testResourceLabels(), testResourceAnnotations())
9797
sa.DeepCopyInto(obj.(*corev1.ServiceAccount))
9898
return true, nil
@@ -104,7 +104,7 @@ func TestServiceAccountReconciliation(t *testing.T) {
104104
{
105105
name: "apply when existing has label drift",
106106
preReq: func(r *Reconciler, m *fakes.FakeCtrlClient) {
107-
m.ExistsCalls(func(ctx context.Context, key client.ObjectKey, obj client.Object) (bool, error) {
107+
m.ExistsCalls(func(_ context.Context, key client.ObjectKey, obj client.Object) (bool, error) {
108108
sa := r.getServiceAccountObject(testResourceLabels(), testResourceAnnotations())
109109
sa.Labels["app.kubernetes.io/instance"] = "modified-value"
110110
sa.DeepCopyInto(obj.(*corev1.ServiceAccount))
@@ -144,7 +144,7 @@ func TestServiceAccountReconciliation(t *testing.T) {
144144
},
145145
{
146146
name: "exists error propagates",
147-
preReq: func(r *Reconciler, m *fakes.FakeCtrlClient) {
147+
preReq: func(_ *Reconciler, m *fakes.FakeCtrlClient) {
148148
m.ExistsCalls(func(ctx context.Context, key client.ObjectKey, obj client.Object) (bool, error) {
149149
return false, errTestClient
150150
})
@@ -155,7 +155,7 @@ func TestServiceAccountReconciliation(t *testing.T) {
155155
},
156156
{
157157
name: "patch error propagates",
158-
preReq: func(r *Reconciler, m *fakes.FakeCtrlClient) {
158+
preReq: func(_ *Reconciler, m *fakes.FakeCtrlClient) {
159159
m.ExistsCalls(func(ctx context.Context, key client.ObjectKey, obj client.Object) (bool, error) {
160160
return false, nil
161161
})

pkg/operator/utils/apidiscovery_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:revive // utils is an established package name in this codebase
12
package utils
23

34
import (

0 commit comments

Comments
 (0)