-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: add test -vet=all sentinel #45963
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
Comments
Is it fair to describe the proposal as basically make If there was also a large uptick in folks[/tools] replacing
Why would this be an issue with
The true positive rate of the existing checkers is very very high. It is not 100% though.
A concern would be whether this will continue to be true moving forward. Adding a checker as initially disabled so folks can try it out and enabling it later is a lower barrier of entry. Implementation note: printf is currently enabled in go test. So facts are enabled. So I do not expect to see a huge change in the performance caused by making |
I agree that adding an "go vet -all" option in vet will be handy, but "go test -vet=all" is less convincing. One main issue is that the checkers not enabled by default such as the ShadowVariable checker may have high false positive rates, and if we combine "go test" and "go vet" then these false positives will fail the tests. "As part of building a test binary, go test runs go vet on the package and its test source files to identify significant problems. If go vet The option "go vet -checker=all" looks better to me. |
to be clear, this would be a nop today? it would only do something different if we added a disabled by default vet like ShadowVariable.
I feel comfortable saying some part of the community, myself included, wants such test failures as a feature, but I can understand doing this default may not be the best call.
so this would also run tests? otherwise it is no different than |
We used to have a |
This proposal has been added to the active column of the proposals project |
Still pending someone looking up why the old -all became a no-op. |
Those flags look they might be mimicking the flags in cmd/vet/all/main.go. Just a guess. cmd/vet/all was deleted in 86463c by rsc@. Not sure when the |
We still need to figure out why -all was removed before. |
alright, that took longer than I expected. it appears that this was added exclusively for backwards compatibility with old vet flags to
this can be manually confirmed: package main
import "golang.org/x/tools/go/analysis/unitchecker"
func main() { unitchecker.Main() }
|
OK, so it sounds like the history here was that we had go vet -all as the default, but that was turned off when you asked for anything specifically, like go vet -asmdecl. But then as part of the fix for #7422 (go vet -composite=false not turning off just the single check) we changed the way the flags are handled and made -all a no-op. Since "all" was the default, it didn't really matter that the flag was a no-op. But then for "go test" we have been using a smaller test-safe subset. In the long term we want that to merge with "all" but it hasn't yet. Providing all would let people say 'go test -vet=all' to get the same checks as plain 'go vet'. That seems reasonable. |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://golang.org/cl/334873 mentions this issue: |
background
Currently the
off
sentinel is used to turn off vet during testing, unfortunately the lack of a "vet all the checks" option means that I either need to curate a (potentially non exhaustive) list or callgo test
thengo vet
. The former suffers from sync issues where each release may add or remove flags which could break builds. The latter is a performance issue with large [recte monorepo] builds where a lot of source is being parsed.summary
I would think that defining
-vet=all
to enable all the vet checks, just likego vet
does, should be easy, backwards compatible, and not terribly controversial.alternatives
We could instead expand test to just run all the vet checks by default since we have been aggressive in only enabling vets that produce true positives.
The name
all
may be confusing if there are ever disabled vets added, likeshadow
, but as I read the docs, it seems like there was a move to purge ineffective vets. Other names that could be more clear includefull
,default
, ormost
, but we can bikeshed later.The text was updated successfully, but these errors were encountered: