diff --git a/.github/workflows/lint-go.yml b/.github/workflows/lint-go.yml index 24b7f1177..a6fc9e25d 100644 --- a/.github/workflows/lint-go.yml +++ b/.github/workflows/lint-go.yml @@ -40,4 +40,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.57 + version: v1.60.1 diff --git a/.golangci.yaml b/.golangci.yaml index 7d92e8014..eedac303c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -28,6 +28,7 @@ linters: - paralleltest - copyloopvar - perfsprint + - gomnd linters-settings: stylecheck: diff --git a/Makefile b/Makefile index 64f41aabe..ab3b51125 100644 --- a/Makefile +++ b/Makefile @@ -204,7 +204,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions KUSTOMIZE_VERSION ?= v5.0.0 CONTROLLER_TOOLS_VERSION ?= v0.16.1 -GOLANG_CI_LINT_VERSION ?= v1.57 +GOLANG_CI_LINT_VERSION ?= v1.60.1 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize diff --git a/hack/e2e/common/fixtures/fixtures.go b/hack/e2e/common/fixtures/fixtures.go index 9b156bd05..47d5815ce 100644 --- a/hack/e2e/common/fixtures/fixtures.go +++ b/hack/e2e/common/fixtures/fixtures.go @@ -1,4 +1,4 @@ -//nolint:gomnd // used in tests +//nolint:mnd // used in tests package fixtures import ( diff --git a/internal/controller/eventing/subscription/jetstream/reconciler.go b/internal/controller/eventing/subscription/jetstream/reconciler.go index 0aedf5645..98c84817c 100644 --- a/internal/controller/eventing/subscription/jetstream/reconciler.go +++ b/internal/controller/eventing/subscription/jetstream/reconciler.go @@ -239,7 +239,7 @@ func (r *Reconciler) enqueueReconciliationForSubscriptions(subs []eventingv1alph // handleSubscriptionDeletion deletes the JetStream subscription and removes its finalizer if it is set. func (r *Reconciler) handleSubscriptionDeletion(ctx context.Context, subscription *eventingv1alpha2.Subscription, log *zap.SugaredLogger, -) (kctrl.Result, error) { +) (kctrl.Result, error) { //nolint:unparam // used as needed. // delete the JetStream subscription/consumer if !utils.ContainsString(subscription.ObjectMeta.Finalizers, eventingv1alpha2.Finalizer) { return kctrl.Result{}, nil @@ -344,7 +344,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, oldSubscription, } // addFinalizer appends the eventing finalizer to the subscription and updates it in k8s. -func (r *Reconciler) addFinalizer(ctx context.Context, sub *eventingv1alpha2.Subscription) (kctrl.Result, error) { +func (r *Reconciler) addFinalizer(ctx context.Context, sub *eventingv1alpha2.Subscription) (kctrl.Result, error) { //nolint:unparam // used as needed. sub.ObjectMeta.Finalizers = append(sub.ObjectMeta.Finalizers, eventingv1alpha2.Finalizer) // update the subscription's finalizers in k8s diff --git a/internal/controller/operator/eventing/integrationtests/validation/integration_test.go b/internal/controller/operator/eventing/integrationtests/validation/integration_test.go index 84ce6ead6..f463037e9 100644 --- a/internal/controller/operator/eventing/integrationtests/validation/integration_test.go +++ b/internal/controller/operator/eventing/integrationtests/validation/integration_test.go @@ -54,8 +54,8 @@ const ( wrongSecret = "gibberish" publisher = "publisher" replicas = "replicas" - max = "max" - min = "min" + max = "max" //nolint:predeclared // used in tests + min = "min" //nolint:predeclared // used in tests resources = "resources" limits = "limits" requests = "requests" diff --git a/pkg/ems/api/events/client/client.go b/pkg/ems/api/events/client/client.go index 59966e83f..bf1444802 100644 --- a/pkg/ems/api/events/client/client.go +++ b/pkg/ems/api/events/client/client.go @@ -65,7 +65,7 @@ func (c Client) Publish(event cloudevents.Event, qos types.Qos) (*types.PublishR } // set required headers - req.Header.Set("qos", string(qos)) + req.Header.Set("qos", string(qos)) //nolint:canonicalheader // used as required. var response types.PublishResponse status, responseBody, err := c.client.Do(req, &response) diff --git a/pkg/eventing/utils.go b/pkg/eventing/utils.go index 2722c304a..9b929e2ed 100644 --- a/pkg/eventing/utils.go +++ b/pkg/eventing/utils.go @@ -42,7 +42,7 @@ func GetPublisherClusterRoleBindingName(eventing v1alpha1.Eventing) string { return fmt.Sprintf("%s-%s", eventing.GetName(), publisherProxySuffix) } -func newHorizontalPodAutoscaler(name, namespace string, min, max, cpuUtilization, memoryUtilization int32, +func newHorizontalPodAutoscaler(name, namespace string, minReplicas, maxReplicas, cpuUtilization, memoryUtilization int32, labels map[string]string, ) *kautoscalingv2.HorizontalPodAutoscaler { return &kautoscalingv2.HorizontalPodAutoscaler{ @@ -61,8 +61,8 @@ func newHorizontalPodAutoscaler(name, namespace string, min, max, cpuUtilization Name: name, APIVersion: "apps/v1", }, - MinReplicas: &min, - MaxReplicas: max, + MinReplicas: &minReplicas, + MaxReplicas: maxReplicas, Metrics: []kautoscalingv2.MetricSpec{ { Type: kautoscalingv2.ResourceMetricSourceType, diff --git a/pkg/tracing/tracing.go b/pkg/tracing/tracing.go index ef3cdc989..3e3db37ea 100644 --- a/pkg/tracing/tracing.go +++ b/pkg/tracing/tracing.go @@ -1,3 +1,4 @@ +//nolint:canonicalheader // used as required in tracing. package tracing import ( diff --git a/pkg/tracing/tracing_test.go b/pkg/tracing/tracing_test.go index a1bdcd2dc..2c3d60a2c 100644 --- a/pkg/tracing/tracing_test.go +++ b/pkg/tracing/tracing_test.go @@ -1,3 +1,4 @@ +//nolint:canonicalheader // used as required in tracing. package tracing import ( diff --git a/test/utils/utils.go b/test/utils/utils.go index cb2aa60de..b91cc6db8 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -1,4 +1,4 @@ -//nolint:gomnd // magic numbers here are used only in context of the function +//nolint:mnd // magic numbers here are used only in context of the function package utils import ( diff --git a/testing/test_helpers.go b/testing/test_helpers.go index 1f527eddb..a8ea74ef6 100644 --- a/testing/test_helpers.go +++ b/testing/test_helpers.go @@ -155,10 +155,10 @@ func GetStructuredMessageHeaders() http.Header { func GetBinaryMessageHeaders() http.Header { headers := make(http.Header) - headers.Add(CeIDHeader, EventID) - headers.Add(CeTypeHeader, CloudEventType) - headers.Add(CeSourceHeader, CloudEventSource) - headers.Add(CeSpecVersionHeader, CloudEventSpecVersion) + headers.Add(CeIDHeader, EventID) //nolint:canonicalheader // used in testing. + headers.Add(CeTypeHeader, CloudEventType) //nolint:canonicalheader // used in testing. + headers.Add(CeSourceHeader, CloudEventSource) //nolint:canonicalheader // used in testing. + headers.Add(CeSpecVersionHeader, CloudEventSpecVersion) //nolint:canonicalheader // used in testing. return headers } @@ -186,7 +186,7 @@ func NewAPIRule(subscription *eventingv1alpha2.Subscription, opts ...APIRuleOpti func WithService(name, host string) APIRuleOption { return func(r *apigatewayv1beta1.APIRule) { - port := uint32(443) //nolint:gomnd // tests + port := uint32(443) //nolint:mnd // tests isExternal := true r.Spec.Host = &host r.Spec.Service = &apigatewayv1beta1.Service{ @@ -531,9 +531,9 @@ func NewSubscriberSvc(name, namespace string) *kcorev1.Service { Ports: []kcorev1.ServicePort{ { Protocol: "TCP", - Port: 443, //nolint:gomnd // tests + Port: 443, //nolint:mnd // tests TargetPort: intstr.IntOrString{ - IntVal: 8080, //nolint:gomnd // tests + IntVal: 8080, //nolint:mnd // tests }, }, },