diff --git a/build/BUILD.bazel b/build/BUILD.bazel index 6b8c0daa73110..d0f8d380b0b89 100644 --- a/build/BUILD.bazel +++ b/build/BUILD.bazel @@ -61,7 +61,9 @@ STATICHECK_ANALYZERS = [ "SA2003", "SA3000", "SA3001", + "SA4004", "SA4009", + "SA4018", "SA5000", "SA5001", "SA5002", diff --git a/build/nogo_config.json b/build/nogo_config.json index 13770711965fe..8c6d56d74285c 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -1023,6 +1023,14 @@ ".*_generated\\.go$": "ignore generated code" } }, + "SA4004": { + "exclude_files": { + "parser/parser.go": "parser/parser.go code", + "server/http_status.go": "ignore server/http_status.go", + "external/": "no need to vet third party code", + ".*_generated\\.go$": "ignore generated code" + } + }, "SA4009": { "exclude_files": { "parser/parser.go": "parser/parser.go code", @@ -1030,6 +1038,13 @@ ".*_generated\\.go$": "ignore generated code" } }, + "SA4018": { + "exclude_files": { + "parser/parser.go": "parser/parser.go code", + "external/": "no need to vet third party code", + ".*_generated\\.go$": "ignore generated code" + } + }, "SA5000": { "exclude_files": { "parser/parser.go": "parser/parser.go code", diff --git a/store/mockstore/unistore/tikv/mvcc/tikv.go b/store/mockstore/unistore/tikv/mvcc/tikv.go index 7b8a52dfd9159..ff62a8057602f 100644 --- a/store/mockstore/unistore/tikv/mvcc/tikv.go +++ b/store/mockstore/unistore/tikv/mvcc/tikv.go @@ -129,52 +129,3 @@ const ( ) var errInvalidLockCFValue = errors.New("invalid lock CF value") - -// ParseLockCFValue parses the []byte data and returns a MvccLock. -func ParseLockCFValue(data []byte) (lock Lock, err error) { - if len(data) == 0 { - err = errInvalidLockCFValue - return - } - switch data[0] { - case LockTypePut: - lock.Op = byte(kvrpcpb.Op_Put) - case LockTypeDelete: - lock.Op = byte(kvrpcpb.Op_Del) - case LockTypeLock: - lock.Op = byte(kvrpcpb.Op_Lock) - case LockTypePessimistic: - lock.Op = byte(kvrpcpb.Op_PessimisticLock) - default: - err = errInvalidLockCFValue - return - } - data, lock.Primary, err = codec.DecodeCompactBytes(data[1:]) - if err != nil { - return - } - lock.PrimaryLen = uint16(len(lock.Primary)) - data, lock.StartTS, err = codec.DecodeUvarint(data) - if err != nil || len(data) == 0 { - return - } - var ttl uint64 - data, ttl, err = codec.DecodeUvarint(data) - lock.TTL = uint32(ttl) - if err != nil || len(data) == 0 { - return - } - if data[0] == shortValuePrefix { - shortValLen := int(data[1]) - data = data[2:] - lock.Value = data[:shortValLen] - data = data[shortValLen:] - } - if len(data) > 0 && data[0] == forUpdatePrefix { - data, lock.ForUpdateTS, err = codec.DecodeUint(data[1:]) - } - if len(data) > 0 && data[0] == minCommitTsPrefix { - data, lock.MinCommitTS, err = codec.DecodeUint(data[1:]) - } - return -} diff --git a/util/dbutil/common.go b/util/dbutil/common.go index f97754c184516..17d6b34cc7c54 100644 --- a/util/dbutil/common.go +++ b/util/dbutil/common.go @@ -606,7 +606,7 @@ func GetTidbLatestTSO(ctx context.Context, db QueryExecutor) (int64, error) { } defer rows.Close() - for rows.Next() { + if rows.Next() { fields, err1 := ScanRow(rows) if err1 != nil { return 0, errors.Trace(err1) @@ -648,12 +648,11 @@ func GetDBVersion(ctx context.Context, db QueryExecutor) (string, error) { defer result.Close() var version sql.NullString - for result.Next() { + if result.Next() { err := result.Scan(&version) if err != nil { return "", errors.Trace(err) } - break } if version.Valid {