Skip to content

Commit

Permalink
lint: remove outdated linter and update gosec rule (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
weeco authored Nov 6, 2024
1 parent 0a68f5c commit 23bd8e3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
- gci
- gocheckcompilerdirectives
- gocognit
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/api/connect/service/topic/v1alpha2/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/api/handle_brokers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/connect/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
2 changes: 1 addition & 1 deletion backend/pkg/serde/protobuf_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions backend/pkg/serde/uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,23 @@ 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)
if err != nil {
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)
if err != nil {
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)
Expand Down

0 comments on commit 23bd8e3

Please sign in to comment.