pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.24k stars 5.84k forks source link

Tracking issue for enabling more linters #28720

Closed tangenta closed 2 years ago

tangenta commented 3 years ago

Enhancement

There are a lot of linters in https://golangci-lint.run/usage/linters. We can utilize them to enhance TiDB's code quality.

To enable one of the linters, the steps are as follows:

  1. Add the target linter to .golangci.yml (comment out the others to speed up the linter's check).
  2. Run make check and see what issues are detected.
  3. Fix the code or add // nolinter comments.
  4. Repeat step 2 and step 3 until all the issues are fixed.
  5. File a PR and reference the subtask issue.

Here is an example: https://github.com/pingcap/tidb/pull/28756/files

Other linters that are thought to be unnecessary

- dogsled - depguard - forbidigo - funlen - gci - gochecknoglobals - gochecknoinits - godox - gofmt - gofumpt - goheader - goimports - gomoddirectives - gomodguard - goprintffuncname - ifshort - importas - lll - misspell - nakedret - nestif - nilerr - nlreturn - noctx - nolintlint - paralleltest - revive - tagliatelle - testpackage - thelper - tparallel - whitespace - wrapcheck - wsl

Misc

tisonkun commented 3 years ago

@tangenta what is the following plan for this issue? Shall we investigate and turn on linters one by one?

tangenta commented 3 years ago

These linters are roughly checked, but please feel free to make further investigations.

I think we can turn on them if the time cost is not significant.

morgo commented 3 years ago

make check has not been clean for me for a while now (see paste). I am using go 1.16.7.

Is there a different issue which tracks this?

util/codec/codec.go:466:45: G601: Implicit memory aliasing in for loop. (gosec)
                b = (*[sizeFloat64]byte)(unsafe.Pointer(&f))[:]
                                                        ^
ddl/label/attributes.go:129:31: G601: Implicit memory aliasing in for loop. (gosec)
        res := label.CompatibleWith(&l)
                                    ^
ddl/placement/constraints.go:88:31: G601: Implicit memory aliasing in for loop. (gosec)
        res := label.CompatibleWith(&cnst)
                                    ^
bindinfo/handle.go:853:45: G201: SQL string formatting (gosec)
        return strings.Replace(bindSQL, "DELETE", fmt.Sprintf("DELETE /*+ %s*/", planHint), 1)
                                                  ^
bindinfo/handle.go:858:45: G201: SQL string formatting (gosec)
        return strings.Replace(bindSQL, "UPDATE", fmt.Sprintf("UPDATE /*+ %s*/", planHint), 1)
                                                  ^
bindinfo/handle.go:872:56: G201: SQL string formatting (gosec)
            tmp := strings.Replace(bindSQL[withEnd:], "SELECT", fmt.Sprintf("SELECT /*+ %s*/", planHint), 1)
                                                                ^
ddl/ddl_api.go:5513:72: G202: SQL string concatenation (gosec)
                    return nil, errWrongFKOptionForGeneratedColumn.GenWithStackByArgs("ON UPDATE " + refer.OnUpdate.ReferOpt.String())
                                                                                      ^
ddl/ddl_api.go:5517:72: G202: SQL string concatenation (gosec)
                    return nil, errWrongFKOptionForGeneratedColumn.GenWithStackByArgs("ON DELETE " + refer.OnDelete.ReferOpt.String())
                                                                                      ^
server/http_handler.go:972:10: G202: SQL string concatenation (gosec)
        sql += ` WHERE ` + strings.Join(condition, ` AND `)
               ^
planner/core/explain.go:596:4: SA9003: empty branch (staticcheck)
            if err != nil {
            ^
privilege/privileges/privileges_test.go:648:10: SA9003: empty branch (staticcheck)
        } else {
               ^
privilege/privileges/privileges_test.go:655:10: SA9003: empty branch (staticcheck)
        } else {
               ^
util/math/math.go:55:21: SA4000: identical expressions on the left and right side of the '-' operator (staticcheck)
    return !math.IsNaN(f - f)
                       ^
expression/builtin_encryption_vec.go:541:16: SA6002: argument should be pointer-like to avoid allocations (staticcheck)
        bytePool.Put(b)
                     ^
expression/expression.go:301:15: SA6002: argument should be pointer-like to avoid allocations (staticcheck)
        selPool.Put(sel)
                    ^
expression/expression.go:314:16: SA6002: argument should be pointer-like to avoid allocations (staticcheck)
        zeroPool.Put(isZero)
                     ^
store/mockstore/unistore/tikv/mvcc/tikv.go:177:3: SA4006: this value of `data` is never used (staticcheck)
        data, lock.MinCommitTS, err = codec.DecodeUint(data[1:])
        ^
ddl/db_test.go:2626:2: SA4006: this value of `tbl` is never used (staticcheck)
    tbl, err = is.TableByName(model.NewCIStr("test_db"), model.NewCIStr("t"))
    ^
ddl/serial_test.go:546:2: SA4006: this value of `err` is never used (staticcheck)
    _, err = tk.Exec("create table auto_random_table (a bigint primary key auto_random(3), b varchar(255));")
    ^
ddl/serial_test.go:554:2: SA4006: this value of `err` is never used (staticcheck)
    _, err = tk.Exec("create table table_pre_split(id int) shard_row_id_bits = 2 pre_split_regions=2;")
    ^
ddl/serial_test.go:562:2: SA4006: this value of `err` is never used (staticcheck)
    _, err = tk.Exec("create table shard_row_id_table (a int) shard_row_id_bits = 5;")
    ^
planner/core/fragment.go:178:3: SA4006: this value of `stack` is never used (staticcheck)
        stack = stack[:len(stack)-1]
        ^
planner/core/fragment.go:196:3: SA4006: this value of `stack` is never used (staticcheck)
        stack = stack[:len(stack)-1]
        ^
planner/core/logical_plan_builder.go:846:3: SA4006: this value of `leftPlan` is never used (staticcheck)
        leftPlan, rightPlan = rightPlan, leftPlan
        ^
planner/core/memtable_predicate_extractor.go:955:2: SA4006: this value of `remained` is never used (staticcheck)
    remained, quantileSkip, quantiles := e.extractCol(schema, names, predicates, "quantile", false)
    ^
executor/executor_test.go:3527:33: SA1029: should not use built-in type string as key for value; define your own type to avoid collisions (staticcheck)
    ctx1 := context.WithValue(ctx, "CheckSelectRequestHook", func(req *kv.Request) {
                                   ^
executor/executor_test.go:3562:34: SA1029: should not use built-in type string as key for value; define your own type to avoid collisions (staticcheck)
        ctx1 := context.WithValue(ctx, "CheckSelectRequestHook", func(req *kv.Request) {
                                       ^
executor/executor_test.go:3991:34: SA1029: should not use built-in type string as key for value; define your own type to avoid collisions (staticcheck)
        ctx1 := context.WithValue(ctx, "CheckSelectRequestHook", func(req *kv.Request) {
                                       ^
ddl/column_type_change_test.go:284:44: SA1019: dbterror.ClassDDL.New is deprecated: use NewStd or NewStdErr instead.  (staticcheck)
    mockTerrorMap[model.StateNone.String()] = dbterror.ClassDDL.New(1, "MockRollingBackInCallBack-"+model.StateNone.String())
                                              ^
ddl/column_type_change_test.go:285:50: SA1019: dbterror.ClassDDL.New is deprecated: use NewStd or NewStdErr instead.  (staticcheck)
    mockTerrorMap[model.StateDeleteOnly.String()] = dbterror.ClassDDL.New(1, "MockRollingBackInCallBack-"+model.StateDeleteOnly.String())
                                                    ^
ddl/column_type_change_test.go:286:49: SA1019: dbterror.ClassDDL.New is deprecated: use NewStd or NewStdErr instead.  (staticcheck)
    mockTerrorMap[model.StateWriteOnly.String()] = dbterror.ClassDDL.New(1, "MockRollingBackInCallBack-"+model.StateWriteOnly.String())
                                                   ^
domain/domain.go:698:6: SA1019: grpc.WithBackoffMaxDelay is deprecated: use WithConnectParams instead. Will be supported throughout 1.x.  (staticcheck)
                    grpc.WithBackoffMaxDelay(time.Second * 3),
                    ^
executor/executor_test.go:31:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.  (staticcheck)
    "github.com/golang/protobuf/proto"
    ^
expression/builtin_like.go:147:23: SA1019: from.memorizedRegexp.Copy is deprecated: In earlier releases, when using a Regexp in multiple goroutines, giving each goroutine its own copy helped to avoid lock contention. As of Go 1.12, using Copy is no longer necessary to avoid lock contention. Copy may still be appropriate if the reason for its use is to make two copies with different Longest settings.  (staticcheck)
        b.memorizedRegexp = from.memorizedRegexp.Copy()
                            ^
owner/manager.go:389:26: SA1019: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead.  (staticcheck)
        terror.ErrorEqual(err, grpc.ErrClientConnClosing) {
                               ^
owner/fail_test.go:90:38: SA1019: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead.  (staticcheck)
        isContextDone := terror.ErrorEqual(grpc.ErrClientConnClosing, err) || terror.ErrorEqual(context.Canceled, err)
                                           ^
owner/fail_test.go:111:38: SA1019: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead.  (staticcheck)
        isContextDone := terror.ErrorEqual(grpc.ErrClientConnClosing, err) || terror.ErrorEqual(context.Canceled, err)
                                           ^
session/session_test.go:161:4: SA1019: grpc.WithBackoffMaxDelay is deprecated: use WithConnectParams instead. Will be supported throughout 1.x.  (staticcheck)
            grpc.WithBackoffMaxDelay(time.Second * 3),
            ^
sessionctx/binloginfo/binloginfo_test.go:100:9: SA1019: grpc.WithDialer is deprecated: use WithContextDialer instead.  Will be supported throughout 1.x.  (staticcheck)
    opt := grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
           ^
store/mockstore/mockcopr/analyze.go:20:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.  (staticcheck)
    "github.com/golang/protobuf/proto"
    ^
store/mockstore/mockcopr/cop_handler_dag.go:23:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.  (staticcheck)
    "github.com/golang/protobuf/proto"
    ^
store/mockstore/unistore/tikv/region.go:545:12: SA1015: using time.Tick leaks the underlying ticker, consider using it only in endless functions, tests and the main package, and use time.NewTicker here (staticcheck)
    ticker := time.Tick(time.Second * 3)
              ^
statistics/scalar.go:241:33: SA4003: no value of type uint64 is less than 0 (staticcheck)
        if remaining >= maxNumStep || remaining < 0 {
                                      ^
executor/executor_pkg_test.go:465:24: ST1016: methods on the same type should have the same receiver name (seen 1x "cm", 8x "s") (stylecheck)
func (s *pkgTestSuite) TestAggPartialResultMapperB(c *C) {
                       ^
expression/builtin_arithmetic.go:376:44: ST1016: methods on the same type should have the same receiver name (seen 2x "b", 2x "s") (stylecheck)
func (s *builtinArithmeticMinusDecimalSig) Clone() builtinFunc {
                                           ^
expression/builtin_arithmetic.go:677:45: ST1016: methods on the same type should have the same receiver name (seen 2x "b", 2x "s") (stylecheck)
func (s *builtinArithmeticDivideDecimalSig) Clone() builtinFunc {
                                            ^
expression/builtin_arithmetic.go:1086:52: ST1016: methods on the same type should have the same receiver name (seen 2x "b", 2x "s") (stylecheck)
func (s *builtinArithmeticModIntSignedUnsignedSig) Clone() builtinFunc {
                                                   ^
expression/builtin_arithmetic.go:198:39: ST1016: methods on the same type should have the same receiver name (seen 2x "s", 6x "b") (stylecheck)
func (s *builtinArithmeticPlusIntSig) Clone() builtinFunc {
                                      ^
expression/builtin_arithmetic.go:406:40: ST1016: methods on the same type should have the same receiver name (seen 2x "b", 3x "s") (stylecheck)
func (s *builtinArithmeticMinusIntSig) Clone() builtinFunc {
                                       ^
expression/constant.go:103:20: ST1016: methods on the same type should have the same receiver name (seen 33x "c", 3x "expr") (stylecheck)
func (c *Constant) Clone() Expression {
                   ^
expression/builtin_arithmetic.go:768:44: ST1016: methods on the same type should have the same receiver name (seen 3x "s", 6x "b") (stylecheck)
func (s *builtinArithmeticIntDivideIntSig) Clone() builtinFunc {
                                           ^
expression/scalar_function.go:562:27: ST1016: methods on the same type should have the same receiver name (seen 3x "expr", 41x "sf") (stylecheck)
func (sf *ScalarFunction) CharsetAndCollation(ctx sessionctx.Context) (string, string) {
                          ^
planner/core/explain.go:998:23: ST1016: methods on the same type should have the same receiver name (seen 2x "p", 8x "ls") (stylecheck)
func (p *LogicalSort) ExplainInfo() string {
                      ^
planner/core/explain.go:521:27: ST1016: methods on the same type should have the same receiver name (seen 11x "p", 3x "base") (stylecheck)
func (p *basePhysicalAgg) ExplainInfo() string {
                          ^
planner/core/stats.go:1096:25: ST1016: methods on the same type should have the same receiver name (seen 11x "la", 1x "p") (stylecheck)
func (la *LogicalApply) DeriveStats(childStats []*property.StatsInfo, selfSchema *expression.Schema, childSchema []*expression.Schema, colGroups [][]*expression.Column) (*property.StatsInfo, error) {
                        ^
planner/core/rule_build_key_info.go:312:29: ST1016: methods on the same type should have the same receiver name (seen 1x "tg", 2x "p", 3x "sg") (stylecheck)
func (tg *TiKVSingleGather) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
                            ^
planner/core/rule_build_key_info.go:293:29: ST1016: methods on the same type should have the same receiver name (seen 1x "s", 3x "p", 4x "is") (stylecheck)
func (is *LogicalIndexScan) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
                            ^
planner/core/rule_build_key_info.go:126:23: ST1016: methods on the same type should have the same receiver name (seen 10x "lt", 3x "p") (stylecheck)
func (p *LogicalTopN) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
                      ^
planner/core/plan.go:520:27: ST1016: methods on the same type should have the same receiver name (seen 1x "s", 27x "p") (stylecheck)
func (p *baseLogicalPlan) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
                          ^
planner/core/util.go:184:30: ST1016: methods on the same type should have the same receiver name (seen 1x "p", 5x "s") (stylecheck)
func (s *baseSchemaProducer) OutputNames() types.NameSlice {
                             ^
planner/core/rule_build_key_info.go:46:31: ST1016: methods on the same type should have the same receiver name (seen 1x "p", 28x "la") (stylecheck)
func (la *LogicalAggregation) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
                              ^
planner/core/explain.go:94:29: ST1016: methods on the same type should have the same receiver name (seen 14x "p", 3x "is") (stylecheck)
func (p *PhysicalIndexScan) AccessObject(normalized bool) string {
                            ^
planner/core/physical_plans.go:639:25: ST1016: methods on the same type should have the same receiver name (seen 2x "lt", 9x "p") (stylecheck)
func (lt *PhysicalTopN) Clone() (PhysicalPlan, error) {
                        ^
planner/core/plan.go:529:33: ST1016: methods on the same type should have the same receiver name (seen 1x "p", 6x "s") (stylecheck)
func (p *logicalSchemaProducer) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
                                ^
planner/core/explain.go:226:29: ST1016: methods on the same type should have the same receiver name (seen 10x "p", 8x "ts") (stylecheck)
func (p *PhysicalTableScan) AccessObject(normalized bool) string {
                            ^
planner/core/physical_plans.go:897:36: ST1016: methods on the same type should have the same receiver name (seen 1x "e", 3x "p") (stylecheck)
func (p *PhysicalExchangeReceiver) Clone() (PhysicalPlan, error) {
                                   ^
planner/core/physical_plans.go:673:26: ST1016: methods on the same type should have the same receiver name (seen 2x "la", 4x "p") (stylecheck)
func (la *PhysicalApply) Clone() (PhysicalPlan, error) {
                         ^
planner/core/rule_build_key_info.go:288:29: ST1016: methods on the same type should have the same receiver name (seen 1x "p", 1x "s", 4x "ts") (stylecheck)
func (ts *LogicalTableScan) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
                            ^
planner/core/physical_plans.go:924:34: ST1016: methods on the same type should have the same receiver name (seen 1x "e", 4x "p") (stylecheck)
func (p *PhysicalExchangeSender) Clone() (PhysicalPlan, error) {
                                 ^
planner/core/physical_plans.go:1141:25: ST1016: methods on the same type should have the same receiver name (seen 2x "ls", 5x "p") (stylecheck)
func (ls *PhysicalSort) Clone() (PhysicalPlan, error) {
                        ^
planner/core/resolve_indices.go:639:34: ST1016: methods on the same type should have the same receiver name (seen 1x "p", 3x "s") (stylecheck)
func (p *physicalSchemaProducer) ResolveIndices() (err error) {
                                 ^
planner/core/physical_plans.go:1214:29: ST1016: methods on the same type should have the same receiver name (seen 1x "sel", 7x "p") (stylecheck)
func (p *PhysicalSelection) Clone() (PhysicalPlan, error) {
                            ^
store/mockstore/unistore/tikv/mock_region.go:662:30: ST1016: methods on the same type should have the same receiver name (seen 1x "mrm", 30x "rm") (stylecheck)
func (rm *MockRegionManager) AddPeer(regionID, storeID, peerID uint64) {
                             ^
bindinfo/cache.go:91:2: ST1003: struct field Db should be DB (stylecheck)
    Db          string
    ^
bindinfo/handle.go:227:2: ST1003: var updateTs should be updateTS (stylecheck)
    updateTs := now.String()
    ^
bindinfo/handle.go:384:2: ST1003: var updateTs should be updateTS (stylecheck)
    updateTs := types.NewTime(types.FromGoTime(time.Now()), mysql.TypeTimestamp, 3).String()
    ^
store/mockstore/unistore/tikv/mvcc/tikv.go:64:2: ST1003: const minCommitTsPrefix should be minCommitTSPrefix (stylecheck)
    minCommitTsPrefix = 'm'
    ^
store/mockstore/unistore/tikv/mvcc/tikv.go:72:38: ST1003: func parameter startTs should be startTS (stylecheck)
func EncodeWriteCFValue(t WriteType, startTs uint64, shortVal []byte) []byte {
                                     ^
store/mockstore/unistore/tikv/dbreader/db_reader.go:234:20: ST1003: method GetKeyByStartTs should be GetKeyByStartTS (stylecheck)
func (r *DBReader) GetKeyByStartTs(startKey, endKey []byte, startTs uint64) ([]byte, error) {
                   ^
bindinfo/handle_serial_test.go:114:2: ST1003: var defaultDb should be defaultDB (stylecheck)
    defaultDb := "test"
    ^
ddl/partition.go:1243:2: ST1003: var ntDbInfo should be ntDBInfo (stylecheck)
    ntDbInfo, err := checkSchemaExistAndCancelNotExistJob(t, job)
    ^
ddl/db_test.go:7271:2: ST1003: var longDbName should be longDBName (stylecheck)
    longDbName := strings.Repeat("库", mysql.MaxDatabaseNameLength-1)
    ^
executor/adapter.go:231:2: ST1003: var startTs should be startTS (stylecheck)
    startTs := uint64(math.MaxUint64)
    ^
executor/builder.go:575:2: ST1003: var startTs should be startTS (stylecheck)
    startTs, err := b.getSnapshotTS()
    ^
executor/builder.go:2891:2: ST1003: var startTs should be startTS (stylecheck)
    startTs, err := b.getSnapshotTS()
    ^
executor/checksum.go:176:2: ST1003: struct field StartTs should be StartTS (stylecheck)
    StartTs   uint64
    ^
executor/checksum.go:180:67: ST1003: func parameter startTs should be startTS (stylecheck)
func newChecksumContext(db *model.DBInfo, table *model.TableInfo, startTs uint64) *checksumContext {
                                                                  ^
executor/compiler.go:184:6: ST1003: func getStmtDbLabel should be getStmtDBLabel (stylecheck)
func getStmtDbLabel(stmtNode ast.StmtNode) map[string]struct{} {
     ^
executor/compiler.go:276:6: ST1003: func getDbFromResultNode should be getDBFromResultNode (stylecheck)
func getDbFromResultNode(resultNode ast.ResultSetNode) []string { // may have duplicate db name
     ^
executor/infoschema_reader.go:1085:3: ST1003: var lastHeartbeatTs should be lastHeartbeatTS (stylecheck)
        lastHeartbeatTs := types.NewTime(types.FromGoTime(storeStat.Status.LastHeartbeatTs), mysql.TypeDatetime, types.DefaultFsp)
        ^
executor/point_get.go:103:62: ST1003: method parameter startTs should be startTS (stylecheck)
func (e *PointGetExecutor) Init(p *plannercore.PointGetPlan, startTs uint64) {
                                                             ^
executor/sample.go:96:67: ST1003: func parameter startTs should be startTS (stylecheck)
func newTableRegionSampler(ctx sessionctx.Context, t table.Table, startTs uint64, partTables []table.PartitionedTable,
                                                                  ^
executor/set.go:226:2: ST1003: var csDb should be csDB (stylecheck)
    csDb, err := sessionVars.GlobalVarsAccessor.GetGlobalSysVar(variable.CharsetDatabase)
tangenta commented 3 years ago

@morgo Which version of the golangci-lint did you use? make check is clean in my local environment.

✗ tools/bin/golangci-lint version
golangci-lint has version 1.41.1 built from a2074809 on 2021-06-19T16:01:50Z
morgo commented 3 years ago

@tangenta That was it. My version was:

$ tools/bin/golangci-lint version
golangci-lint has version 1.29.0 built from 6a68907 on 2020-07-20T14:54:31Z

I upgraded to v1.42.1 and I get different errors now. So it looks like this is something we should script around to make sure the version is in an acceptable range?

util/israce/norace.go:14: File is not `goimports`-ed (goimports)

util/testbridge/bridge.go:14: File is not `goimports`-ed (goimports)

util/sys/linux/sys_linux.go:13: File is not `goimports`-ed (goimports)
Defined2014 commented 3 years ago

According #29067, #28910 and #28952, I found we have some codes that are only used in tests or never be used. Used find . -name "*test.go" | xargs rm -rf; make check-static to get some result below. IMO, we should move those function to test file or delete them.

Does golangci-lint have a way to deal with it? @tangenta @tisonkun

tools/bin/golangci-lint run -v $(go list ./... | grep -vE "github.com\/pingcap\/tidb\/br|github.com\/pingcap\/tidb\/cmd" | sed 's|github.com/pingcap/tidb/||')
sessionctx/variable/session.go:1585:23: func `(*SessionVars).setTxnMode` is unused (unused)
func (s *SessionVars) setTxnMode(val string) error {
                      ^
util/selection/selection.go:55:6: func `quickselect` is unused (unused)
func quickselect(data Interface, left, right, k int) int {
     ^
util/chunk/disk.go:103:22: func `(*ListInDisk).flush` is unused (unused)
func (l *ListInDisk) flush() (err error) {
                     ^
util/stmtsummary/statement_summary.go:472:38: func `(*stmtSummaryByDigestMap).maxStmtCount` is unused (unused)
func (ssMap *stmtSummaryByDigestMap) maxStmtCount() int {
                                     ^
plugin/plugin.go:49:19: func `(*plugins).clone` is unused (unused)
func (p *plugins) clone() *plugins {
                  ^
util/benchdaily/bench_daily.go:85:6: `readBenchResultFromFile` is unused (deadcode)
func readBenchResultFromFile(file string) []BenchResult {
     ^
executor/hash_table.go:145:28: func `(*hashRowContainer).alreadySpilledSafeForTest` is unused (unused)
func (c *hashRowContainer) alreadySpilledSafeForTest() bool {
                           ^
config/config_util.go:107:6: `atomicWriteConfig` is unused (deadcode)
func atomicWriteConfig(c *Config, confPath string) (err error) {
     ^
config/config_util.go:131:6: `decodeConfig` is unused (deadcode)
func decodeConfig(content string) (*Config, error) {
     ^
config/config_util.go:122:6: func `encodeConfig` is unused (unused)
func encodeConfig(conf *Config) (string, error) {
     ^
statistics/fmsketch.go:119:6: `buildFMSketch` is unused (deadcode)
func buildFMSketch(sc *stmtctx.StatementContext, values []types.Datum, maxSize int) (*FMSketch, int64, error) {
     ^
plugin/conn_ip_example/conn_ip_example.go:33:6: `Validate` is unused (deadcode)
func Validate(ctx context.Context, m *plugin.Manifest) error {
     ^
plugin/conn_ip_example/conn_ip_example.go:40:6: `OnInit` is unused (deadcode)
func OnInit(ctx context.Context, manifest *plugin.Manifest) error {
     ^
plugin/conn_ip_example/conn_ip_example.go:81:6: `OnShutdown` is unused (deadcode)
func OnShutdown(ctx context.Context, manifest *plugin.Manifest) error {
     ^
plugin/conn_ip_example/conn_ip_example.go:90:6: `OnGeneralEvent` is unused (deadcode)
func OnGeneralEvent(ctx context.Context, sctx *variable.SessionVars, event plugin.GeneralEvent, cmd string) {
     ^
plugin/conn_ip_example/conn_ip_example.go:115:6: `OnConnectionEvent` is unused (deadcode)
func OnConnectionEvent(ctx context.Context, event plugin.ConnectionEvent, info *variable.ConnectionInfo) error {
     ^
tangenta commented 2 years ago

We are planning to migrate the linter tool to "nogo" to utilize the incremental lint. This issue will be closed temporarily until the migrated linters are stabilized. For details, see https://github.com/pingcap/tidb/pull/35344.

Thanks for your contributions.