-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
SA4017 false positive #949
Labels
Comments
Thanks for reducing the problem to a minimal example. I can reproduce the issue and am looking into it. |
This is fixed in master. I will make a new patch release containing the fix early next week. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Firstly, thank you for building such an incredible tool! It's saved me from many bugs. :-)
I recently encountered a false positive while working on some code that I've reduced to the smallest reproducible example I could and attached to this issue.
The output of 'staticcheck -version'
staticcheck 2020.2.3 (v0.1.3)
The output of 'staticcheck -debug.version' (it is fine if this command fails)
The output of 'go version'
go version go1.16.2 linux/amd64
The output of 'go env'
Exactly which command you ran
staticcheck ./...
Output of the command and what's wrong with the output
app/app.go:21:10: Errorf is a pure function but its return value is ignored (SA4017)
The return value from
fmt.Errorf
is used as the return value of the function. It's definitely being used.Where we can read the code you're running staticcheck on
I've attached a tiny project that reproduces the bug with the smallest example I could make. scheck.tar.gz
There seem to be 2 key elements to triggering the bug.
for
loop at the end of the function, the error also disappears.The example is based on a server that I'm writing, hence the non-terminating
for
loop.In short, staticcheck has a problem with the following bit of code:
If I return
err
directly instead of wrapping it withfmt.Errorf()
the error will also go away.The text was updated successfully, but these errors were encountered: