Skip to content

Commit 103f3f3

Browse files
committed
go/analysis: doc updates
Change-Id: Id784b350955cc8d76a1cc903b3ff29be36414434 Reviewed-on: https://go-review.googlesource.com/c/149741 Reviewed-by: Michael Matloob <[email protected]>
1 parent 29e82b5 commit 103f3f3

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

go/analysis/doc.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ To add a new Analyzer to an existing driver, add another item to the list:
7272
7373
A driver may use the name, flags, and documentation to provide on-line
7474
help that describes the analyses its performs.
75+
The doc comment contains a brief one-line summary,
76+
optionally followed by paragraphs of explanation.
7577
The vet command, shown below, is an example of a driver that runs
7678
multiple analyzers. It is based on the multichecker package
7779
(see the "Standalone commands" section for details).
7880
79-
$ go build golang.org/x/tools/cmd/vet
81+
$ go build golang.org/x/tools/go/analysis/cmd/vet
8082
$ ./vet help
8183
vet is a tool for static analysis of Go programs.
8284
@@ -285,6 +287,16 @@ pointed to by fact. This scheme assumes that the concrete type of fact
285287
is a pointer; this assumption is checked by the Validate function.
286288
See the "printf" analyzer for an example of object facts in action.
287289
290+
Some driver implementations (such as those based on Bazel and Blaze) do
291+
not currently apply analyzers to packages of the standard library.
292+
Therefore, for best results, analyzer authors should not rely on
293+
analysis facts being available for standard packages.
294+
For example, although the printf checker is capable of deducing during
295+
analysis of the log package that log.Printf is a printf-wrapper,
296+
this fact is built in to the analyzer so that it correctly checks
297+
calls to log.Printf even when run in a driver that does not apply
298+
it to standard packages. We plan to remove this limitation in future.
299+
288300
289301
Testing an Analyzer
290302
@@ -298,14 +310,14 @@ diagnostics and facts (and no more). Expectations are expressed using
298310
Standalone commands
299311
300312
Analyzers are provided in the form of packages that a driver program is
301-
expected to import. The vet command imports a set of several analyses,
313+
expected to import. The vet command imports a set of several analyzers,
302314
but users may wish to define their own analysis commands that perform
303315
additional checks. To simplify the task of creating an analysis command,
304316
either for a single analyzer or for a whole suite, we provide the
305317
singlechecker and multichecker subpackages.
306318
307319
The singlechecker package provides the main function for a command that
308-
runs one analysis. By convention, each analyzer such as
320+
runs one analyzer. By convention, each analyzer such as
309321
go/passes/findcall should be accompanied by a singlechecker-based
310322
command such as go/analysis/passes/findcall/cmd/findcall, defined in its
311323
entirety as:

0 commit comments

Comments
 (0)