Skip to content

Commit

Permalink
go/analysis/passes/vet: fork cmd/vet@31d19c0
Browse files Browse the repository at this point in the history
This change creates a fork of vet from the standard distribution.

It was created by this script:

 $ mkdir go/analysis/passes/vet/
 $ cd go/analysis/passes/vet/
 $ (cd $GOROOT/src/cmd/vet >/dev/null && git co 31d19c0 && tar cf - .) | tar xf -
 $ rm -fr all              # We'll deal with cmd/vet/all later.
 $ rm -fr internal/cfg     # Published as golang.org/x/tools/go/cfg.
 $ sed -i -e '1s?^?// +build ignore\n\n?' *.go

All the Go files have been tagged "ignore" for now.
A series of follow-up changes will convert each vet check
into an instance of the new go/analysis API's Analyzer.

At some point soon, cmd/vet in the standard distribution will use a
vendored copy of this code. Until then we will periodically integrate
any changes made to cmd/vet to this fork. The current version of
cmd/vet will be recorded in the REVISION file.

Change-Id: I0c63eeb17cc612b3f013679595dcbc71a90950f7
Reviewed-on: https://go-review.googlesource.com/138137
Reviewed-by: Michael Matloob <matloob@golang.org>
  • Loading branch information
adonovan committed Sep 27, 2018
1 parent b41e4b4 commit 1be7b45
Show file tree
Hide file tree
Showing 70 changed files with 13,029 additions and 0 deletions.
33 changes: 33 additions & 0 deletions go/analysis/passes/vet/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Vet is a tool that checks correctness of Go programs. It runs a suite of tests,
each tailored to check for a particular class of errors. Examples include incorrect
Printf format verbs and malformed build tags.

Over time many checks have been added to vet's suite, but many more have been
rejected as not appropriate for the tool. The criteria applied when selecting which
checks to add are:

Correctness:

Vet's checks are about correctness, not style. A vet check must identify real or
potential bugs that could cause incorrect compilation or execution. A check that
only identifies stylistic points or alternative correct approaches to a situation
is not acceptable.

Frequency:

Vet is run every day by many programmers, often as part of every compilation or
submission. The cost in execution time is considerable, especially in aggregate,
so checks must be likely enough to find real problems that they are worth the
overhead of the added check. A new check that finds only a handful of problems
across all existing programs, even if the problem is significant, is not worth
adding to the suite everyone runs daily.

Precision:

Most of vet's checks are heuristic and can generate both false positives (flagging
correct programs) and false negatives (not flagging incorrect ones). The rate of
both these failures must be very small. A check that is too noisy will be ignored
by the programmer overwhelmed by the output; a check that misses too many of the
cases it's looking for will give a false sense of security. Neither is acceptable.
A vet check must be accurate enough that everything it reports is worth examining,
and complete enough to encourage real confidence.
1 change: 1 addition & 0 deletions go/analysis/passes/vet/REVISION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmd/vet@31d19c0
Loading

0 comments on commit 1be7b45

Please sign in to comment.