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

*: Fixed some linter check errors #25606

Closed
wants to merge 0 commits into from
Closed

Conversation

hsqlu
Copy link
Contributor

@hsqlu hsqlu commented Jun 21, 2021

Signed-off-by: Qiannan Lyu lvqiannan@gmail.com

What problem does this PR solve?

#22979 Fixed some linter check errors.

Problem Summary:

Before:

➜  tidb git:(master) make check-static                                                                                                 
tools/bin/golangci-lint run -v --disable-all --deadline=3m \
          --enable=misspell \                                                                                                          
          --enable=ineffassign \
          --enable=typecheck \
          --enable=varcheck \                                                                                                          
          --enable=unused \         
          --enable=structcheck \
          --enable=deadcode \                                                                                                          
          --enable=gosimple \       
          $(go list ./...| grep -vE "cmd|github.com\/pingcap\/tidb\/tests" | sed 's|github.com/pingcap/tidb/||')
INFO [config_reader] Config search paths: [./ /Users/qiannan/go/src/github.com/pingcap/tidb/bindinfo /Users/qiannan/go/src/github.com/pingcap/tidb /Users/qiannan/go/src/github.com/pingcap /Users/qiannan/go/src/github.com /Users/qiannan/go/src /Users/qiannan/go /Users/qi
annan /Users /]                                          
INFO [lintersdb] Active 8 linters: [deadcode gosimple ineffassign misspell structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (compiled_files|files|imports|types_sizes|deps|exports_file|name) took 2.154018256s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 217.231129ms 
INFO [linters context/goanalysis] analyzers took 0s with no stages 
INFO [runner] Issues before processing: 60, after processing: 17                                                                       
INFO [runner] Processors filtering stat (out/in): cgo: 60/60, filename_unadjuster: 60/60, skip_files: 60/60, exclude: 60/60, nolint: 17/60, max_same_issues: 17/17, severity-rules: 17/17, path_prettifier: 60/60, skip_dirs: 60/60, autogenerated_exclude: 60/60, identifier_
marker: 60/60, diff: 17/17, max_per_file_from_linter: 17/17, exclude-rules: 60/60, uniq_by_line: 17/17, source_code: 17/17, path_shortener: 17/17, path_prefixer: 17/17, sort_results: 17/17, max_from_linter: 17/17 
INFO [runner] processing took 81.31546ms with stages: nolint: 75.43776ms, source_code: 1.546283ms, autogenerated_exclude: 1.459192ms, path_prettifier: 1.356503ms, exclude-rules: 856.416µs, identifier_marker: 513.612µs, skip_dirs: 90.122µs, max_same_issues: 12.751µs, pat
h_shortener: 10.932µs, uniq_by_line: 9.566µs, max_from_linter: 6.41µs, cgo: 6.264µs, filename_unadjuster: 4.246µs, max_per_file_from_linter: 3.713µs, diff: 338ns, severity-rules: 326ns, sort_results: 323ns, skip_files: 294ns, exclude: 235ns, path_prefixer: 174ns 
INFO [runner] linters took 369.573059ms with stages: goanalysis_metalinter: 287.965682ms 
executor/builder.go:2794:93: `prefered` is a misspelling of `preferred` (misspell) 
        // When isPartition is set, it means the union rewriting is done, so a partition reader is prefered.
                                                                                                   ^
executor/builder.go:3023:93: `prefered` is a misspelling of `preferred` (misspell)
        // When isPartition is set, it means the union rewriting is done, so a partition reader is prefered.
                                                                                                   ^
sessionctx/variable/sysvar_test.go:116:17: ineffectual assignment to err (ineffassign)
        normalizedVal, err := sysVar.Validate(vars, "oN", ScopeSession)
                       ^
sessionctx/variable/sysvar_test.go:118:17: ineffectual assignment to err (ineffassign)
        normalizedVal, err = sysVar.Validate(vars, "0", ScopeSession)
                       ^
planner/core/preprocess.go:132:2: `initedLastSnapshotTS` is unused (structcheck)
        initedLastSnapshotTS bool
        ^
planner/core/logical_plan_builder.go:3637:2: S1023: redundant `return` statement (gosimple)
        return
        ^
structure/type.go:51:23: func `(*TxStructure).encodeHashMetaKey` is unused (unused)
func (t *TxStructure) encodeHashMetaKey(key []byte) kv.Key {
                      ^
statistics/handle/handle_test.go:872:26: func `(*testStatsSuite).checkForGlobalStatsWithOpts` is unused (unused)
func (s *testStatsSuite) checkForGlobalStatsWithOpts(c *C, tk *testkit.TestKit, p string, topn, buckets int) {
                         ^
statistics/handle/handle_test.go:849:26: func `(*testStatsSuite).prepareForGlobalStatsWithOpts` is unused (unused)
func (s *testStatsSuite) prepareForGlobalStatsWithOpts(c *C, tk *testkit.TestKit, tblName, dbName string) {
                         ^
statistics/handle/handle_test.go:890:7: type `opt` is unused (unused)
        type opt struct {
             ^
server/tidb_test.go:1490:2: ineffectual assignment to cancel (ineffassign)
        cancel = runWorkload(11, 20)
        ^
server/tidb_test.go:1508:2: ineffectual assignment to cancel (ineffassign)
        cancel = runWorkload(11, 20)
        ^
ddl/column_type_change_test.go:1767:14: S1039: unnecessary use of fmt.Sprintf (gosimple)
        tk.MustExec(fmt.Sprintf("set time_zone = 'UTC'"))
                    ^
executor/distsql_test.go:39:6: func `checkGoroutineExists` is unused (unused)
func checkGoroutineExists(keyword string) bool {
     ^
executor/analyze_test.go:602:22: func `(*testSuite1).testAnalyzeIncremental` is unused (unused)
func (s *testSuite1) testAnalyzeIncremental(tk *testkit.TestKit, c *C) {
                     ^
executor/memory_test.go:107:26: func `(*testMemoryLeak).readMem` is unused (unused)
func (s *testMemoryLeak) readMem() (allocated, heapInUse uint64) {
                         ^
executor/memory_test.go:113:26: func `(*testMemoryLeak).memDiff` is unused (unused)
func (s *testMemoryLeak) memDiff(m1, m2 uint64) uint64 {
                         ^
INFO File cache stats: 11 entries of total size 771.9KiB 
INFO Memory: 29 samples, avg is 109.7MB, max is 208.3MB 
INFO Execution took 2.763390788s                  
make: *** [check-static] Error 1

After:

➜  tidb git: make check-static 
tools/bin/golangci-lint run -v --disable-all --deadline=3m \
          --enable=misspell \
          --enable=ineffassign \
          --enable=typecheck \
          --enable=varcheck \
          --enable=unused \
          --enable=structcheck \
          --enable=deadcode \
          --enable=gosimple \
          $(go list ./...| grep -vE "cmd|github.com\/pingcap\/tidb\/tests" | sed 's|github.com/pingcap/tidb/||')
INFO [config_reader] Config search paths: [./ /Users/qiannan/go/src/github.com/pingcap/tidb/bindinfo /Users/qiannan/go/src/github.com/pingcap/tidb /Users/qiannan/go/src/github.com/pingcap /Users/qiannan/go/src/github.com /Users/qiannan/go/src /Users/qiannan/go /Users/qiannan /Users /] 
INFO [lintersdb] Active 8 linters: [deadcode gosimple ineffassign misspell structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (exports_file|files|imports|types_sizes|compiled_files|deps|name) took 2.149255847s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 206.892029ms 
INFO [linters context/goanalysis] analyzers took 0s with no stages 
INFO [runner] Issues before processing: 51, after processing: 1 
INFO [runner] Processors filtering stat (out/in): diff: 1/1, max_same_issues: 1/1, severity-rules: 1/1, autogenerated_exclude: 51/51, identifier_marker: 51/51, exclude-rules: 51/51, uniq_by_line: 1/1, source_code: 1/1, skip_dirs: 51/51, exclude: 51/51, path_shortener: 1/1, path_prefixer: 1/1, sort_results: 1/1, max_per_file_from_linter: 1/1, max_from_linter: 1/1, cgo: 51/51, filename_unadjuster: 51/51, path_prettifier: 51/51, skip_files: 51/51, nolint: 1/51 
INFO [runner] processing took 68.779247ms with stages: nolint: 65.77031ms, path_prettifier: 916.672µs, autogenerated_exclude: 891.398µs, exclude-rules: 611.232µs, identifier_marker: 408.53µs, source_code: 98.749µs, skip_dirs: 61.562µs, cgo: 6.973µs, filename_unadjuster: 5.893µs, uniq_by_line: 1.961µs, max_same_issues: 1.736µs, path_shortener: 1.256µs, max_from_linter: 874ns, max_per_file_from_linter: 544ns, skip_files: 411ns, diff: 345ns, exclude: 261ns, sort_results: 213ns, severity-rules: 204ns, path_prefixer: 123ns 
INFO [runner] linters took 342.291996ms with stages: goanalysis_metalinter: 273.374234ms 
planner/core/preprocess.go:133:2: `initedLastSnapshotTS` is unused (structcheck)
        initedLastSnapshotTS bool
        ^
INFO File cache stats: 1 entries of total size 45.9KiB 
INFO Memory: 29 samples, avg is 109.4MB, max is 207.5MB 
INFO Execution took 2.713330317s                  
make: *** [check-static] Error 1

Release note

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@hsqlu hsqlu requested review from a team as code owners June 21, 2021 09:07
@hsqlu hsqlu requested review from wshwsh12 and eurekaka and removed request for a team June 21, 2021 09:07
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 21, 2021
@ti-chi-bot
Copy link
Member

@hsqlu: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 21, 2021
@sre-bot
Copy link
Contributor

sre-bot commented Jun 21, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@ti-srebot
Copy link
Contributor

@sre-bot
Copy link
Contributor

sre-bot commented Jun 21, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@ti-srebot
Copy link
Contributor

@hsqlu hsqlu changed the title Fixed some linter check errors *: Fixed some linter check errors Jun 21, 2021
@hsqlu hsqlu closed this Jun 21, 2021
@ti-chi-bot ti-chi-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants