From daf93fea7b68f9a79b3345ffcd5e9a1a0d49ab63 Mon Sep 17 00:00:00 2001 From: Elena Gershkovich Date: Mon, 11 Dec 2023 17:54:23 +0530 Subject: [PATCH] Enable unused-parameter revive flag Signed-off-by: Elena Gershkovich --- .golangci.yaml | 2 +- controllers/drcluster_controller_test.go | 6 ++--- .../drplacementcontrol_controller_test.go | 22 +++++++++---------- controllers/kubeobjects/requests.go | 2 +- controllers/s3utils.go | 2 +- controllers/s3utils_test.go | 2 +- controllers/util/mcv_util.go | 6 ++--- controllers/util/predicates.go | 6 ++--- controllers/vrg_kubeobjects.go | 6 ++--- controllers/vrg_volrep.go | 2 +- controllers/vrg_volrep_test.go | 6 ++--- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index e1dc8503e9..12f0e8fd9c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -73,7 +73,7 @@ linters-settings: - name: unhandled-error # - name: flag-parameter # - name: unused-receiver - # - name: unused-parameter + - name: unused-parameter # - name: confusing-naming # - name: import-shadowing # - name: confusing-results diff --git a/controllers/drcluster_controller_test.go b/controllers/drcluster_controller_test.go index fd27a1b5d0..57885f0678 100644 --- a/controllers/drcluster_controller_test.go +++ b/controllers/drcluster_controller_test.go @@ -32,8 +32,8 @@ var baseNF = &csiaddonsv1alpha1.NetworkFence{ }, } -func (f FakeMCVGetter) GetNFFromManagedCluster(resourceName, resourceNamespace, managedCluster string, - annotations map[string]string, +func (f FakeMCVGetter) GetNFFromManagedCluster(_, _, _ string, + _ map[string]string, ) (*csiaddonsv1alpha1.NetworkFence, error) { nfStatus := csiaddonsv1alpha1.NetworkFenceStatus{ Result: csiaddonsv1alpha1.FencingOperationResultSucceeded, @@ -57,7 +57,7 @@ func (f FakeMCVGetter) GetNFFromManagedCluster(resourceName, resourceNamespace, } func (f FakeMCVGetter) DeleteNFManagedClusterView( - resourceName, resourceNamespace, clusterName, resourceType string, + _, _, _, _ string, ) error { return nil } diff --git a/controllers/drplacementcontrol_controller_test.go b/controllers/drplacementcontrol_controller_test.go index 7d16cc4332..bc32e9f758 100644 --- a/controllers/drplacementcontrol_controller_test.go +++ b/controllers/drplacementcontrol_controller_test.go @@ -191,7 +191,7 @@ func getSyncDRPolicy() *rmn.DRPolicy { var drstate string // FakeProgressCallback of function type -func FakeProgressCallback(drpcName string, state string) { +func FakeProgressCallback(_ string, state string) { drstate = state } @@ -220,7 +220,7 @@ func getFunctionNameAtIndex(idx int) string { // a nil mcv back in case of success func (f FakeMCVGetter) GetMModeFromManagedCluster( resourceName, managedCluster string, - annotations map[string]string, + _ map[string]string, ) (*rmn.MaintenanceMode, error) { mModeMCV := &viewv1beta1.ManagedClusterView{} @@ -321,7 +321,7 @@ func (f FakeMCVGetter) GetResource(mcv *viewv1beta1.ManagedClusterView, resource // DeleteManagedClusterView: This fake function would eventually delete the MMode MCV that is created // by the call to GetMModeFromManagedCluster. It is generic enough to delete any MCV that was created as well // TODO: Implementation is mostly the same as the one in ManagedClusterViewGetterImpl -func (f FakeMCVGetter) DeleteManagedClusterView(clusterName, mcvName string, logger logr.Logger) error { +func (f FakeMCVGetter) DeleteManagedClusterView(clusterName, mcvName string, _ logr.Logger) error { mcv := &viewv1beta1.ManagedClusterView{} err := f.Get(context.TODO(), types.NamespacedName{Name: mcvName, Namespace: clusterName}, mcv) @@ -337,7 +337,7 @@ func (f FakeMCVGetter) DeleteManagedClusterView(clusterName, mcvName string, log } func (f FakeMCVGetter) GetNamespaceFromManagedCluster( - resourceName, managedCluster, namespaceString string, annotations map[string]string, + resourceName, managedCluster, namespaceString string, _ map[string]string, ) (*corev1.Namespace, error) { appNamespaceObj := &corev1.Namespace{} @@ -381,8 +381,8 @@ func isRestorePVsComplete() bool { } //nolint:funlen,cyclop,gocognit -func (f FakeMCVGetter) GetVRGFromManagedCluster(resourceName, resourceNamespace, managedCluster string, - annnotations map[string]string, +func (f FakeMCVGetter) GetVRGFromManagedCluster(_, _, managedCluster string, + _ map[string]string, ) (*rmn.VolumeReplicationGroup, error) { conType := controllers.VRGConditionTypeDataReady reason := controllers.VRGConditionReasonReplicating @@ -487,13 +487,13 @@ func (f FakeMCVGetter) GetVRGFromManagedCluster(resourceName, resourceNamespace, } func (f FakeMCVGetter) DeleteVRGManagedClusterView( - resourceName, resourceNamespace, clusterName, resourceType string, + _, _, _, _ string, ) error { return nil } func (f FakeMCVGetter) DeleteNamespaceManagedClusterView( - resourceName, resourceNamespace, clusterName, resourceType string, + _, _, _, _ string, ) error { return nil } @@ -1125,7 +1125,7 @@ const ( UsePlacementWithAppSet = 3 ) -func InitialDeploymentAsync(namespace, placementName, homeCluster string, plType PlacementType) ( +func InitialDeploymentAsync(namespace, placementName, _ string, plType PlacementType) ( client.Object, *rmn.DRPlacementControl, ) { createNamespacesAsync(getNamespaceObj(DRPCNamespaceName)) @@ -1152,7 +1152,7 @@ func InitialDeploymentAsync(namespace, placementName, homeCluster string, plType return placementObj, createDRPC(placementName, DRPCName, DRPCNamespaceName, AsyncDRPolicyName) } -func FollowOnDeploymentAsync(namespace, placementName, homeCluster string) (*plrv1.PlacementRule, +func FollowOnDeploymentAsync(namespace, placementName, _ string) (*plrv1.PlacementRule, *rmn.DRPlacementControl, ) { createNamespace(appNamespace2) @@ -1620,7 +1620,7 @@ func createNamespacesSync() { createNamespace(appNamespace) } -func InitialDeploymentSync(namespace, placementName, homeCluster string) (*plrv1.PlacementRule, +func InitialDeploymentSync(namespace, placementName, _ string) (*plrv1.PlacementRule, *rmn.DRPlacementControl, ) { createNamespacesSync() diff --git a/controllers/kubeobjects/requests.go b/controllers/kubeobjects/requests.go index 4df02d8465..6e312be9fb 100644 --- a/controllers/kubeobjects/requests.go +++ b/controllers/kubeobjects/requests.go @@ -107,7 +107,7 @@ type HookSpec struct { func RequestProcessingErrorCreate(s string) RequestProcessingError { return RequestProcessingError{s} } func (e RequestProcessingError) Error() string { return e.string } -func (RequestProcessingError) Is(err error) bool { return true } +func (RequestProcessingError) Is(_ error) bool { return true } type RequestsManager interface { ProtectsPath() string diff --git a/controllers/s3utils.go b/controllers/s3utils.go index 389c150861..7d9075dd9b 100644 --- a/controllers/s3utils.go +++ b/controllers/s3utils.go @@ -114,7 +114,7 @@ type s3ObjectStoreGetter struct{} // secret is not configured, or if client session creation fails. func (s3ObjectStoreGetter) ObjectStore(ctx context.Context, r client.Reader, s3ProfileName string, - callerTag string, log logr.Logger, + callerTag string, _ logr.Logger, ) (ObjectStorer, ramen.S3StoreProfile, error) { s3StoreProfile, err := GetRamenConfigS3StoreProfile(ctx, r, s3ProfileName) if err != nil { diff --git a/controllers/s3utils_test.go b/controllers/s3utils_test.go index 26390964a6..c4c8595d7e 100644 --- a/controllers/s3utils_test.go +++ b/controllers/s3utils_test.go @@ -41,7 +41,7 @@ func (fakeObjectStoreGetter) ObjectStore( apiReader client.Reader, s3ProfileName string, callerTag string, - log logr.Logger, + _ logr.Logger, ) (controllers.ObjectStorer, ramen.S3StoreProfile, error) { s3StoreProfile, err := controllers.GetRamenConfigS3StoreProfile(ctx, apiReader, s3ProfileName) if err != nil { diff --git a/controllers/util/mcv_util.go b/controllers/util/mcv_util.go index f48ff54071..487f40f81f 100644 --- a/controllers/util/mcv_util.go +++ b/controllers/util/mcv_util.go @@ -344,7 +344,7 @@ func (m ManagedClusterViewGetterImpl) getOrCreateManagedClusterView( } func (m ManagedClusterViewGetterImpl) DeleteVRGManagedClusterView( - resourceName, resourceNamespace, clusterName, resourceType string, + resourceName, resourceNamespace, clusterName, _ string, ) error { logger := ctrl.Log.WithName("MCV").WithValues("resouceName", resourceName) mcvNameVRG := BuildManagedClusterViewName(resourceName, resourceNamespace, MWTypeVRG) @@ -353,7 +353,7 @@ func (m ManagedClusterViewGetterImpl) DeleteVRGManagedClusterView( } func (m ManagedClusterViewGetterImpl) DeleteNamespaceManagedClusterView( - resourceName, resourceNamespace, clusterName, resourceType string, + resourceName, resourceNamespace, clusterName, _ string, ) error { logger := ctrl.Log.WithName("MCV").WithValues("resouceName", resourceName) mcvNameNS := BuildManagedClusterViewName(resourceName, resourceNamespace, MWTypeNS) @@ -362,7 +362,7 @@ func (m ManagedClusterViewGetterImpl) DeleteNamespaceManagedClusterView( } func (m ManagedClusterViewGetterImpl) DeleteNFManagedClusterView( - resourceName, resourceNamespace, clusterName, resourceType string, + resourceName, resourceNamespace, clusterName, _ string, ) error { logger := ctrl.Log.WithName("MCV").WithValues("resouceName", resourceName) mcvNameNF := BuildManagedClusterViewName(resourceName, resourceNamespace, MWTypeNF) diff --git a/controllers/util/predicates.go b/controllers/util/predicates.go index 87b9c1d961..6d64d13c96 100644 --- a/controllers/util/predicates.go +++ b/controllers/util/predicates.go @@ -10,11 +10,11 @@ import ( type CreateOrDeleteOrResourceVersionUpdatePredicate struct{} -func (CreateOrDeleteOrResourceVersionUpdatePredicate) Create(e event.CreateEvent) bool { +func (CreateOrDeleteOrResourceVersionUpdatePredicate) Create(_ event.CreateEvent) bool { return true } -func (CreateOrDeleteOrResourceVersionUpdatePredicate) Delete(e event.DeleteEvent) bool { +func (CreateOrDeleteOrResourceVersionUpdatePredicate) Delete(_ event.DeleteEvent) bool { return true } @@ -22,7 +22,7 @@ func (CreateOrDeleteOrResourceVersionUpdatePredicate) Update(e event.UpdateEvent return predicate.ResourceVersionChangedPredicate{}.Update(e) } -func (CreateOrDeleteOrResourceVersionUpdatePredicate) Generic(e event.GenericEvent) bool { +func (CreateOrDeleteOrResourceVersionUpdatePredicate) Generic(_ event.GenericEvent) bool { return false } diff --git a/controllers/vrg_kubeobjects.go b/controllers/vrg_kubeobjects.go index ef748a3afd..15a57dbf1e 100644 --- a/controllers/vrg_kubeobjects.go +++ b/controllers/vrg_kubeobjects.go @@ -168,8 +168,8 @@ func (v *VRGInstance) kubeObjectsCaptureStartOrResumeOrDelay( } func kubeObjectsCaptureStartConditionallySecondary( - v *VRGInstance, result *ctrl.Result, - captureStartGeneration int64, captureStartTimeSince, captureStartInterval time.Duration, + v *VRGInstance, _ *ctrl.Result, + captureStartGeneration int64, _, _ time.Duration, captureStart func(), ) { generation := v.instance.Generation @@ -187,7 +187,7 @@ func kubeObjectsCaptureStartConditionallySecondary( func kubeObjectsCaptureStartConditionallyPrimary( v *VRGInstance, result *ctrl.Result, - captureStartGeneration int64, captureStartTimeSince, captureStartInterval time.Duration, + _ int64, captureStartTimeSince, captureStartInterval time.Duration, captureStart func(), ) { if delay := captureStartInterval - captureStartTimeSince; delay > 0 { diff --git a/controllers/vrg_volrep.go b/controllers/vrg_volrep.go index 2d642e8f8e..a3101fd615 100644 --- a/controllers/vrg_volrep.go +++ b/controllers/vrg_volrep.go @@ -661,7 +661,7 @@ func (v *VRGInstance) UploadPVAndPVCtoS3(s3ProfileName string, objectStore Objec } func (v *VRGInstance) UploadPVandPVCtoS3Stores(pvc *corev1.PersistentVolumeClaim, - log logr.Logger, + _ logr.Logger, ) ([]string, error) { succeededProfiles := []string{} // Upload the PV to all the S3 profiles in the VRG spec diff --git a/controllers/vrg_volrep_test.go b/controllers/vrg_volrep_test.go index 53d1cfbed3..51f7714b6f 100644 --- a/controllers/vrg_volrep_test.go +++ b/controllers/vrg_volrep_test.go @@ -1788,14 +1788,14 @@ func pvcUnprotectedVerify( type pvcPreDeleteVerify func(ramendrv1alpha1.VolumeReplicationGroup, types.NamespacedName, string) func vrgPvcStatusAbsentVerify( - vrg ramendrv1alpha1.VolumeReplicationGroup, pvcNamespacedName types.NamespacedName, pvName string, + vrg ramendrv1alpha1.VolumeReplicationGroup, pvcNamespacedName types.NamespacedName, _ string, ) { By("not storing PVC in VRG's status") Expect(vrgController.FindProtectedPVC(&vrg, pvcNamespacedName.Namespace, pvcNamespacedName.Name)).To(BeNil()) } func pvcClusterDataProtectedFalseVerify( - vrg ramendrv1alpha1.VolumeReplicationGroup, pvcNamespacedName types.NamespacedName, pvName string, + vrg ramendrv1alpha1.VolumeReplicationGroup, pvcNamespacedName types.NamespacedName, _ string, ) { vrgPvcStatus := vrgPvcStatusGet(vrg, pvcNamespacedName) @@ -1835,7 +1835,7 @@ func pvcClusterDataProtectedStatusVerify( type pvcPostDeleteVerify func(types.NamespacedName, string) -func vrAndPvcDeletionTimestampsRecentVerify(pvcNamespacedName types.NamespacedName, pvName string) { +func vrAndPvcDeletionTimestampsRecentVerify(pvcNamespacedName types.NamespacedName, _ string) { vrDeletionTimestampRecentVerify(pvcNamespacedName) pvcDeletionTimestampRecentVerify(pvcNamespacedName) }