Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: enable all gosimples #35762

Merged
merged 5 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,6 @@ func (local *local) ResolveDuplicateRows(ctx context.Context, tbl table.Table, t
logger.Warn("[resolve-dupe] skipping resolution due to selected algorithm. this table will become inconsistent!", zap.Stringer("algorithm", algorithm))
return nil
case config.DupeResAlgRemove:
break
default:
panic(fmt.Sprintf("[resolve-dupe] unknown resolution algorithm %v", algorithm))
}
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ func (cfg *Config) CheckAndAdjustSecurity() error {
return common.ErrInvalidConfig.GenWithStack("cannot set `tidb.tls` to 'cluster' without a [security] section")
}
case "false", "skip-verify", "preferred":
break
return nil
default:
return common.ErrInvalidConfig.GenWithStack("unsupported `tidb.tls` config %s", cfg.TiDB.TLS)
}
Expand Down
1 change: 0 additions & 1 deletion br/pkg/lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ func (rc *Controller) saveStatusCheckpoint(ctx context.Context, tableName string

switch {
case err == nil:
break
case utils.MessageIsRetryableStorageError(err.Error()), common.IsContextCanceledError(err):
// recoverable error, should not be recorded in checkpoint
// which will prevent lightning from automatically recovering
Expand Down
24 changes: 24 additions & 0 deletions build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,41 @@ load("@io_bazel_rules_go//go:def.bzl", "nogo")
load("//build/linter/staticcheck:def.bzl", "staticcheck_analyzers")

STATICHECK_ANALYZERS = [
"S1000",
"S1001",
"S1002",
"S1003",
"S1004",
"S1005",
"S1006",
"S1007",
"S1008",
"S1009",
"S1010",
"S1011",
"S1012",
"S1016",
"S1017",
"S1018",
"S1019",
"S1020",
"S1021",
"S1023",
"S1024",
"S1025",
"S1028",
"S1029",
"S1030",
"S1031",
"S1032",
"S1033",
"S1034",
"S1035",
"S1036",
"S1037",
"S1038",
"S1039",
"S1040",
"SA2000",
"SA2001",
"SA2003",
Expand Down
182 changes: 182 additions & 0 deletions build/nogo_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,60 @@
"parser/digester_test.go": "ignore code"
}
},
"S1000": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1001": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1002": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1003": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1004": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1005": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1006": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1007": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1008": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1009": {
"exclude_files": {
"/external/": "no need to vet third party code",
Expand All @@ -260,12 +296,54 @@
".*_generated\\.go$": "ignore generated code"
}
},
"S1011": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1012": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1013": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1014": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1015": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1016": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1017": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1018": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1019": {
"exclude_files": {
"/external/": "no need to vet third party code",
Expand All @@ -286,18 +364,122 @@
"tools/check/ut.go": "ignore code"
}
},
"S1022": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1023": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code",
"parser/parser.go": "ignore code"
}
},
"S1024": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1025": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1026": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1027": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1028": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1029": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1030": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1031": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1032": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1033": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1034": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1035": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1036": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1037": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1038": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1039": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"S1040": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code",
"parser/parser.go": "ignore generated code"
}
},
"SA2000": {
"exclude_files": {
"/external/": "no need to vet third party code",
Expand Down
3 changes: 0 additions & 3 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4706,7 +4706,6 @@ func checkAutoRandom(tableInfo *model.TableInfo, originCol *table.Column, specNe
}
switch {
case oldRandBits == newRandBits:
break
case oldRandBits < newRandBits:
addingAutoRandom := oldRandBits == 0
if addingAutoRandom {
Expand Down Expand Up @@ -6341,7 +6340,6 @@ func validateCommentLength(vars *variable.SessionVars, name string, comment *str
case dbterror.ErrTooLongTableComment:
maxLen *= 2
case dbterror.ErrTooLongFieldComment, dbterror.ErrTooLongIndexComment, dbterror.ErrTooLongTablePartitionComment:
break
default:
// add more types of terror.Error if need
}
Expand Down Expand Up @@ -6405,7 +6403,6 @@ func checkColumnsTypeAndValuesMatch(ctx sessionctx.Context, meta *model.TableInf
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeDuration:
switch vkind {
case types.KindString, types.KindBytes:
break
default:
return dbterror.ErrWrongTypeColumnValue.GenWithStackByArgs()
}
Expand Down
1 change: 0 additions & 1 deletion executor/brie.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ func (b *executorBuilder) buildBRIE(s *ast.BRIEStmt, schema *expression.Schema)
return nil
}
default:
break
}

if tidbCfg.Store != "tikv" {
Expand Down
18 changes: 9 additions & 9 deletions executor/merge_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,22 +785,22 @@ func TestVectorizedMergeJoin(t *testing.T) {
)).Check(testkit.Rows(
fmt.Sprintf(`MergeJoin 4150.01 root inner join, left key:test.%s.a, right key:test.%s.a`, t1, t2),
fmt.Sprintf(`├─Sort(Build) 3320.01 root test.%s.a`, t2),
fmt.Sprintf(`│ └─TableReader 3320.01 root data:Selection`),
`│ └─TableReader 3320.01 root data:Selection`,
fmt.Sprintf(`│ └─Selection 3320.01 cop[tikv] lt(test.%s.b, 5), not(isnull(test.%s.a))`, t2, t2),
fmt.Sprintf(`│ └─TableFullScan 10000.00 cop[tikv] table:%s keep order:false, stats:pseudo`, t2),
fmt.Sprintf(`└─Sort(Probe) 3330.00 root test.%s.a`, t1),
fmt.Sprintf(` └─TableReader 3330.00 root data:Selection`),
` └─TableReader 3330.00 root data:Selection`,
fmt.Sprintf(` └─Selection 3330.00 cop[tikv] gt(test.%s.b, 5), not(isnull(test.%s.a))`, t1, t1),
fmt.Sprintf(` └─TableFullScan 10000.00 cop[tikv] table:%s keep order:false, stats:pseudo`, t1),
))
tk.MustQuery(fmt.Sprintf("explain format = 'brief' select /*+ TIDB_HJ(%s, %s) */ * from %s, %s where %s.a=%s.a and %s.b>5 and %s.b<5",
t1, t2, t1, t2, t1, t2, t1, t2,
)).Check(testkit.Rows(
fmt.Sprintf(`HashJoin 4150.01 root inner join, equal:[eq(test.%s.a, test.%s.a)]`, t1, t2),
fmt.Sprintf(`├─TableReader(Build) 3320.01 root data:Selection`),
`├─TableReader(Build) 3320.01 root data:Selection`,
fmt.Sprintf(`│ └─Selection 3320.01 cop[tikv] lt(test.%s.b, 5), not(isnull(test.%s.a))`, t2, t2),
fmt.Sprintf(`│ └─TableFullScan 10000.00 cop[tikv] table:%s keep order:false, stats:pseudo`, t2),
fmt.Sprintf(`└─TableReader(Probe) 3330.00 root data:Selection`),
`└─TableReader(Probe) 3330.00 root data:Selection`,
fmt.Sprintf(` └─Selection 3330.00 cop[tikv] gt(test.%s.b, 5), not(isnull(test.%s.a))`, t1, t1),
fmt.Sprintf(` └─TableFullScan 10000.00 cop[tikv] table:%s keep order:false, stats:pseudo`, t1),
))
Expand Down Expand Up @@ -903,25 +903,25 @@ func TestVectorizedShuffleMergeJoin(t *testing.T) {
tk.MustQuery(fmt.Sprintf("explain format = 'brief' select /*+ TIDB_SMJ(%s, %s) */ * from %s, %s where %s.a=%s.a and %s.b>5 and %s.b<5",
t1, t2, t1, t2, t1, t2, t1, t2,
)).Check(testkit.Rows(
fmt.Sprintf(`Shuffle 4150.01 root execution info: concurrency:4, data sources:[TableReader TableReader]`),
`Shuffle 4150.01 root execution info: concurrency:4, data sources:[TableReader TableReader]`,
fmt.Sprintf(`└─MergeJoin 4150.01 root inner join, left key:test.%s.a, right key:test.%s.a`, t1, t2),
fmt.Sprintf(` ├─Sort(Build) 3320.01 root test.%s.a`, t2),
fmt.Sprintf(` │ └─TableReader 3320.01 root data:Selection`),
` │ └─TableReader 3320.01 root data:Selection`,
fmt.Sprintf(` │ └─Selection 3320.01 cop[tikv] lt(test.%s.b, 5), not(isnull(test.%s.a))`, t2, t2),
fmt.Sprintf(` │ └─TableFullScan 10000.00 cop[tikv] table:%s keep order:false, stats:pseudo`, t2),
fmt.Sprintf(` └─Sort(Probe) 3330.00 root test.%s.a`, t1),
fmt.Sprintf(` └─TableReader 3330.00 root data:Selection`),
` └─TableReader 3330.00 root data:Selection`,
fmt.Sprintf(` └─Selection 3330.00 cop[tikv] gt(test.%s.b, 5), not(isnull(test.%s.a))`, t1, t1),
fmt.Sprintf(` └─TableFullScan 10000.00 cop[tikv] table:%s keep order:false, stats:pseudo`, t1),
))
tk.MustQuery(fmt.Sprintf("explain format = 'brief' select /*+ TIDB_HJ(%s, %s) */ * from %s, %s where %s.a=%s.a and %s.b>5 and %s.b<5",
t1, t2, t1, t2, t1, t2, t1, t2,
)).Check(testkit.Rows(
fmt.Sprintf(`HashJoin 4150.01 root inner join, equal:[eq(test.%s.a, test.%s.a)]`, t1, t2),
fmt.Sprintf(`├─TableReader(Build) 3320.01 root data:Selection`),
`├─TableReader(Build) 3320.01 root data:Selection`,
fmt.Sprintf(`│ └─Selection 3320.01 cop[tikv] lt(test.%s.b, 5), not(isnull(test.%s.a))`, t2, t2),
fmt.Sprintf(`│ └─TableFullScan 10000.00 cop[tikv] table:%s keep order:false, stats:pseudo`, t2),
fmt.Sprintf(`└─TableReader(Probe) 3330.00 root data:Selection`),
`└─TableReader(Probe) 3330.00 root data:Selection`,
fmt.Sprintf(` └─Selection 3330.00 cop[tikv] gt(test.%s.b, 5), not(isnull(test.%s.a))`, t1, t1),
fmt.Sprintf(` └─TableFullScan 10000.00 cop[tikv] table:%s keep order:false, stats:pseudo`, t1),
))
Expand Down
Loading