From 8c33190dd72a653719ddca22d0cbc3e7bcd4f4dc Mon Sep 17 00:00:00 2001 From: Arenatlx <314806019@qq.com> Date: Wed, 23 Jun 2021 11:19:22 +0800 Subject: [PATCH] linter: fix linter error when `make dev` locally (#25661) --- ddl/column_type_change_test.go | 2 +- executor/builder.go | 4 ++-- go.mod | 1 + planner/core/logical_plan_builder.go | 1 - planner/core/preprocess.go | 3 +++ server/tidb_test.go | 15 +++++++++------ structure/type.go | 3 +++ 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ddl/column_type_change_test.go b/ddl/column_type_change_test.go index 53bec672c52e2..273522c00f874 100644 --- a/ddl/column_type_change_test.go +++ b/ddl/column_type_change_test.go @@ -1764,7 +1764,7 @@ func (s *testColumnTypeChangeSuite) TestChangingColOriginDefaultValueAfterAddCol tk1 := testkit.NewTestKit(c, s.store) tk1.MustExec("use test") - tk.MustExec(fmt.Sprintf("set time_zone = 'UTC'")) + tk.MustExec("set time_zone = 'UTC'") tk.MustExec("drop table if exists t") tk.MustExec("create table t(a VARCHAR(31) NULL DEFAULT 'wwrzfwzb01j6ddj', b DECIMAL(12,0) NULL DEFAULT '-729850476163')") tk.MustExec("ALTER TABLE t ADD COLUMN x CHAR(218) NULL DEFAULT 'lkittuae'") diff --git a/executor/builder.go b/executor/builder.go index b3fa9e5c7c084..74a1fa49b5dad 100644 --- a/executor/builder.go +++ b/executor/builder.go @@ -2791,7 +2791,7 @@ func (b *executorBuilder) buildTableReader(v *plannercore.PhysicalTableReader) E if !b.ctx.GetSessionVars().UseDynamicPartitionPrune() { return ret } - // When isPartition is set, it means the union rewriting is done, so a partition reader is prefered. + // When isPartition is set, it means the union rewriting is done, so a partition reader is preferred. if ok, _ := ts.IsPartition(); ok { return ret } @@ -3020,7 +3020,7 @@ func (b *executorBuilder) buildIndexReader(v *plannercore.PhysicalIndexReader) E if !b.ctx.GetSessionVars().UseDynamicPartitionPrune() { return ret } - // When isPartition is set, it means the union rewriting is done, so a partition reader is prefered. + // When isPartition is set, it means the union rewriting is done, so a partition reader is preferred. if ok, _ := is.IsPartition(); ok { return ret } diff --git a/go.mod b/go.mod index 4ab4839545a79..e07aaa5e1afd3 100644 --- a/go.mod +++ b/go.mod @@ -74,6 +74,7 @@ require ( golang.org/x/tools v0.1.0 google.golang.org/grpc v1.27.1 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + honnef.co/go/tools v0.2.0 // indirect modernc.org/mathutil v1.2.2 // indirect sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 diff --git a/planner/core/logical_plan_builder.go b/planner/core/logical_plan_builder.go index 1be83d87786ab..c0ffdc9921edb 100644 --- a/planner/core/logical_plan_builder.go +++ b/planner/core/logical_plan_builder.go @@ -3634,7 +3634,6 @@ func (ds *DataSource) addExtraPIDColumn(info *extraPIDInfo) { info.Columns = append(info.Columns, pidCol) info.TblIDs = append(info.TblIDs, ds.TableInfo().ID) - return } var ( diff --git a/planner/core/preprocess.go b/planner/core/preprocess.go index 463683b9ad9bb..26ebfd5c3e125 100644 --- a/planner/core/preprocess.go +++ b/planner/core/preprocess.go @@ -127,6 +127,9 @@ const ( inSequenceFunction ) +// Make linter happy. +var _ = PreprocessorReturn{}.initedLastSnapshotTS + // PreprocessorReturn is used to retain information obtained in the preprocessor. type PreprocessorReturn struct { initedLastSnapshotTS bool diff --git a/server/tidb_test.go b/server/tidb_test.go index 5d1d6418e43a4..3ea82cc4f621e 100644 --- a/server/tidb_test.go +++ b/server/tidb_test.go @@ -1495,7 +1495,7 @@ func (ts *tidbTestTopSQLSuite) TestTopSQLAgent(c *C) { cancel() // cancel case 1 // case 2: agent hangs for a while - cancel = runWorkload(0, 10) + cancel2 := runWorkload(0, 10) // empty agent address, should not collect records dbt.mustExec("set @@global.tidb_top_sql_max_statement_count=5;") dbt.mustExec("set @@tidb_top_sql_agent_address='';") @@ -1508,13 +1508,15 @@ func (ts *tidbTestTopSQLSuite) TestTopSQLAgent(c *C) { // agent server hangs for a while agentServer.HangFromNow(time.Second * 6) // run another set of SQL queries - cancel() - cancel = runWorkload(11, 20) + cancel2() + + cancel3 := runWorkload(11, 20) agentServer.WaitCollectCnt(1, time.Second*8) checkFn(5) + cancel3() // case 3: agent restart - cancel = runWorkload(0, 10) + cancel4 := runWorkload(0, 10) // empty agent address, should not collect records dbt.mustExec("set @@tidb_top_sql_agent_address='';") agentServer.WaitCollectCnt(1, time.Second*4) @@ -1524,9 +1526,9 @@ func (ts *tidbTestTopSQLSuite) TestTopSQLAgent(c *C) { agentServer.WaitCollectCnt(1, time.Second*8) checkFn(5) // run another set of SQL queries - cancel() + cancel4() - cancel = runWorkload(11, 20) + cancel5 := runWorkload(11, 20) // agent server shutdown agentServer.Stop() // agent server restart @@ -1536,6 +1538,7 @@ func (ts *tidbTestTopSQLSuite) TestTopSQLAgent(c *C) { // check result agentServer.WaitCollectCnt(2, time.Second*8) checkFn(5) + cancel5() } func (ts *tidbTestTopSQLSuite) loopExec(ctx context.Context, c *C, fn func(db *sql.DB)) { diff --git a/structure/type.go b/structure/type.go index a79ef76350130..77b3b04a4869a 100644 --- a/structure/type.go +++ b/structure/type.go @@ -39,6 +39,9 @@ const ( ListData TypeFlag = 'l' ) +// Make linter happy, since encodeHashMetaKey is unused in this repo. +var _ = (&TxStructure{}).encodeHashMetaKey + func (t *TxStructure) encodeStringDataKey(key []byte) kv.Key { // for codec Encode, we may add extra bytes data, so here and following encode // we will use extra length like 4 for a little optimization.