Skip to content

Commit

Permalink
*: update the golangci-lint and fix all lint errors (pingcap#25912)
Browse files Browse the repository at this point in the history
  • Loading branch information
JmPotato authored Jul 5, 2021
1 parent 2e00c6a commit cb06e11
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ tools/bin/errdoc-gen: tools/check/go.mod
$(GO) build -o ../bin/errdoc-gen github.com/pingcap/errors/errdoc-gen

tools/bin/golangci-lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ./tools/bin v1.29.0
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ./tools/bin v1.41.1

# Usage:
#
Expand Down
2 changes: 1 addition & 1 deletion ddl/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ func BuildElements(changingCol *model.ColumnInfo, changingIdxs []*model.IndexInf

func (w *worker) updatePhysicalTableRow(t table.PhysicalTable, oldColInfo, colInfo *model.ColumnInfo, reorgInfo *reorgInfo) error {
logutil.BgLogger().Info("[ddl] start to update table row", zap.String("job", reorgInfo.Job.String()), zap.String("reorgInfo", reorgInfo.String()))
return w.writePhysicalTableRecord(t.(table.PhysicalTable), typeUpdateColumnWorker, nil, oldColInfo, colInfo, reorgInfo)
return w.writePhysicalTableRecord(t, typeUpdateColumnWorker, nil, oldColInfo, colInfo, reorgInfo)
}

// TestReorgGoroutineRunning is only used in test to indicate the reorg goroutine has been started.
Expand Down
2 changes: 1 addition & 1 deletion ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2992,7 +2992,7 @@ func getPartitionTableRecordsNum(c *C, ctx sessionctx.Context, tbl table.Partiti
info := tbl.Meta().GetPartitionInfo()
for _, def := range info.Definitions {
pid := def.ID
partition := tbl.(table.PartitionedTable).GetPartition(pid)
partition := tbl.GetPartition(pid)
c.Assert(ctx.NewTxn(context.Background()), IsNil)
err := tables.IterRecords(partition, ctx, partition.Cols(),
func(_ kv.Handle, data []types.Datum, cols []*table.Column) (bool, error) {
Expand Down
4 changes: 2 additions & 2 deletions ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ func (w *addIndexWorker) BackfillDataInTxn(handleRange reorgBackfillTask) (taskC

func (w *worker) addPhysicalTableIndex(t table.PhysicalTable, indexInfo *model.IndexInfo, reorgInfo *reorgInfo) error {
logutil.BgLogger().Info("[ddl] start to add table index", zap.String("job", reorgInfo.Job.String()), zap.String("reorgInfo", reorgInfo.String()))
return w.writePhysicalTableRecord(t.(table.PhysicalTable), typeAddIndexWorker, indexInfo, nil, nil, reorgInfo)
return w.writePhysicalTableRecord(t, typeAddIndexWorker, indexInfo, nil, nil, reorgInfo)
}

// addTableIndex handles the add index reorganization state for a table.
Expand Down Expand Up @@ -1358,7 +1358,7 @@ func (w *cleanUpIndexWorker) BackfillDataInTxn(handleRange reorgBackfillTask) (t
// cleanupPhysicalTableIndex handles the drop partition reorganization state for a non-partitioned table or a partition.
func (w *worker) cleanupPhysicalTableIndex(t table.PhysicalTable, reorgInfo *reorgInfo) error {
logutil.BgLogger().Info("[ddl] start to clean up index", zap.String("job", reorgInfo.Job.String()), zap.String("reorgInfo", reorgInfo.String()))
return w.writePhysicalTableRecord(t.(table.PhysicalTable), typeCleanUpIndexWorker, nil, nil, nil, reorgInfo)
return w.writePhysicalTableRecord(t, typeCleanUpIndexWorker, nil, nil, nil, reorgInfo)
}

// cleanupGlobalIndex handles the drop partition reorganization state to clean up index entries of partitions.
Expand Down
5 changes: 1 addition & 4 deletions executor/slow_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,7 @@ func (e *slowQueryRetriever) parseLog(ctx context.Context, sctx sessionctx.Conte
} else {
fieldValues := strings.Split(line, " ")
for i := 0; i < len(fieldValues)-1; i += 2 {
field := fieldValues[i]
if strings.HasSuffix(field, ":") {
field = field[:len(field)-1]
}
field := strings.TrimSuffix(fieldValues[i], ":")
valid, err := st.setFieldValue(tz, field, fieldValues[i+1], fileLine, e.checker)
if err != nil {
sctx.GetSessionVars().StmtCtx.AppendWarning(err)
Expand Down
2 changes: 1 addition & 1 deletion planner/core/common_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ func (e *Explain) prepareTaskDot(p PhysicalPlan, taskTp string, buffer *bytes.Bu
buffer.WriteString("}\n")

for _, cop := range copTasks {
e.prepareTaskDot(cop.(PhysicalPlan), "cop", buffer)
e.prepareTaskDot(cop, "cop", buffer)
}

for i := range pipelines {
Expand Down
4 changes: 2 additions & 2 deletions planner/core/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (pn *planEncoder) encodePlan(p Plan, isRoot bool, store kv.StoreType, depth
if pn.encodedPlans[child.ID()] {
continue
}
pn.encodePlan(child.(PhysicalPlan), isRoot, store, depth)
pn.encodePlan(child, isRoot, store, depth)
}
switch copPlan := selectPlan.(type) {
case *PhysicalTableReader:
Expand Down Expand Up @@ -184,7 +184,7 @@ func (d *planDigester) normalizePlan(p PhysicalPlan, isRoot bool, store kv.Store
if d.encodedPlans[child.ID()] {
continue
}
d.normalizePlan(child.(PhysicalPlan), isRoot, store, depth)
d.normalizePlan(child, isRoot, store, depth)
}
switch x := p.(type) {
case *PhysicalTableReader:
Expand Down
2 changes: 1 addition & 1 deletion planner/core/logical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ func (s *testPlanSuite) TestUnion(c *C) {
}
c.Assert(err, IsNil)
p := plan.(LogicalPlan)
p, err = logicalOptimize(ctx, builder.optFlag, p.(LogicalPlan))
p, err = logicalOptimize(ctx, builder.optFlag, p)
s.testData.OnRecord(func() {
output[i].Best = ToString(p)
})
Expand Down
8 changes: 4 additions & 4 deletions server/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ func (ts *HTTPHandlerTestSuite) TestGetSchema(c *C) {
c.Assert(err, IsNil)
c.Assert(dbtbl.TableInfo.Name.L, Equals, "user")
c.Assert(dbtbl.DBInfo.Name.L, Equals, "mysql")
se, err := session.CreateSession(ts.store.(kv.Storage))
se, err := session.CreateSession(ts.store)
c.Assert(err, IsNil)
c.Assert(dbtbl.SchemaVersion, Equals, domain.GetDomain(se.(sessionctx.Context)).InfoSchema().SchemaMetaVersion())

Expand Down Expand Up @@ -1148,7 +1148,7 @@ func (ts *HTTPHandlerTestSerialSuite) TestPostSettings(c *C) {
ts.startServer(c)
ts.prepareData(c)
defer ts.stopServer(c)
se, err := session.CreateSession(ts.store.(kv.Storage))
se, err := session.CreateSession(ts.store)
c.Assert(err, IsNil)

form := make(url.Values)
Expand Down Expand Up @@ -1298,7 +1298,7 @@ func (ts *HTTPHandlerTestSuite) TestServerInfo(c *C) {
c.Assert(info.GitHash, Equals, versioninfo.TiDBGitHash)

store := ts.server.newTikvHandlerTool().Store.(kv.Storage)
do, err := session.GetDomain(store.(kv.Storage))
do, err := session.GetDomain(store)
c.Assert(err, IsNil)
ddl := do.DDL()
c.Assert(info.ID, Equals, ddl.GetID())
Expand All @@ -1321,7 +1321,7 @@ func (ts *HTTPHandlerTestSerialSuite) TestAllServerInfo(c *C) {
c.Assert(clusterInfo.ServersNum, Equals, 1)

store := ts.server.newTikvHandlerTool().Store.(kv.Storage)
do, err := session.GetDomain(store.(kv.Storage))
do, err := session.GetDomain(store)
c.Assert(err, IsNil)
ddl := do.DDL()
c.Assert(clusterInfo.OwnerID, Equals, ddl.GetID())
Expand Down
4 changes: 2 additions & 2 deletions types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -3004,7 +3004,6 @@ func parseSep(input string) (string, parseState) {

func time12Hour(t *CoreTime, input string, ctx map[string]int) (string, bool) {
tryParse := func(input string) (string, parseState) {
state := parseStateNormal
// hh:mm:ss AM
/// Note that we should update `t` as soon as possible, or we
/// can not get correct result for incomplete input like "12:13"
Expand All @@ -3023,6 +3022,7 @@ func time12Hour(t *CoreTime, input string, ctx map[string]int) (string, bool) {
t.setHour(uint8(hour))

// ':'
var state parseState
if input, state = parseSep(input[length:]); state != parseStateNormal {
return input, state
}
Expand Down Expand Up @@ -3082,7 +3082,6 @@ func time24Hour(t *CoreTime, input string, ctx map[string]int) (string, bool) {
/// Note that we should update `t` as soon as possible, or we
/// can not get correct result for incomplete input like "12:13"
/// that is shorter than "hh:mm:ss"
state := parseStateNormal
result := oneOrTwoDigitRegex.FindString(input) // 0..23
length := len(result)
hour, succ := parseDigits(input, length)
Expand All @@ -3092,6 +3091,7 @@ func time24Hour(t *CoreTime, input string, ctx map[string]int) (string, bool) {
t.setHour(uint8(hour))

// ':'
var state parseState
if input, state = parseSep(input[length:]); state != parseStateNormal {
return input, state
}
Expand Down

0 comments on commit cb06e11

Please sign in to comment.