-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Labels
AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Issues related to static analysis (vet, x/tools/go/analysis)ProposalProposal-Accepted
Milestone
Description
I propose that cmd/vet flag any benchmark that doesn’t have any reference to b in its body.
- Frequency: Low among experienced gophers, but not an uncommon mistake among new gophers.
- Correctness: Benchmarks written without using b do not function as benchmarks. Often this gets caught by a user who is puzzled by the output, but not always, particularly if the benchmark is slow.
- Precision: 100%, or very near it. You cannot write a correct benchmark without using b.N, b.Run, b.RunParallel, or somehow passing b or one of its fields to another function to do that for you.
The implementation should be fairly straightforward. Pick out benchmarks. Pick out the identifier (usually b
). Look for any uses of that identifier. If none, complain.
bcmills, adg, sfllaw, Zerotask, Deleplace and 4 more
Metadata
Metadata
Assignees
Labels
AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Issues related to static analysis (vet, x/tools/go/analysis)ProposalProposal-Accepted
Type
Projects
Status
Accepted