-
Notifications
You must be signed in to change notification settings - Fork 18k
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
proposal: cmd/vet: Not using the return value of a function that only produces an error should be flagged #72926
Comments
As your experience points out, this wouldn't meet the accuracy bar for vet. |
sorry, I meant to contrast them. errcheck checks for every single possible function. I'm suggesting vet only check the ones from the standard library, which would be very accurate |
What about |
Close has side effects. Errorf doesn't, the whole point of it is to create an error, so doing nothing with it doesn't make sense. To me it's the same sort of check as not allowing unused variables. |
Sure, but how do you differentiate |
oh, by listing the relevant functions out I guess |
Right, just depending on the return type as proposed is probably insufficient. |
This is a subset of #65984. |
Proposal Details
I ran into a piece of code today that did
Clearly the first one was a mistake, the intention was to return. I think it would be nice if vet flagged such uses of Errorf, Wrapf, errors.New as they are most definitely not intentional.
There is an existing tool, https://github.com/kisielk/errcheck which would have pointed this out. However, in my experience integrating it in existing codebases can be quite tedious and requires fixing many calls that might be fishy but not necessarily buggy.
The text was updated successfully, but these errors were encountered: