Skip to content

Commit

Permalink
Merge pull request #4512 from Affan-7/lint-unused-param
Browse files Browse the repository at this point in the history
Add linting for unused parameters
  • Loading branch information
karmada-bot authored Jan 14, 2024
2 parents be5b5a8 + 970435c commit e7192a9
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ linters-settings:
- name: unreachable-code
- name: var-naming
- name: redefines-builtin-id
- name: unused-parameter
staticcheck:
checks:
- all
Expand Down
2 changes: 1 addition & 1 deletion operator/pkg/controlplane/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func EnsureKarmadaAggregatedAPIServer(client clientset.Interface, cfg *operatorv
return createKarmadaAggregatedAPIServerService(client, name, namespace)
}

func installKarmadaAPIServer(client clientset.Interface, cfg *operatorv1alpha1.KarmadaAPIServer, name, namespace string, featureGates map[string]bool) error {
func installKarmadaAPIServer(client clientset.Interface, cfg *operatorv1alpha1.KarmadaAPIServer, name, namespace string, _ map[string]bool) error {
apiserverDeploymentBytes, err := util.ParseTemplate(KarmadaApiserverDeployment, struct {
DeploymentName, Namespace, Image, EtcdClientService string
ServiceSubnet, KarmadaCertsSecret, EtcdCertsSecret string
Expand Down
2 changes: 1 addition & 1 deletion operator/pkg/controlplane/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func EnsureKarmadaSearch(client clientset.Interface, cfg *operatorv1alpha1.Karma
return createKarmadaSearchService(client, name, namespace)
}

func installKarmadaSearch(client clientset.Interface, cfg *operatorv1alpha1.KarmadaSearch, name, namespace string, featureGates map[string]bool) error {
func installKarmadaSearch(client clientset.Interface, cfg *operatorv1alpha1.KarmadaSearch, name, namespace string, _ map[string]bool) error {
searchDeploymentSetBytes, err := util.ParseTemplate(KarmadaSearchDeployment, struct {
DeploymentName, Namespace, Image, KarmadaCertsSecret string
KubeconfigSecret, EtcdClientService string
Expand Down
2 changes: 1 addition & 1 deletion operator/pkg/controlplane/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func EnsureKarmadaWebhook(client clientset.Interface, cfg *operatorv1alpha1.Karm
return createKarmadaWebhookService(client, name, namespace)
}

func installKarmadaWebhook(client clientset.Interface, cfg *operatorv1alpha1.KarmadaWebhook, name, namespace string, featureGates map[string]bool) error {
func installKarmadaWebhook(client clientset.Interface, cfg *operatorv1alpha1.KarmadaWebhook, name, namespace string, _ map[string]bool) error {
webhookDeploymentSetBytes, err := util.ParseTemplate(KarmadaWebhookDeployment, struct {
DeploymentName, Namespace, Image string
KubeconfigSecret, WebhookCertsSecret string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *HPAReplicasSyncer) Delete(e event.DeleteEvent) bool {
}

// Generic implements default GenericEvent filter
func (r *HPAReplicasSyncer) Generic(e event.GenericEvent) bool {
func (r *HPAReplicasSyncer) Generic(_ event.GenericEvent) bool {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (c *EndpointSliceCollectController) Reconcile(ctx context.Context, req cont
return controllerruntime.Result{Requeue: true}, err
}

if err = c.buildResourceInformers(ctx, work, clusterName); err != nil {
if err = c.buildResourceInformers(clusterName); err != nil {
return controllerruntime.Result{Requeue: true}, err
}

Expand Down Expand Up @@ -147,7 +147,7 @@ func (c *EndpointSliceCollectController) collectEndpointSlice(key util.QueueKey)
return nil
}

func (c *EndpointSliceCollectController) buildResourceInformers(ctx context.Context, work *workv1alpha1.Work, clusterName string) error {
func (c *EndpointSliceCollectController) buildResourceInformers(clusterName string) error {
cluster, err := util.GetCluster(c.Client, clusterName)
if err != nil {
klog.Errorf("Failed to get the given member cluster %s", clusterName)
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/status/cluster_status_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ func TestClusterStatusController_updateStatusIfNeeded(t *testing.T) {
})
}

func NewClusterDynamicClientSetForAgentWithError(clusterName string, client client.Client) (*util.DynamicClusterClient, error) {
func NewClusterDynamicClientSetForAgentWithError(_ string, _ client.Client) (*util.DynamicClusterClient, error) {
return nil, fmt.Errorf("err")
}

Expand Down Expand Up @@ -1029,7 +1029,7 @@ func TestClusterStatusController_initializeGenericInformerManagerForCluster(t *t
})
}

func TestClusterStatusController_initLeaseController(t *testing.T) {
func TestClusterStatusController_initLeaseController(_ *testing.T) {
c := &ClusterStatusController{
Client: fake.NewClientBuilder().WithScheme(gclient.NewSchema()).Build(),
GenericInformerManager: genericmanager.GetInstance(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/status/work_status_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func TestWorkStatusController_getEventHandler(t *testing.T) {
assert.NotEmpty(t, eventHandler)
}

func TestWorkStatusController_RunWorkQueue(t *testing.T) {
func TestWorkStatusController_RunWorkQueue(_ *testing.T) {
c := WorkStatusController{
Client: fake.NewClientBuilder().WithScheme(gclient.NewSchema()).WithObjects(newCluster("cluster", clusterv1alpha1.ClusterConditionReady, metav1.ConditionFalse)).Build(),
InformerManager: genericmanager.GetInstance(),
Expand Down
4 changes: 2 additions & 2 deletions pkg/karmadactl/promote/promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func (o *CommandPromoteOption) promote(controlPlaneRestConfig *rest.Config, obj
}

if o.AutoCreatePolicy {
err = o.createClusterPropagationPolicy(karmadaClient, obj, gvr, isDep)
err = o.createClusterPropagationPolicy(karmadaClient, gvr, isDep)
if err != nil {
return err
}
Expand Down Expand Up @@ -681,7 +681,7 @@ func (o *CommandPromoteOption) createPropagationPolicy(karmadaClient *karmadacli
}

// createClusterPropagationPolicy create ClusterPropagationPolicy in karmada control plane
func (o *CommandPromoteOption) createClusterPropagationPolicy(karmadaClient *karmadaclientset.Clientset, obj *unstructured.Unstructured, gvr schema.GroupVersionResource, isDep bool) error {
func (o *CommandPromoteOption) createClusterPropagationPolicy(karmadaClient *karmadaclientset.Clientset, gvr schema.GroupVersionResource, isDep bool) error {
var policyName string
if o.PolicyName == "" {
policyName = names.GeneratePolicyName("", o.name, o.gvk.String())
Expand Down
2 changes: 1 addition & 1 deletion pkg/metricsadapter/provider/externalmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func MakeExternalMetricsProvider() *ExternalMetricsProvider {
}

// GetExternalMetric will query metrics by selector from member clusters and return the result
func (c *ExternalMetricsProvider) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error) {
func (c *ExternalMetricsProvider) GetExternalMetric(_ context.Context, _ string, _ labels.Selector, _ provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error) {
return nil, fmt.Errorf("karmada-metrics-adapter still not implement it")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/multiclusterservice/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ admission.Handler = &ValidatingAdmission{}

// Handle implements admission.Handler interface.
// It yields a response to an AdmissionRequest.
func (v *ValidatingAdmission) Handle(ctx context.Context, req admission.Request) admission.Response {
func (v *ValidatingAdmission) Handle(_ context.Context, req admission.Request) admission.Response {
mcs := &networkingv1alpha1.MultiClusterService{}
err := v.Decoder.Decode(req, mcs)
if err != nil {
Expand Down

0 comments on commit e7192a9

Please sign in to comment.