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
SA5011 false positive in tests that use gotest.tools "assert" #1022
Comments
Funny, I've just closed #832 and now you're telling me there's an entire testing framework built around this pattern… I guess this can be the new issue for this. |
The easiest workaround is probably to only consider those |
Ah, I think I saw that one when searching, and now reading the linked issue. Yes, I can see it being somewhat complicated to take all "possible" testing frameworks into account. Thought I'd at least open a ticket for it, in case that's something you'd normally do. I think in our case either excluding this check for tests would probably be ok (worst case: we run into a panic in a test), or just removing the |
I find that this staticcheck rule/check doesn't bite me too often. When it does, however, I find this pattern quiets it: if assert.Check(t, thing != nil) {
assert.Assert(t, thing.Field)
} |
When linting the file below, static check fails to detect the
assert.Assert(t, loadedConfig != nil)
as a guard against nil values, causing linting to fail;https://play.golang.org/p/ETtTE7jResx
When running with "plain"
staticcheck
:When running as part of golangci-lint:
Staticcheck should detect that the
assert.Assert
(orassert.Check
) is gating this situation.The text was updated successfully, but these errors were encountered: