Tidb: Refine some code in TiDB

Created on 26 Nov 2019  路  8Comments  路  Source: pingcap/tidb

Feature Request

Is your feature request related to a problem? Please describe:

There is a is a static analysis toolset called Staticcheck which can be used to refine our code.
For example:
staticcheck github.com/pingcap/tidb/...
I got the output:

-: could not load export data: no export data for "github.com/pingcap/tidb/ddl/failtest" (compile)
-: could not load export data: no export data for "github.com/pingcap/tidb/executor/seqtest" (compile)
bindinfo/bind_test.go:56:2: field ctx is unused (U1000)
bindinfo/handle.go:495:2: unnecessary nil check around range (S1031)
bindinfo/handle.go:537:20: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
bindinfo/handle.go:707:18: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (S1028)
bindinfo/handle.go:726:2: redundant return statement (S1023)
bindinfo/session_handle.go:91:2: unnecessary nil check around range (S1031)
config/config.go:156:9: assigning the result of this type assertion to a variable (switch v := v.(type)) could eliminate type assertions in switch cases (S1034)
    config/config.go:158:27: could eliminate this type assertion
ddl/callback_test.go:93:15: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
ddl/column_test.go:633:103: argument handle is overwritten before first use (SA4009)
    ddl/column_test.go:666:2: assignment to handle
ddl/db_integration_test.go:28:2: package "github.com/pingcap/parser/mysql" is being imported more than once (ST1019)
    ddl/db_integration_test.go:29:2: other import of "github.com/pingcap/parser/mysql"
ddl/db_integration_test.go:665:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:668:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:672:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:676:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:680:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:684:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:688:2: this value of rs is never used (SA4006)
ddl/db_test.go:32:2: package "github.com/pingcap/parser/mysql" is being imported more than once (ST1019)
    ddl/db_test.go:33:2: other import of "github.com/pingcap/parser/mysql"
ddl/db_test.go:841:24: func (*testDBSuite4).testAlterLock is unused (U1000)
ddl/db_test.go:1768:3: should use a simple channel send/receive instead of select with a single case (S1000)
ddl/db_test.go:2718:2: this value of rs is never used (SA4006)
ddl/db_test.go:2720:2: this value of rs is never used (SA4006)
ddl/db_test.go:3821:13: sleeping for 50 nanoseconds is probably a bug; be explicit if it isn't (SA1004)
ddl/ddl.go:458:38: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
ddl/ddl_api.go:466:37: should use strings.EqualFold instead (SA6005)
ddl/ddl_api.go:785:5: Background is a pure function but its return value is ignored (SA4017)
ddl/ddl_api.go:2757:6: should omit comparison to bool constant, can be simplified to !containColumn (S1002)
ddl/ddl_api.go:3922:38: should use make([]string, 0) instead (S1019)
ddl/ddl_worker.go:457:23: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
ddl/ddl_worker.go:680:3: should use a simple channel send/receive instead of select with a single case (S1000)
ddl/util/syncer_test.go:110:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002)
    ddl/util/syncer_test.go:119:4: call to T.Fatalf
ddl/util/syncer_test.go:233:55: grpc.Code is deprecated: use status.Code instead.  (SA1019)
ddl/util/syncer_test.go:253:5: identical expressions on the left and right side of the '!=' operator (SA4000)
executor/admin_test.go:447:3: this value of err is never used (SA4006)
executor/admin_test.go:470:3: this value of err is never used (SA4006)
executor/admin_test.go:492:3: this value of err is never used (SA4006)
executor/aggfuncs/func_first_row.go:104:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:151:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:197:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:243:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:290:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:337:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:383:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:432:3: the surrounding loop is unconditionally terminated (SA4004)
executor/analyze.go:247:2: field priority is unused (U1000)
executor/analyze.go:398:2: field priority is unused (U1000)
executor/analyze.go:608:6: should omit comparison to bool constant, can be simplified to *needRebuild (S1002)
executor/analyze.go:1023:27: should use make([][][]byte, len(idxInfo.Columns)) instead (S1019)
executor/analyze_test.go:245:10: this result of append is never used, except maybe in other appends (SA4010)
executor/batch_point_get.go:100:50: should use make(map[hack.MutableString]struct{}) instead (S1019)
executor/compiler.go:261:4: unnecessary nil check around range (S1031)
executor/compiler.go:262:5: should replace loop with dbLabels = append(dbLabels, dbs...) (S1011)
executor/compiler.go:270:4: unnecessary nil check around range (S1031)
executor/compiler.go:271:5: should replace loop with dbLabels = append(dbLabels, dbs...) (S1011)
executor/executor.go:1181:3: the surrounding loop is unconditionally terminated (SA4004)
executor/executor_test.go:2127:50: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/executor_test.go:2161:50: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/executor_test.go:2945:33: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/executor_test.go:2978:34: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/executor_test.go:3365:34: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/hash_table.go:247:26: func (*hashRowContainer).getJoinKeyFromChkRow is unused (U1000)
executor/index_lookup_hash_join.go:518:2: redundant return statement (S1023)
executor/join.go:330:7: should omit comparison to bool constant, can be simplified to !e.outerMatchedStatus[i].UnsafeIsSet(j) (S1002)
executor/join.go:367:7: should omit comparison to bool constant, can be simplified to !e.outerMatchedStatus[i].UnsafeIsSet(j) (S1002)
executor/load_data.go:243:4: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
executor/load_data.go:253:5: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
executor/seqtest/seq_executor_test.go:75:2: field ctx is unused (U1000)
executor/simple.go:782:5: this value of failedUsers is never used (SA4006)
executor/simple.go:782:19: this result of append is never used, except maybe in other appends (SA4010)
executor/sort.go:41:2: field keyExprs is unused (U1000)
executor/sort.go:42:2: field keyTypes is unused (U1000)
executor/table_readers_required_rows_test.go:94:31: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/table_readers_required_rows_test.go:95:31: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/trace.go:51:2: field rootTrace is unused (U1000)
executor/union_scan.go:194:3: the surrounding loop is unconditionally terminated (SA4004)
executor/update_test.go:37:2: field ctx is unused (U1000)
expression/bench_test.go:1169:7: should merge variable declaration with assignment on next line (S1021)
expression/builtin_arithmetic.go:402:16: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic.go:407:16: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic_vec.go:375:17: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic_vec.go:379:17: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic_vec.go:399:17: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic_vec.go:419:17: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_compare.go:2082:18: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_compare.go:2089:18: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_encryption_vec.go:452:16: argument should be pointer-like to avoid allocations (SA6002)
expression/builtin_like.go:119:22: from.memoizedRegexp.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.  (SA1019)
expression/builtin_vectorized_test.go:782:2: this value of sel is never used (SA4006)
expression/chunk_executor.go:110:10: empty branch (SA9003)
expression/chunk_executor.go:110:13: HasUnsignedFlag is a pure function but its return value is ignored (SA4017)
expression/constant_propagation_test.go:37:21: func (*testSuite).cleanEnv is unused (U1000)
expression/evaluator_test.go:54:2: field ctx is unused (U1000)
expression/expression.go:237:15: argument should be pointer-like to avoid allocations (SA6002)
expression/expression.go:250:16: argument should be pointer-like to avoid allocations (SA6002)
expression/integration_test.go:4209:32: func (*testIntegrationSuite).testTiDBIsOwnerFunc is unused (U1000)
expression/simple_rewriter.go:258:27: func (*simpleRewriter).useCache is unused (U1000)
expression/util_test.go:39:25: func (*testUtilSuite).checkPanic is unused (U1000)
infoschema/tables.go:2128:3: should replace loop with finalRows = append(finalRows, result.rows...) (S1011)
infoschema/tables.go:2214:2: field rows is unused (U1000)
kv/memdb_buffer.go:31:2: field bufferLenLimit is unused (U1000)
kv/mock_test.go:84:36: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
meta/meta.go:823:2: const codeInvalidTableKey is unused (U1000)
meta/meta.go:823:2: only the first constant in this group has an explicit type (SA9004)
meta/meta.go:824:2: const codeInvalidDBKey is unused (U1000)
owner/fail_test.go:92:38: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead.  (SA1019)
owner/fail_test.go:110:38: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead.  (SA1019)
owner/manager.go:379:26: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead.  (SA1019)
planner/cascades/implementation_rules.go:79:2: should use 'return !(!prop.IsEmpty())' instead of 'if !prop.IsEmpty() { return false }; return true' (S1008)
planner/core/common_plans.go:754:3: this value of err is never used (SA4006)
planner/core/errors.go:22:2: only the first constant in this group has an explicit type (SA9004)
planner/core/exhaust_physical_plans.go:616:2: field chosenIndexInfo is unused (U1000)
planner/core/exhaust_physical_plans.go:1117:33: should use make([]types.Datum, pointLength + 1) instead (S1019)
planner/core/exhaust_physical_plans.go:1118:33: should use make([]types.Datum, pointLength + 1) instead (S1019)
planner/core/exhaust_physical_plans.go:1122:33: should use make([]types.Datum, pointLength) instead (S1019)
planner/core/exhaust_physical_plans.go:1123:33: should use make([]types.Datum, pointLength) instead (S1019)
planner/core/find_best_task.go:267:5: should omit comparison to bool constant, can be simplified to !l (S1002)
planner/core/logical_plans.go:235:2: field calculateGenCols is unused (U1000)
planner/core/logical_plans.go:473:3: empty branch (SA9003)
planner/core/physical_plans.go:318:2: field outerSchema is unused (U1000)
planner/core/planbuilder.go:272:29: func (*handleColHelper).appendColToLastMap is unused (U1000)
planner/core/point_get_plan.go:51:2: field expr is unused (U1000)
planner/core/point_get_plan.go:52:2: field ctx is unused (U1000)
planner/core/rule_join_reorder_dp.go:285:31: func (*joinReorderDPSolver).newJoinWithConds is unused (U1000)
planner/core/rule_partition_processor.go:131:22: should omit comparison to bool constant, can be simplified to !ret (S1002)
planner/core/rule_partition_processor.go:210:21: should omit comparison to bool constant, can be simplified to !ret (S1002)
planner/core/stats.go:439:18: don't use Yoda conditions (ST1017)
planner/core/task.go:909:2: should use 'return len(remained) <= 0' instead of 'if len(remained) > 0 { return false }; return true' (S1008)
planner/memo/group_test.go:131:2: field cost is unused (U1000)
plugin/conn_ip_example/conn_ip_example.go:48:2: redundant return statement (S1023)
plugin/conn_ip_example/conn_ip_example_test.go:25:6: func LoadRunShutdownPluginExample is unused (U1000)
privilege/privileges/cache.go:150:2: should replace loop with queue = append(queue, activeRoles...) (S1011)
privilege/privileges/cache_test.go:31:2: field dbName is unused (U1000)
server/conn_test.go:348:26: func (*ConnTestSuite).testGetSessionVarsWaitTimeout is unused (U1000)
server/http_handler.go:563:2: field first is unused (U1000)
server/http_handler.go:564:2: field last is unused (U1000)
server/http_handler.go:565:2: field region is unused (U1000)
server/http_handler.go:1181:6: type hotRegion is unused (U1000)
server/http_handler.go:1185:6: type hotRegions is unused (U1000)
server/http_handler_test.go:227:2: this value of resp is never used (SA4006)
server/http_handler_test.go:691:23: printf-style function with dynamic format string and no further arguments should use print-style function instead (SA1006)
server/http_status.go:258:33: should use httpRouterPage.Bytes() instead of []byte(httpRouterPage.String()) (S1030)
server/server_test.go:119:20: func (*DBTest).fail is unused (U1000)
server/statistics_handler_test.go:72:31: func (*testDumpStatsSuite).stopServer is unused (U1000)
server/statistics_handler_test.go:238:31: func (*testDumpStatsSuite).clearData is unused (U1000)
session/session_test.go:1766:2: field checkLeak is unused (U1000)
session/session_test.go:1961:66: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
session/session_test.go:2396:49: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
session/session_test.go:2402:48: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
session/txn.go:469:2: redundant return statement (S1023)
sessionctx/binloginfo/binloginfo_test.go:101:9: grpc.WithDialer is deprecated: use WithContextDialer instead.  Will be supported throughout 1.x.  (SA1019)
sessionctx/variable/statusvar.go:101:2: tls.VersionSSL30 is deprecated: SSLv3 is cryptographically broken, and will be removed in Go 1.14. See golang.org/issue/32716.  (SA1019)
statistics/feedback.go:243:2: redundant return statement (S1023)
statistics/handle/update.go:286:6: should omit comparison to bool constant, can be simplified to !dumpMode (S1002)
statistics/handle/update.go:720:2: redundant return statement (S1023)
statistics/histogram.go:367:2: redundant return statement (S1023)
statistics/histogram.go:627:2: should replace loop with newHist.Buckets = append(newHist.Buckets, hg.Buckets...) (S1011)
store/mockstore/mocktikv/cluster.go:645:2: field tokenCount is unused (U1000)
store/mockstore/mocktikv/cluster_test.go:37:2: field store is unused (U1000)
store/mockstore/mocktikv/mvcc.go:243:6: type rawEntry is unused (U1000)
store/tikv/2pc.go:820:3: the surrounding loop is unconditionally terminated (SA4004)
store/tikv/client_batch.go:494:2: redundant return statement (S1023)
store/tikv/gcworker/gc_worker.go:182:5: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
store/tikv/lock_resolver.go:361:2: redundant return statement (S1023)
store/tikv/oracle/oracles/export_test.go:36:6: func ClearOracleHook is unused (U1000)
store/tikv/range_task.go:275:4: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
store/tikv/region_cache.go:432:23: func (*RegionCache).loadAndInsertRegion is unused (U1000)
store/tikv/region_cache.go:1153:2: redundant return statement (S1023)
store/tikv/region_cache.go:1307:2: redundant return statement (S1023)
store/tikv/region_request.go:220:5: grpc.Code is deprecated: use status.Code instead.  (SA1019)
store/tikv/snapshot_test.go:132:49: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
store/tikv/split_region.go:35:2: should use 'return bytes.Equal(key, regionStartKey)' instead of 'if bytes.Equal(key, regionStartKey) { return true }; return false' (S1008)
store/tikv/store_test.go:111:24: func (*mockPDClient).enable is unused (U1000)
structure/structure.go:23:2: only the first constant in this group has an explicit type (SA9004)
table/column.go:263:5: should use strings.EqualFold instead (SA6005)
table/column.go:398:74: should use strings.EqualFold instead (SA6005)
table/tables/tables.go:484:2: this value of err is never used (SA4006)
tidb-server/main.go:627:20: tracingCfg.New is deprecated: use NewTracer() function  (SA1019)
types/convert_test.go:958:33: should use make(map[string]interface{}) instead (S1019)
types/datum.go:1662:17: func (*Datum).convergeType is unused (U1000)
types/json/binary.go:360:22: func BinaryJSON.marshalValueEntryTo is unused (U1000)
types/mydecimal.go:1784:3: this value of dec2 is never used (SA4006)
types/mydecimal.go:1787:3: this value of dec2 is never used (SA4006)
types/time.go:914:5: the address of a variable cannot be nil (SA4022)
types/time.go:929:5: the address of a variable cannot be nil (SA4022)
types/time.go:2255:5: var weekdayAbbrev is unused (U1000)
types/time.go:2631:6: func parseOrdinalNumbers is unused (U1000)
types/time_test.go:442:25: func (*testTimeSuite).getLocation is unused (U1000)
util/stmtsummary/statement_summary.go:472:4: unnecessary guard around map access (S1036)
util/stmtsummary/statement_summary_test.go:364:3: should use strings.EqualFold instead (SA6005)

