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 ineffassign #35670

Merged
merged 2 commits into from
Jun 23, 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
8 changes: 8 additions & 0 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,14 @@ def go_deps():
sum = "h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=",
version = "v0.0.0-20181017120253-0766667cb4d1",
)
go_repository(
name = "com_github_gordonklaus_ineffassign",
build_file_proto_mode = "disable",
importpath = "github.com/gordonklaus/ineffassign",
sum = "h1:PVRE9d4AQKmbelZ7emNig1+NT27DUmKZn5qXxfio54U=",
version = "v0.0.0-20210914165742-4cc7213b9bc8",
)

go_repository(
name = "com_github_gorilla_handlers",
build_file_proto_mode = "disable_global",
Expand Down
1 change: 1 addition & 0 deletions build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ nogo(
"@org_golang_x_tools//go/analysis/passes/unsafeptr:go_default_library",
"@org_golang_x_tools//go/analysis/passes/unusedresult:go_default_library",
"//build/linter/durationcheck:durationcheck",
"//build/linter/ineffassign:ineffassign",
"//build/linter/prealloc:prealloc",
] + staticcheck_analyzers(STATICHECK_ANALYZERS),
)
9 changes: 9 additions & 0 deletions build/linter/ineffassign/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "ineffassign",
srcs = ["analyzer.go"],
importpath = "github.com/pingcap/tidb/build/linter/ineffassign",
visibility = ["//visibility:public"],
deps = ["@com_github_gordonklaus_ineffassign//pkg/ineffassign"],
)
20 changes: 20 additions & 0 deletions build/linter/ineffassign/analyzer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ineffassign

import "github.com/gordonklaus/ineffassign/pkg/ineffassign"

// Analyzer is the analyzer struct of ineffassign.
var Analyzer = ineffassign.Analyzer
6 changes: 6 additions & 0 deletions build/nogo_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
".*_generated\\.go$": "ignore generated code"
}
},
"ineffassign": {
"exclude_files": {
"/external/": "no need to vet third party code",
".*_generated\\.go$": "ignore generated code"
}
},
"inspect": {
"exclude_files": {
"/external/": "no need to vet third party code",
Expand Down
2 changes: 1 addition & 1 deletion ddl/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func (w *worker) onRecoverTable(d *ddlCtx, t *meta.Meta, job *model.Job) (ver in

failpoint.Inject("mockRecoverTableCommitErr", func(val failpoint.Value) {
if val.(bool) && atomic.CompareAndSwapUint32(&mockRecoverTableCommitErrOnce, 0, 1) {
err = failpoint.Enable(`tikvclient/mockCommitErrorOpt`, "return(true)")
_ = failpoint.Enable(`tikvclient/mockCommitErrorOpt`, "return(true)")
}
})

Expand Down
1 change: 1 addition & 0 deletions executor/splittest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go_test(
shard_count = 5,
deps = [
"//ddl",
"//domain/infosync",
"//errno",
"//parser/mysql",
"//parser/terror",
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ require (
require (
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1581
github.com/charithe/durationcheck v0.0.9
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8
honnef.co/go/tools v0.0.1-2020.1.4
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pf
github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU=
github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 h1:PVRE9d4AQKmbelZ7emNig1+NT27DUmKZn5qXxfio54U=
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
Expand Down
6 changes: 3 additions & 3 deletions parser/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,16 @@ func TestFeatureIDsComment(t *testing.T) {
requires.Equal(t, identifier, tok)
requires.Equal(t, "auto_random", lit)
requires.Equal(t, Pos{1, 16, 16}, pos)
tok, pos, _ = l.scan()
tok, _, _ = l.scan()
requires.Equal(t, int('('), tok)
_, pos, lit = l.scan()
requires.Equal(t, "5", lit)
requires.Equal(t, Pos{1, 28, 28}, pos)
tok, pos, _ = l.scan()
tok, _, _ = l.scan()
requires.Equal(t, int(')'), tok)

l = NewScanner("/*T![unsupported_feature] unsupported(123) */")
tok, pos, _ = l.scan()
tok, _, _ = l.scan()
requires.Equal(t, 0, tok)
}

Expand Down
5 changes: 4 additions & 1 deletion session/txninfo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "txninfo",
srcs = ["txn_info.go"],
srcs = [
"summary.go",
"txn_info.go",
],
importpath = "github.com/pingcap/tidb/session/txninfo",
visibility = ["//visibility:public"],
deps = [
Expand Down
1 change: 1 addition & 0 deletions tidb-server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ go_library(
"//privilege/privileges",
"//server",
"//session",
"//session/txninfo",
"//sessionctx/binloginfo",
"//sessionctx/variable",
"//statistics",
Expand Down