-
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
test: make Go code lint stricter #8068
Comments
Unused function arguments would be a good one, CI should have caught this bug from #8074: func (dec *messageDecoder) decodeLimit(numBytes uint64) (raftpb.Message, error) {
var m raftpb.Message
var l uint64
if err := binary.Read(dec.r, binary.BigEndian, &l); err != nil {
return m, err
}
if l > readBytesLimit {
return m, ErrExceedSizeLimit
}
buf := make([]byte, int(l))
if _, err := io.ReadFull(dec.r, buf); err != nil {
return m, err
}
return m, m.Unmarshal(buf)
} |
TODO: try https://github.com/mvdan/unparam. |
Gave it a spin, totally broken. Can't recognize import renaming. The ignore policy seems too weak anyway; if an argument is unused and not given an underscore name, there's still a bunch of ways it'll let that pass, even though it probably shouldn't... |
Hey, original author here. If you find any issues in particular, please file issues with a small example to reproduce them. I realise the tool likely has some false negatives and positives, but it's impossible (or near impossible?) to have a perfect solution given how arguments might be used in lots of subtle ways. But of course, I'm sure the tool can do better :) Happy to help if you give me concrete issues. |
Friendly ping - still happy to look into false positives or negatives if you'd give me pointers. |
I have been improving the tool the past couple of weeks, and I've been using Last week, the number of warnings was upwards of 100. Now, it's down to 31:
Except the Whether or not the signature of exported funcs can be changed is a different aspect - the tool does nothing about that, at the moment. Thinking of adding a flag, defaulting to assuming that backwards compatibility cannot be broken. |
@mvdan We will integrate https://github.com/mvdan/unparam in CI. Seems useful! |
Possible addition to our format tests
public method on unexported struct clientv3: change Close() to close() for keepAlive and watchGrpcStream #8066Either use external tools or propose to
cmd/vet
teamThe text was updated successfully, but these errors were encountered: