From e63537be719802ccd95bcb9cdf8dd9355997c1ce Mon Sep 17 00:00:00 2001 From: Ping Yu Date: Mon, 4 Dec 2023 11:03:42 +0800 Subject: [PATCH] [to #371] chore: Upgrade golangci-lint to v1.55.2 (#373) * upgrade golangci v1.55.2 Signed-off-by: Ping Yu * fix lint error Signed-off-by: Ping Yu --------- Signed-off-by: Ping Yu --- .golangci.yml | 18 +++++++++--------- br/Makefile | 2 +- br/pkg/backup/client.go | 4 +++- br/pkg/backup/client_test.go | 2 +- br/pkg/storage/s3_test.go | 2 +- cdc/Makefile | 2 +- cdc/cdc/model/kv.go | 3 +-- cdc/pkg/fsutil/filelock.go | 3 +-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 752c9af3..845afc01 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -49,15 +49,15 @@ linters-settings: - name: unreachable-code depguard: - list-type: blacklist - include-go-root: false - packages: - - log - - github.com/juju/errors - packages-with-error-message: - # specify an error message to output when a blacklisted package is used - - log: "logging is allowed only by pingcap/log" - - github.com/juju/errors: "error handling is allowed only by pingcap/errors" + rules: + main: + list-mode: lax # everything is allowed unless it is denied. + deny: + - pkg: "log" + desc: logging is allowed only by pingcap/log + - pkg: "github.com/juju/errors" + desc: error handling is allowed only by pingcap/errors + staticcheck: checks: ["S1002","S1004","S1007","S1009","S1010","S1012","S1019","S1020","S1021","S1024","S1030","SA2*","SA3*","SA4009","SA5*","SA6000","SA6001","SA6005", "-SA2002"] stylecheck: diff --git a/br/Makefile b/br/Makefile index 66f3d1d8..452fab89 100644 --- a/br/Makefile +++ b/br/Makefile @@ -86,7 +86,7 @@ failpoint/disable: tools/bin/failpoint-ctl find `pwd` -type d | grep -vE "(\.git|tools)" | xargs tools/bin/failpoint-ctl disable tools/bin/golangci-lint: - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./tools/bin v1.52.2 + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./tools/bin v1.55.2 tools/bin/failpoint-ctl: tools/check/go.mod cd tools/check && $(GO) build -o ../bin/failpoint-ctl github.com/pingcap/failpoint/failpoint-ctl diff --git a/br/pkg/backup/client.go b/br/pkg/backup/client.go index ff07cb85..037871df 100644 --- a/br/pkg/backup/client.go +++ b/br/pkg/backup/client.go @@ -250,7 +250,9 @@ func (bc *Client) BackupRanges( progressCallBack func(ProgressUnit), ) error { init := time.Now() - defer log.Info("Backup Ranges", zap.Duration("take", time.Since(init))) + defer func() { + log.Info("Backup Ranges", zap.Duration("take", time.Since(init))) + }() if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil { span1 := span.Tracer().StartSpan("Client.BackupRanges", opentracing.ChildOf(span.Context())) diff --git a/br/pkg/backup/client_test.go b/br/pkg/backup/client_test.go index 3ad94897..f6150d63 100644 --- a/br/pkg/backup/client_test.go +++ b/br/pkg/backup/client_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/jarcoal/httpmock" - . "github.com/pingcap/check" + . "github.com/pingcap/check" // nolint:revive backuppb "github.com/pingcap/kvproto/pkg/brpb" "github.com/pingcap/kvproto/pkg/errorpb" "github.com/pingcap/kvproto/pkg/kvrpcpb" diff --git a/br/pkg/storage/s3_test.go b/br/pkg/storage/s3_test.go index 947c6c41..88ba9ea7 100644 --- a/br/pkg/storage/s3_test.go +++ b/br/pkg/storage/s3_test.go @@ -21,7 +21,7 @@ import ( backuppb "github.com/pingcap/kvproto/pkg/brpb" "github.com/stretchr/testify/require" "github.com/tikv/migration/br/pkg/mock" - . "github.com/tikv/migration/br/pkg/storage" + . "github.com/tikv/migration/br/pkg/storage" // nolint:revive ) type s3Suite struct { diff --git a/cdc/Makefile b/cdc/Makefile index 80954e72..8e9b1249 100644 --- a/cdc/Makefile +++ b/cdc/Makefile @@ -202,7 +202,7 @@ tools/bin/goveralls: tools/check/go.mod cd tools/check && $(GO) build -mod=mod -o ../bin/goveralls github.com/mattn/goveralls tools/bin/golangci-lint: tools/check/go.mod - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b tools/bin v1.51.1 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b tools/bin v1.55.2 tools/bin/mockgen: tools/check/go.mod cd tools/check && $(GO) build -mod=mod -o ../bin/mockgen github.com/golang/mock/mockgen diff --git a/cdc/cdc/model/kv.go b/cdc/cdc/model/kv.go index 57637e5e..47162bb1 100644 --- a/cdc/cdc/model/kv.go +++ b/cdc/cdc/model/kv.go @@ -54,9 +54,8 @@ func (e *RegionFeedEvent) GetValue() interface{} { return e.Val } else if e.Resolved != nil { return e.Resolved - } else { - return nil } + return nil } // ResolvedSpan guarantees all the KV value event diff --git a/cdc/pkg/fsutil/filelock.go b/cdc/pkg/fsutil/filelock.go index 8a1271f8..16d6cc44 100644 --- a/cdc/pkg/fsutil/filelock.go +++ b/cdc/pkg/fsutil/filelock.go @@ -79,7 +79,6 @@ func (fl *FileLock) IsLocked() (bool, error) { return true, nil } else if err != nil { return false, errors.Trace(err) - } else { - return false, nil } + return false, nil }