From 140e020efc6fec77a540221e70d1b1651c649070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Catt=C4=AB=20Cr=C5=ABd=C4=93l=C4=93s?= <17695588+wzy9607@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:04:30 +0800 Subject: [PATCH] chore: lint (#49) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cattī Crūdēlēs <17695588+wzy9607@users.noreply.github.com> --- .golangci.yml | 34 ++++++++++++++++++---------------- channel.go | 1 + 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 46c1acf..ee1e038 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,9 +1,9 @@ run: timeout: 10m - show-stats: true output: sort-results: true + show-stats: true linters-settings: cyclop: @@ -24,13 +24,18 @@ linters-settings: - switch - map default-signifies-exhaustive: true + funlen: + lines: 100 + statements: 80 gci: sections: - standard - default - prefix(github.com/rabbitmq/amqp091-go) - - prefix(github.com/wzy9607/amqp091otel) + - localmodule custom-order: true + gocognit: + min-complexity: 20 gocritic: enabled-tags: - diagnostic @@ -40,11 +45,12 @@ linters-settings: - opinionated disabled-checks: - dupImport # https://github.com/go-critic/go-critic/issues/845 + - emptyStringTest - hugeParam - ifElseChain - ruleguard - sloppyReassign - - whyNoLint + - whyNoLint # nolintlint is better settings: captLocal: paramsOnly: false @@ -57,7 +63,13 @@ linters-settings: replacement: "any" - pattern: "a[b:len(a)]" replacement: "a[b:]" - gomnd: + govet: + enable-all: true + disable: + - fieldalignment + grouper: + import-require-single-import: true + mnd: checks: - argument - case @@ -65,13 +77,6 @@ linters-settings: - return ignored-functions: - strings.SplitN - govet: - check-shadowing: true - enable-all: true - disable: - - fieldalignment - grouper: - import-require-single-import: true nakedret: max-func-lines: 50 nolintlint: @@ -119,11 +124,9 @@ linters-settings: time-layout: true crypto-hash: true default-rpc-path: true - os-dev-null: true sql-isolation-level: true tls-signature-scheme: true constant-kind: true - syslog-priority: true varnamelen: max-distance: 10 @@ -154,7 +157,6 @@ linters: - gocritic - gofmt - gofumpt - - gomnd - gomoddirectives - gosec - gosimple @@ -168,6 +170,7 @@ linters: - makezero - mirror - misspell + - mnd - musttag - nakedret - nestif @@ -198,7 +201,6 @@ linters: - wastedassign - whitespace - issues: include: - EXC0003 @@ -214,7 +216,7 @@ issues: - exhaustruct - forcetypeassert - funlen - - gomnd + - mnd - nakedret - spancheck - varnamelen diff --git a/channel.go b/channel.go index 4006b53..dd9f61a 100644 --- a/channel.go +++ b/channel.go @@ -104,6 +104,7 @@ func (ch *Channel) startConsumerSpan(msg *amqp091.Delivery, queue string, operat attrs = append(attrs, semconv.MessagingMessageID(msg.MessageId)) } if msg.DeliveryTag != 0 { + //nolint:gosec // overflow here is relatively safe and unlikely to happen attrs = append(attrs, semconv.MessagingRabbitmqMessageDeliveryTag(int(msg.DeliveryTag))) } attrs = append(attrs, ch.commonAttrs()...)