From d7145e2c066556c2dd753bde5467a7f5198ca112 Mon Sep 17 00:00:00 2001 From: Bingyi Sun Date: Tue, 21 Nov 2023 10:04:21 +0800 Subject: [PATCH] enhance: Update golangci_lint version (#28535) Update golangci lint and fix some warnings Signed-off-by: sunby --- Makefile | 4 ++-- internal/kv/tikv/txn_tikv.go | 3 +-- internal/parser/planparserv2/utils.go | 3 +-- internal/util/importutil/binlog_adapter.go | 10 ++++------ 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 4e0f8b5750..21cc1b1d95 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ ifdef USE_DYNAMIC_SIMD use_dynamic_simd = ${USE_DYNAMIC_SIMD} endif # golangci-lint -GOLANGCI_LINT_VERSION := 1.53.1 +GOLANGCI_LINT_VERSION := 1.55.2 GOLANGCI_LINT_OUTPUT := $(shell $(INSTALL_PATH)/golangci-lint --version 2>/dev/null) INSTALL_GOLANGCI_LINT := $(findstring $(GOLANGCI_LINT_VERSION), $(GOLANGCI_LINT_OUTPUT)) # mockery @@ -80,7 +80,7 @@ get-build-deps: getdeps: @mkdir -p $(INSTALL_PATH) @if [ -z "$(INSTALL_GOLANGCI_LINT)" ]; then \ - echo "Installing golangci-lint into ./bin/" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(INSTALL_PATH) v1.53.1 ; \ + echo "Installing golangci-lint into ./bin/" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(INSTALL_PATH) v${GOLANGCI_LINT_VERSION} ; \ else \ echo "golangci-lint v@$(GOLANGCI_LINT_VERSION) already installed"; \ fi diff --git a/internal/kv/tikv/txn_tikv.go b/internal/kv/tikv/txn_tikv.go index d9542478d8..10c25f9e8b 100644 --- a/internal/kv/tikv/txn_tikv.go +++ b/internal/kv/tikv/txn_tikv.go @@ -773,7 +773,6 @@ func convertEmptyStringToByte(value string) ([]byte, error) { return EmptyValueByte, nil } else if value == EmptyValueString { return nil, fmt.Errorf("Value for key is reserved by EmptyValue: %s", EmptyValueString) - } else { - return []byte(value), nil } + return []byte(value), nil } diff --git a/internal/parser/planparserv2/utils.go b/internal/parser/planparserv2/utils.go index d6c2172e7c..53d3e72587 100644 --- a/internal/parser/planparserv2/utils.go +++ b/internal/parser/planparserv2/utils.go @@ -432,9 +432,8 @@ func HandleCompare(op int, left, right *ExprWithType) (*planpb.Expr, error) { return handleCompareRightValue(op, right, valueExpr) } else if valueExpr := right.expr.GetValueExpr(); valueExpr != nil { return handleCompareRightValue(cmpOp, left, valueExpr) - } else { - return handleCompare(cmpOp, left, right) } + return handleCompare(cmpOp, left, right) } func isEmptyExpression(s string) bool { diff --git a/internal/util/importutil/binlog_adapter.go b/internal/util/importutil/binlog_adapter.go index b06428e587..2e8171fbf8 100644 --- a/internal/util/importutil/binlog_adapter.go +++ b/internal/util/importutil/binlog_adapter.go @@ -316,10 +316,9 @@ func (p *BinlogAdapter) readDeltalogs(segmentHolder *SegmentFilesHolder) (map[in } log.Info("Binlog adapter: count of deleted entities", zap.Int("deletedCount", len(deletedIDDict))) return nil, deletedIDDict, nil - } else { - log.Warn("Binlog adapter: unsupported primary key type", zap.Int("type", int(primaryKey.GetDataType()))) - return nil, nil, fmt.Errorf("unsupported primary key type %d, primary key should be int64 or varchar", primaryKey.GetDataType()) } + log.Warn("Binlog adapter: unsupported primary key type", zap.Int("type", int(primaryKey.GetDataType()))) + return nil, nil, fmt.Errorf("unsupported primary key type %d, primary key should be int64 or varchar", primaryKey.GetDataType()) } // decodeDeleteLogs decodes string array(read from delta log) to storage.DeleteLog array @@ -495,10 +494,9 @@ func (p *BinlogAdapter) readPrimaryKeys(logPath string) ([]int64, []string, erro } log.Info("Binlog adapter: succeed to read varchar primary key binlog", zap.Int("len", len(idList))) return nil, idList, nil - } else { - log.Warn("Binlog adapter: unsupported primary key type", zap.Int("type", int(primaryKey.GetDataType()))) - return nil, nil, fmt.Errorf("unsupported primary key type %d, primary key should be int64 or varchar", primaryKey.GetDataType()) } + log.Warn("Binlog adapter: unsupported primary key type", zap.Int("type", int(primaryKey.GetDataType()))) + return nil, nil, fmt.Errorf("unsupported primary key type %d, primary key should be int64 or varchar", primaryKey.GetDataType()) } // getShardingListByPrimaryInt64 method generates a shard id list by primary key(int64) list and deleted list.