-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
*: fix ineffassign lint #16605
*: fix ineffassign lint #16605
Conversation
logger.go:130: 2023-09-18T04:51:30.214Z WARN m0.raft 23c867d67cc4267b stepped down to follower since quorum is not active {"member": "m0"}
logger.go:130: 2023-09-18T04:51:30.215Z INFO m0.raft 23c867d67cc4267b became follower at term 3 {"member": "m0"}
logger.go:130: 2023-09-18T04:51:30.215Z INFO m0.raft raft.node: 23c867d67cc4267b lost leader 23c867d67cc4267b at term 3 {"member": "m0"}
logger.go:130: 2023-09-18T04:51:30.551Z WARN m1 request stats {"member": "m1", "start time": "2023-09-18T04:51:30.013Z", "time spent": "537.193567ms", "remote": "@", "response type": "/etcdserverpb.Lease/LeaseTimeToLive", "request count": -1, "request size": -1, "response count": -1, "response size": -1, "request content": ""}
lease_test.go:180:
Error Trace: /__w/etcd/etcd/tests/common/lease_test.go:180
/__w/etcd/etcd/tests/framework/testutils/execute.go:38
/__t/go/1.21.1/x64/src/runtime/asm_amd64.s:1650
Error: "2" is not greater than "9223372036"
Test: TestLeaseGrantKeepAliveOnce/PeerAutoTLS The leader has been changed during invoking LeaseTimeToLive. And the new leader didn't Promote in time. |
62e5ffb
to
89959d5
Compare
function ineffassign_pass { | ||
run_for_modules generic_checker ineffassign_per_package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't ineffassign be enabled as part of golangci? Check tools/.golangci.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminder! The tools/.golangci.yaml
already has the ineffassign
. But the golangci-lint doesn't support multiple modules so... currently the make verify-lint
doesn't work.
# at root (no error)
➜ etcd git:(main) golangci-lint run --config ./tools/.golangci.yaml -v
INFO [config_reader] Used config file tools/.golangci.yaml
INFO [lintersdb] Active 7 linters: [goimports ineffassign revive staticcheck stylecheck unconvert unused]
INFO [loader] Go packages loading at mode 575 (types_sizes|compiled_files|deps|exports_file|files|imports|name) took 412.865392ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 6.088202ms
INFO [linters_context/goanalysis] analyzers took 0s with no stages
INFO [runner] Issues before processing: 10, after processing: 0
INFO [runner] Processors filtering stat (out/in): exclude-rules: 0/10, identifier_marker: 10/10, skip_dirs: 10/10, filename_unadjuster: 10/10, path_prettifier: 10/10, skip_files: 10/10, autogenerated_exclude: 10/10, exclude: 10/10, cgo: 10/10
INFO [runner] processing took 1.314322ms with stages: path_prettifier: 465.208µs, exclude-rules: 277.505µs, autogenerated_exclude: 251.005µs, identifier_marker: 221.403µs, skip_dirs: 70.401µs, skip_files: 19µs, cgo: 3µs, filename_unadjuster: 1.4µs, max_same_issues: 1.4µs, nolint: 900ns, fixer: 900ns, diff: 400ns, source_code: 400ns, max_from_linter: 300ns, max_per_file_from_linter: 200ns, uniq_by_line: 200ns, path_prefixer: 200ns, exclude: 200ns, severity-rules: 100ns, path_shortener: 100ns, sort_results: 100ns
INFO [runner] linters took 154.52938ms with stages: goanalysis_metalinter: 152.939553ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 7 samples, avg is 33.4MB, max is 50.9MB
INFO Execution took 588.932231ms
# cd ./server
➜ server git:(main) golangci-lint run --config ../tools/.golangci.yaml
lease/lease_queue.go:25:6: exported: type name will be used as lease.LeaseWithTime by other packages, and that stutters; consider calling this WithTime (revive)
type LeaseWithTime struct {
^
lease/lessor.go:823:39: unused-parameter: parameter 'dr' seems to be unused, consider removing or renaming it as _ (revive)
func (fl *FakeLessor) SetRangeDeleter(dr RangeDeleter) {}
^
lease/lease.go:119:6: exported: type name will be used as lease.LeaseItem by other packages, and that stutters; consider calling this Item (revive)
type LeaseItem struct {
^
lease/lease_queue.go:31:6: exported: type name will be used as lease.LeaseQueue by other packages, and that stutters; consider calling this Queue (revive)
type LeaseQueue []*LeaseWithTime
May I fix the lint one by one and then fix the make verify-lint
after that? The small changeset is easy to be reviewed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's unfortunate. Fixing golangci sounds good to me. Thanks for investigating this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After fixing all the lint's issues, I will fix golangci-lint issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you file an issue about golangci being broken so we can track fixes to lint issues in one place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #16610 .
89959d5
to
ce48c87
Compare
function ineffassign_pass { | ||
run_for_modules generic_checker ineffassign_per_package | ||
run_for_modules generic_checker run_go_tool "github.com/gordonklaus/ineffassign" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your plan for ineffassign_pass
if this will be covered by make verify-lint
? Should we maybe remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# TODO: https://github.com/etcd-io/etcd/issues/16610
#
# The golangci-lint doesn't verify sub modules. Before #16610 fixed, verify-lint
# still depends on legacy {ineffassign,nakedret,unparam,...}_pass. These X_pass
# will be removed when the golangci-lint covers all the sub modules.
.PHONY: verify-lint
verify-lint: verify-ineffassign
golangci-lint run --config tools/.golangci.yaml
I add new recipe verify-ineffassign
and verify-lint
depends on it. So, it can cover the new change.
when all the lint issues are covered by _pass
, we can switch to golangci-lint. After that, all the legacy lint_pass can be removed. Does it make senses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, should be good to prevent regressions until we fix golangci.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when all the lint issues are covered by _pass, we can switch to golangci-lint. After that, all the legacy lint_pass can be removed.
I assume there is a ticket to track this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. #16610 is tracking this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx
ce48c87
to
32fc09b
Compare
Signed-off-by: Wei Fu <fuweid89@gmail.com>
32fc09b
to
df86cad
Compare
ping @ahrtr @serathius @jmhbnz ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
thx. @fuweid
function ineffassign_pass { | ||
run_for_modules generic_checker ineffassign_per_package | ||
run_for_modules generic_checker run_go_tool "github.com/gordonklaus/ineffassign" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when all the lint issues are covered by _pass, we can switch to golangci-lint. After that, all the legacy lint_pass can be removed.
I assume there is a ticket to track this.
Part of #15549
Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.