From 23bd8e325c31f87dd5028843b1dcf993c81af923 Mon Sep 17 00:00:00 2001 From: Martin Schneppenheim <23424570+weeco@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:05:53 +0000 Subject: [PATCH] lint: remove outdated linter and update gosec rule (#1499) --- backend/.golangci.yaml | 2 +- backend/pkg/api/connect/service/topic/v1alpha2/mapper.go | 2 +- backend/pkg/api/handle_brokers.go | 2 +- backend/pkg/connect/service.go | 2 +- backend/pkg/serde/protobuf_schema.go | 2 +- backend/pkg/serde/uint.go | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/.golangci.yaml b/backend/.golangci.yaml index 460db8b46..9050deba6 100644 --- a/backend/.golangci.yaml +++ b/backend/.golangci.yaml @@ -67,7 +67,6 @@ linters: - errname - errorlint - exhaustive - - exportloopref - gci - gocheckcompilerdirectives - gocognit @@ -112,6 +111,7 @@ linters-settings: gosec: excludes: - G104 # unhandled errors, we exclude for the same reason we do not use errcheck + - G115 # Go has no built-in solution to check the overflow # Complexity analysis: the recommendations are to be between 10-20, with a # default of 30 for gocyclo and gocognit, and a default of 10 for cyclop. We # will choose the middle of the range for cyclo analysis, which should be diff --git a/backend/pkg/api/connect/service/topic/v1alpha2/mapper.go b/backend/pkg/api/connect/service/topic/v1alpha2/mapper.go index 6fc8737c4..1075c8a69 100644 --- a/backend/pkg/api/connect/service/topic/v1alpha2/mapper.go +++ b/backend/pkg/api/connect/service/topic/v1alpha2/mapper.go @@ -61,7 +61,7 @@ func (*mapper) createTopicRequestTopicToKafka(topicReq *v1alpha2.CreateTopicRequ req := kmsg.NewCreateTopicsRequestTopic() req.Topic = topicReq.Name req.NumPartitions = partitionCount - req.ReplicationFactor = int16(replicationFactor) //nolint:gosec // conversion TODO we should change our API to match kafka + req.ReplicationFactor = int16(replicationFactor) // TODO we should change our API to match kafka req.ReplicaAssignment = replicaAssignments req.Configs = configs diff --git a/backend/pkg/api/handle_brokers.go b/backend/pkg/api/handle_brokers.go index e44aaef38..37c26d0af 100644 --- a/backend/pkg/api/handle_brokers.go +++ b/backend/pkg/api/handle_brokers.go @@ -67,7 +67,7 @@ func (api *API) handleBrokerConfig() http.HandlerFunc { return } - cfgs, restErr := api.ConsoleSvc.GetBrokerConfig(r.Context(), int32(brokerID)) //nolint:gosec // broker ID is parsed as 32 + cfgs, restErr := api.ConsoleSvc.GetBrokerConfig(r.Context(), int32(brokerID)) if restErr != nil { rest.SendRESTError(w, r, api.Logger, restErr) return diff --git a/backend/pkg/connect/service.go b/backend/pkg/connect/service.go index 3c2b6c79e..a062b5be3 100644 --- a/backend/pkg/connect/service.go +++ b/backend/pkg/connect/service.go @@ -133,5 +133,5 @@ func (s *Service) TestConnectivity(ctx context.Context) { wg.Wait() s.Logger.Info("tested Kafka connect cluster connectivity", zap.Uint32("successful_clusters", successfulChecks), - zap.Uint32("failed_clusters", uint32(len(s.ClientsByCluster))-successfulChecks)) //nolint:gosec // len conversion + zap.Uint32("failed_clusters", uint32(len(s.ClientsByCluster))-successfulChecks)) } diff --git a/backend/pkg/serde/protobuf_schema.go b/backend/pkg/serde/protobuf_schema.go index 9115b0030..78dd4cd17 100644 --- a/backend/pkg/serde/protobuf_schema.go +++ b/backend/pkg/serde/protobuf_schema.go @@ -111,7 +111,7 @@ func (d ProtobufSchemaSerde) DeserializePayload(_ context.Context, record *kgo.R return &RecordPayload{}, fmt.Errorf("failed to serialize protobuf payload into JSON: %w", err) } - sID := uint32(schemaID) //nolint:gosec // conversion + sID := uint32(schemaID) return &RecordPayload{ DeserializedPayload: native, diff --git a/backend/pkg/serde/uint.go b/backend/pkg/serde/uint.go index d2a46ee23..549092374 100644 --- a/backend/pkg/serde/uint.go +++ b/backend/pkg/serde/uint.go @@ -145,7 +145,7 @@ func convertStringToUint(v string, ss UintSize) ([]byte, error) { return nil, fmt.Errorf("failed to encode uint payload: %w", err) } buf := new(bytes.Buffer) - binary.Write(buf, binary.BigEndian, uint8(nv)) //nolint:gosec // parsed as 8 + binary.Write(buf, binary.BigEndian, uint8(nv)) byteData = buf.Bytes() case Uint16: nv, err := strconv.ParseUint(v, 10, 16) @@ -153,7 +153,7 @@ func convertStringToUint(v string, ss UintSize) ([]byte, error) { return nil, fmt.Errorf("failed to encode uint payload: %w", err) } buf := new(bytes.Buffer) - binary.Write(buf, binary.BigEndian, uint16(nv)) //nolint:gosec // parsed as 16 + binary.Write(buf, binary.BigEndian, uint16(nv)) byteData = buf.Bytes() case Uint32: nv, err := strconv.ParseUint(v, 10, 32) @@ -161,7 +161,7 @@ func convertStringToUint(v string, ss UintSize) ([]byte, error) { return nil, fmt.Errorf("failed to encode uint payload: %w", err) } buf := new(bytes.Buffer) - binary.Write(buf, binary.BigEndian, uint32(nv)) //nolint:gosec // parsed as 32 + binary.Write(buf, binary.BigEndian, uint32(nv)) byteData = buf.Bytes() default: nv, err := strconv.ParseUint(v, 10, 64)