We can check the output and see if we can refine the code.

good-first-issue statuhelp-wanted typenhancement

All 8 comments

After fix all issue list in the result, do we need add the staticcheck in Makefile and run it in CI automatically?

Related to #13456

@Deardrops We need to check the time consumption of this check. If we can accept then it's ok to add it to CI.

Let me fix a part of ddl package.

I am working on types, tidb-server, table, store, statistics.

I have a question about functions and values that have never been used, should we delete it or comment it?

@Rustin-Liu If the function is for future use, you should keep it, otherwise delete it.

Update:

-: could not load export data: no export data for "github.com/pingcap/tidb/ddl/failtest" (compile)
-: could not load export data: no export data for "github.com/pingcap/tidb/executor/seqtest" (compile)
bindinfo/bind_test.go:56:2: field ctx is unused (U1000)
bindinfo/handle.go:495:2: unnecessary nil check around range (S1031)
bindinfo/handle.go:537:20: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
bindinfo/handle.go:707:18: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (S1028)
bindinfo/handle.go:726:2: redundant return statement (S1023)
bindinfo/session_handle.go:91:2: unnecessary nil check around range (S1031)
config/config.go:156:9: assigning the result of this type assertion to a variable (switch v := v.(type)) could eliminate type assertions in switch cases (S1034)
config/config.go:158:27: could eliminate this type assertion
ddl/callback_test.go:93:15: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
ddl/column_test.go:633:103: argument handle is overwritten before first use (SA4009)
ddl/column_test.go:666:2: assignment to handle
ddl/db_integration_test.go:28:2: package "github.com/pingcap/parser/mysql" is being imported more than once (ST1019)
ddl/db_integration_test.go:29:2: other import of "github.com/pingcap/parser/mysql"
ddl/db_integration_test.go:665:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:668:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:672:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:676:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:680:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:684:2: this value of rs is never used (SA4006)
ddl/db_integration_test.go:688:2: this value of rs is never used (SA4006)
ddl/db_test.go:32:2: package "github.com/pingcap/parser/mysql" is being imported more than once (ST1019)
ddl/db_test.go:33:2: other import of "github.com/pingcap/parser/mysql"
ddl/db_test.go:841:24: func (testDBSuite4).testAlterLock is unused (U1000)
ddl/db_test.go:1768:3: should use a simple channel send/receive instead of select with a single case (S1000)
ddl/db_test.go:2718:2: this value of rs is never used (SA4006)
ddl/db_test.go:2720:2: this value of rs is never used (SA4006)
ddl/db_test.go:3821:13: sleeping for 50 nanoseconds is probably a bug; be explicit if it isn't (SA1004)
ddl/ddl.go:458:38: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
ddl/ddl_api.go:466:37: should use strings.EqualFold instead (SA6005)
ddl/ddl_api.go:785:5: Background is a pure function but its return value is ignored (SA4017)
ddl/ddl_api.go:2757:6: should omit comparison to bool constant, can be simplified to !containColumn (S1002)
ddl/ddl_api.go:3922:38: should use make([]string, 0) instead (S1019)
ddl/ddl_worker.go:457:23: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
ddl/ddl_worker.go:680:3: should use a simple channel send/receive instead of select with a single case (S1000)
ddl/util/syncer_test.go:110:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002)
ddl/util/syncer_test.go:119:4: call to T.Fatalf
ddl/util/syncer_test.go:233:55: grpc.Code is deprecated: use status.Code instead. (SA1019)
ddl/util/syncer_test.go:253:5: identical expressions on the left and right side of the '!=' operator (SA4000)
executor/admin_test.go:447:3: this value of err is never used (SA4006)
executor/admin_test.go:470:3: this value of err is never used (SA4006)
executor/admin_test.go:492:3: this value of err is never used (SA4006)
executor/aggfuncs/func_first_row.go:104:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:151:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:197:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:243:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:290:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:337:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:383:3: the surrounding loop is unconditionally terminated (SA4004)
executor/aggfuncs/func_first_row.go:432:3: the surrounding loop is unconditionally terminated (SA4004)
executor/analyze.go:247:2: field priority is unused (U1000)
executor/analyze.go:398:2: field priority is unused (U1000)
executor/analyze.go:608:6: should omit comparison to bool constant, can be simplified to *needRebuild (S1002)
executor/analyze.go:1023:27: should use make([][][]byte, len(idxInfo.Columns)) instead (S1019)
executor/analyze_test.go:245:10: this result of append is never used, except maybe in other appends (SA4010)
executor/batch_point_get.go:100:50: should use make(map[hack.MutableString]struct{}) instead (S1019)
executor/compiler.go:261:4: unnecessary nil check around range (S1031)
executor/compiler.go:262:5: should replace loop with dbLabels = append(dbLabels, dbs...) (S1011)
executor/compiler.go:270:4: unnecessary nil check around range (S1031)
executor/compiler.go:271:5: should replace loop with dbLabels = append(dbLabels, dbs...) (S1011)
executor/executor.go:1181:3: the surrounding loop is unconditionally terminated (SA4004)
executor/executor_test.go:2127:50: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/executor_test.go:2161:50: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/executor_test.go:2945:33: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/executor_test.go:2978:34: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/executor_test.go:3365:34: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/hash_table.go:247:26: func (
hashRowContainer).getJoinKeyFromChkRow is unused (U1000)
executor/index_lookup_hash_join.go:518:2: redundant return statement (S1023)
executor/join.go:330:7: should omit comparison to bool constant, can be simplified to !e.outerMatchedStatus[i].UnsafeIsSet(j) (S1002)
executor/join.go:367:7: should omit comparison to bool constant, can be simplified to !e.outerMatchedStatus[i].UnsafeIsSet(j) (S1002)
executor/load_data.go:243:4: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
executor/load_data.go:253:5: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
executor/seqtest/seq_executor_test.go:75:2: field ctx is unused (U1000)
executor/simple.go:782:5: this value of failedUsers is never used (SA4006)
executor/simple.go:782:19: this result of append is never used, except maybe in other appends (SA4010)
executor/sort.go:41:2: field keyExprs is unused (U1000)
executor/sort.go:42:2: field keyTypes is unused (U1000)
executor/table_readers_required_rows_test.go:94:31: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/table_readers_required_rows_test.go:95:31: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
executor/trace.go:51:2: field rootTrace is unused (U1000)
executor/union_scan.go:194:3: the surrounding loop is unconditionally terminated (SA4004)
executor/update_test.go:37:2: field ctx is unused (U1000)
expression/bench_test.go:1169:7: should merge variable declaration with assignment on next line (S1021)
expression/builtin_arithmetic.go:402:16: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic.go:407:16: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic_vec.go:375:17: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic_vec.go:379:17: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic_vec.go:399:17: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_arithmetic_vec.go:419:17: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_compare.go:2082:18: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_compare.go:2089:18: no value of type int64 is greater than math.MaxInt64 (SA4003)
expression/builtin_encryption_vec.go:452:16: argument should be pointer-like to avoid allocations (SA6002)
expression/builtin_like.go:119:22: from.memoizedRegexp.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. (SA1019)
expression/builtin_vectorized_test.go:782:2: this value of sel is never used (SA4006)
expression/chunk_executor.go:110:10: empty branch (SA9003)
expression/chunk_executor.go:110:13: HasUnsignedFlag is a pure function but its return value is ignored (SA4017)
expression/constant_propagation_test.go:37:21: func (testSuite).cleanEnv is unused (U1000)
expression/evaluator_test.go:54:2: field ctx is unused (U1000)
expression/expression.go:237:15: argument should be pointer-like to avoid allocations (SA6002)
expression/expression.go:250:16: argument should be pointer-like to avoid allocations (SA6002)
expression/integration_test.go:4209:32: func (
testIntegrationSuite).testTiDBIsOwnerFunc is unused (U1000)
expression/simple_rewriter.go:258:27: func (simpleRewriter).useCache is unused (U1000)
expression/util_test.go:39:25: func (
testUtilSuite).checkPanic is unused (U1000)
infoschema/tables.go:2128:3: should replace loop with finalRows = append(finalRows, result.rows...) (S1011)
infoschema/tables.go:2214:2: field rows is unused (U1000)
kv/memdb_buffer.go:31:2: field bufferLenLimit is unused (U1000)
kv/mock_test.go:84:36: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
meta/meta.go:823:2: const codeInvalidTableKey is unused (U1000)
meta/meta.go:823:2: only the first constant in this group has an explicit type (SA9004)
meta/meta.go:824:2: const codeInvalidDBKey is unused (U1000)
owner/fail_test.go:92:38: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead. (SA1019)
owner/fail_test.go:110:38: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead. (SA1019)
owner/manager.go:379:26: grpc.ErrClientConnClosing is deprecated: this error should not be relied upon by users; use the status code of Canceled instead. (SA1019)
planner/cascades/implementation_rules.go:79:2: should use 'return !(!prop.IsEmpty())' instead of 'if !prop.IsEmpty() { return false }; return true' (S1008)
planner/core/common_plans.go:754:3: this value of err is never used (SA4006)
planner/core/errors.go:22:2: only the first constant in this group has an explicit type (SA9004)
planner/core/exhaust_physical_plans.go:616:2: field chosenIndexInfo is unused (U1000)
planner/core/exhaust_physical_plans.go:1117:33: should use make([]types.Datum, pointLength + 1) instead (S1019)
planner/core/exhaust_physical_plans.go:1118:33: should use make([]types.Datum, pointLength + 1) instead (S1019)
planner/core/exhaust_physical_plans.go:1122:33: should use make([]types.Datum, pointLength) instead (S1019)
planner/core/exhaust_physical_plans.go:1123:33: should use make([]types.Datum, pointLength) instead (S1019)
planner/core/find_best_task.go:267:5: should omit comparison to bool constant, can be simplified to !l (S1002)
planner/core/logical_plans.go:235:2: field calculateGenCols is unused (U1000)
planner/core/logical_plans.go:473:3: empty branch (SA9003)
planner/core/physical_plans.go:318:2: field outerSchema is unused (U1000)
planner/core/planbuilder.go:272:29: func (handleColHelper).appendColToLastMap is unused (U1000)
planner/core/point_get_plan.go:51:2: field expr is unused (U1000)
planner/core/point_get_plan.go:52:2: field ctx is unused (U1000)
planner/core/rule_join_reorder_dp.go:285:31: func (
joinReorderDPSolver).newJoinWithConds is unused (U1000)
planner/core/rule_partition_processor.go:131:22: should omit comparison to bool constant, can be simplified to !ret (S1002)
planner/core/rule_partition_processor.go:210:21: should omit comparison to bool constant, can be simplified to !ret (S1002)
planner/core/stats.go:439:18: don't use Yoda conditions (ST1017)
planner/core/task.go:909:2: should use 'return len(remained) <= 0' instead of 'if len(remained) > 0 { return false }; return true' (S1008)
planner/memo/group_test.go:131:2: field cost is unused (U1000)
plugin/conn_ip_example/conn_ip_example.go:48:2: redundant return statement (S1023)
plugin/conn_ip_example/conn_ip_example_test.go:25:6: func LoadRunShutdownPluginExample is unused (U1000)
privilege/privileges/cache.go:150:2: should replace loop with queue = append(queue, activeRoles...) (S1011)
privilege/privileges/cache_test.go:31:2: field dbName is unused (U1000)
server/conn_test.go:348:26: func (ConnTestSuite).testGetSessionVarsWaitTimeout is unused (U1000)
server/http_handler.go:563:2: field first is unused (U1000)
server/http_handler.go:564:2: field last is unused (U1000)
server/http_handler.go:565:2: field region is unused (U1000)
server/http_handler.go:1181:6: type hotRegion is unused (U1000)
server/http_handler.go:1185:6: type hotRegions is unused (U1000)
server/http_handler_test.go:227:2: this value of resp is never used (SA4006)
server/http_handler_test.go:691:23: printf-style function with dynamic format string and no further arguments should use print-style function instead (SA1006)
server/http_status.go:258:33: should use httpRouterPage.Bytes() instead of []byte(httpRouterPage.String()) (S1030)
server/server_test.go:119:20: func (
DBTest).fail is unused (U1000)
server/statistics_handler_test.go:72:31: func (testDumpStatsSuite).stopServer is unused (U1000)
server/statistics_handler_test.go:238:31: func (
testDumpStatsSuite).clearData is unused (U1000)
session/session_test.go:1766:2: field checkLeak is unused (U1000)
session/session_test.go:1961:66: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
session/session_test.go:2396:49: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
session/session_test.go:2402:48: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
session/txn.go:469:2: redundant return statement (S1023)
sessionctx/binloginfo/binloginfo_test.go:101:9: grpc.WithDialer is deprecated: use WithContextDialer instead. Will be supported throughout 1.x. (SA1019)
sessionctx/variable/statusvar.go:101:2: tls.VersionSSL30 is deprecated: SSLv3 is cryptographically broken, and will be removed in Go 1.14. See golang.org/issue/32716. (SA1019)
statistics/feedback.go:243:2: redundant return statement (S1023)
statistics/handle/update.go:286:6: should omit comparison to bool constant, can be simplified to !dumpMode (S1002)
statistics/handle/update.go:720:2: redundant return statement (S1023)
statistics/histogram.go:367:2: redundant return statement (S1023)
statistics/histogram.go:627:2: should replace loop with newHist.Buckets = append(newHist.Buckets, hg.Buckets...) (S1011)
store/mockstore/mocktikv/cluster.go:645:2: field tokenCount is unused (U1000)
store/mockstore/mocktikv/cluster_test.go:37:2: field store is unused (U1000)
store/mockstore/mocktikv/mvcc.go:243:6: type rawEntry is unused (U1000)
store/tikv/2pc.go:820:3: the surrounding loop is unconditionally terminated (SA4004)
store/tikv/client_batch.go:494:2: redundant return statement (S1023)
store/tikv/gcworker/gc_worker.go:182:5: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
store/tikv/lock_resolver.go:361:2: redundant return statement (S1023)
store/tikv/oracle/oracles/export_test.go:36:6: func ClearOracleHook is unused (U1000)
store/tikv/range_task.go:275:4: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
store/tikv/region_cache.go:432:23: func (RegionCache).loadAndInsertRegion is unused (U1000)
store/tikv/region_cache.go:1153:2: redundant return statement (S1023)
store/tikv/region_cache.go:1307:2: redundant return statement (S1023)
store/tikv/region_request.go:220:5: grpc.Code is deprecated: use status.Code instead. (SA1019)
store/tikv/snapshot_test.go:132:49: should not use built-in type string as key for value; define your own type to avoid collisions (SA1029)
store/tikv/split_region.go:35:2: should use 'return bytes.Equal(key, regionStartKey)' instead of 'if bytes.Equal(key, regionStartKey) { return true }; return false' (S1008)
store/tikv/store_test.go:111:24: func (
mockPDClient).enable is unused (U1000)
structure/structure.go:23:2: only the first constant in this group has an explicit type (SA9004)
table/column.go:263:5: should use strings.EqualFold instead (SA6005)
table/column.go:398:74: should use strings.EqualFold instead (SA6005)
table/tables/tables.go:484:2: this value of err is never used (SA4006)
tidb-server/main.go:627:20: tracingCfg.New is deprecated: use NewTracer() function (SA1019)
types/convert_test.go:958:33: should use make(map[string]interface{}) instead (S1019)
types/datum.go:1662:17: func (Datum).convergeType is unused (U1000)
types/json/binary.go:360:22: func BinaryJSON.marshalValueEntryTo is unused (U1000)
types/mydecimal.go:1784:3: this value of dec2 is never used (SA4006)
types/mydecimal.go:1787:3: this value of dec2 is never used (SA4006)
types/time.go:914:5: the address of a variable cannot be nil (SA4022)
types/time.go:929:5: the address of a variable cannot be nil (SA4022)
types/time.go:2255:5: var weekdayAbbrev is unused (U1000)
types/time.go:2631:6: func parseOrdinalNumbers is unused (U1000)
types/time_test.go:442:25: func (
testTimeSuite).getLocation is unused (U1000)
util/stmtsummary/statement_summary.go:472:4: unnecessary guard around map access (S1036)
util/stmtsummary/statement_summary_test.go:364:3: should use strings.EqualFold instead (SA6005)

Was this page helpful?
0 / 5 - 0 ratings