-
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
*: enable and fix unparam lint #16622
Conversation
@@ -24,6 +24,7 @@ linters: | |||
- stylecheck | |||
- unused | |||
- unconvert # Remove unnecessary type conversions | |||
- unparam |
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.
Note, this is new check that was not enabled before, so this is not part of #16610 and should start from community discussion whether we want to adopt unparam
check at all.
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.
OK. Let me fix all the existing lint issues and then discuss this one.
313be92
to
bc815e7
Compare
ping @ahrtr @serathius @jmhbnz |
server/etcdmain/grpc_proxy.go
Outdated
@@ -538,8 +538,7 @@ func mustHTTPListener(lg *zap.Logger, m cmux.CMux, tlsinfo *transport.TLSInfo, c | |||
func mustNewHTTPClient(lg *zap.Logger) *http.Client { | |||
transport, err := newHTTPTransport(grpcProxyCA, grpcProxyCert, grpcProxyKey) | |||
if err != nil { | |||
fmt.Fprintln(os.Stderr, err) | |||
os.Exit(1) | |||
lg.Fatal("failed to new http transport", zap.Error(err)) |
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.
This is not the same, it changes the exit code and the output.
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.
+1 let's try not to change anything unrelated to this PR.
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.
lg.Fatal
exits with code 1. Yes, I should not update the output.
Updated with removing the lg *zap.Logger
since no function uses lg
.
bc815e7
to
e3b1bb3
Compare
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
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 - Great to tidy and tighten this up, thanks @fuweid.
Is it ready to move on? |
ping @serathius @ahrtr |
Sorry for the delay. I already approved the PR, and leave it to @serathius to take another look and merge, since he raised comment/concern #16622 (comment) previously |
Thanks for the comment. As far as I know, the test script has been refactored several times and I believe we miss some of them. The unparam_pass isn't introduced in this pr. The pr just enables it. The lint did find some unparam issues. It has strict rule, especially when we write test code. But it could help us to find some issues in test code. In my opinion, based on the fact that it's not new lint in the repo, we can enable it and evaluate it for a while. If it's annoying, we can consider to disable it. |
Signed-off-by: Wei Fu <fuweid89@gmail.com>
e3b1bb3
to
aea1cd0
Compare
ping @serathius ~ |
Thanks! @serathius |
Part of #15549
Highlight of changes:
1. transport/listener_test.go:44:32:
fakeCertificateParserFunc
-cert
always receivestls.Certificate{}
(nil
)fakeCertificateParserFunc
returnstls.Certificate{}
by default.2. retry_interceptor.go:381:22:
withRetryPolicy
-rp
always receivesrepeatable
(0
) (unparam) func withRetryPolicy(rp retryPolicy) retryOption {Uses the following code to fix
3. history.go:349:22:
staleGetRequest
-key
always receives"key"
(unparam) func staleGetRequest(key string, revision int64) EtcdRequest {Changed one model operation's key from
key
tokey1
.4. member_test.go:84:40:
newTestMemberAsLearner
-peerURLs
always receivesnil
(unparam) func newTestMemberAsLearner(id uint64, peerURLs []string, name string, clientURLs []string) *Member {Changed
nil
to[]string{}
to fix the lint issue.Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.