go/analysis/cmd/analyze: install all analyzers
The default value of -findcall.name has been changed to "" to avoid producing noise. Change-Id: I71554080bcc7b6e23f632b49e30590fa0b0bc034 Reviewed-on: https://go-review.googlesource.com/c/143297 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
9f76e5c58b
commit
8dacc032e7
|
@ -28,6 +28,8 @@ func init() {
|
||||||
func TestTheTest(t *testing.T) {
|
func TestTheTest(t *testing.T) {
|
||||||
// We'll simulate a partly failing test of the findcall analysis,
|
// We'll simulate a partly failing test of the findcall analysis,
|
||||||
// which (by default) reports calls to functions named 'println'.
|
// which (by default) reports calls to functions named 'println'.
|
||||||
|
findcall.Analyzer.Flags.Set("name", "println")
|
||||||
|
|
||||||
filemap := map[string]string{"a/b.go": `package main
|
filemap := map[string]string{"a/b.go": `package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -15,8 +15,29 @@ import (
|
||||||
"golang.org/x/tools/go/analysis/multichecker"
|
"golang.org/x/tools/go/analysis/multichecker"
|
||||||
|
|
||||||
// analysis plug-ins
|
// analysis plug-ins
|
||||||
|
"golang.org/x/tools/go/analysis/passes/asmdecl"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/assign"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/atomic"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/bools"
|
||||||
"golang.org/x/tools/go/analysis/passes/buildtag"
|
"golang.org/x/tools/go/analysis/passes/buildtag"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/cgocall"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/composite"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/copylock"
|
||||||
"golang.org/x/tools/go/analysis/passes/findcall"
|
"golang.org/x/tools/go/analysis/passes/findcall"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/httpresponse"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/loopclosure"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/lostcancel"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/nilfunc"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/nilness"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/pkgfact"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/printf"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/shift"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/stdmethods"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/structtag"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/tests"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/unreachable"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/unsafeptr"
|
||||||
|
"golang.org/x/tools/go/analysis/passes/unusedresult"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -24,7 +45,38 @@ func main() {
|
||||||
log.SetPrefix("analyze: ")
|
log.SetPrefix("analyze: ")
|
||||||
|
|
||||||
multichecker.Main(
|
multichecker.Main(
|
||||||
findcall.Analyzer,
|
// the traditional vet suite:
|
||||||
|
asmdecl.Analyzer,
|
||||||
|
assign.Analyzer,
|
||||||
|
atomic.Analyzer,
|
||||||
|
bools.Analyzer,
|
||||||
buildtag.Analyzer,
|
buildtag.Analyzer,
|
||||||
|
cgocall.Analyzer,
|
||||||
|
composite.Analyzer,
|
||||||
|
copylock.Analyzer,
|
||||||
|
httpresponse.Analyzer,
|
||||||
|
loopclosure.Analyzer,
|
||||||
|
lostcancel.Analyzer,
|
||||||
|
nilfunc.Analyzer,
|
||||||
|
pkgfact.Analyzer,
|
||||||
|
printf.Analyzer,
|
||||||
|
// shadow.Analyzer, // experimental; not enabled by default
|
||||||
|
shift.Analyzer,
|
||||||
|
stdmethods.Analyzer,
|
||||||
|
structtag.Analyzer,
|
||||||
|
tests.Analyzer,
|
||||||
|
unreachable.Analyzer,
|
||||||
|
unsafeptr.Analyzer,
|
||||||
|
unusedresult.Analyzer,
|
||||||
|
|
||||||
|
// for debugging:
|
||||||
|
findcall.Analyzer,
|
||||||
|
|
||||||
|
// use SSA:
|
||||||
|
nilness.Analyzer,
|
||||||
|
|
||||||
|
// Work in progress:
|
||||||
|
// httpheader.Analyzer,
|
||||||
|
// deadcode.Analyzer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ var Analyzer = &analysis.Analyzer{
|
||||||
FactTypes: []analysis.Fact{new(foundFact)},
|
FactTypes: []analysis.Fact{new(foundFact)},
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = "println" // -name flag
|
var name string // -name flag
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Analyzer.Flags.StringVar(&name, "name", name, "name of the function to find")
|
Analyzer.Flags.StringVar(&name, "name", name, "name of the function to find")
|
||||||
|
|
|
@ -11,11 +11,16 @@ import (
|
||||||
"golang.org/x/tools/go/analysis/passes/findcall"
|
"golang.org/x/tools/go/analysis/passes/findcall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
findcall.Analyzer.Flags.Set("name", "println")
|
||||||
|
}
|
||||||
|
|
||||||
// TestFromStringLiterals demonstrates how to test an analysis using
|
// TestFromStringLiterals demonstrates how to test an analysis using
|
||||||
// a table of string literals for each test case.
|
// a table of string literals for each test case.
|
||||||
//
|
//
|
||||||
// Such tests are typically quite compact.
|
// Such tests are typically quite compact.
|
||||||
func TestFromStringLiterals(t *testing.T) {
|
func TestFromStringLiterals(t *testing.T) {
|
||||||
|
|
||||||
for _, test := range [...]struct {
|
for _, test := range [...]struct {
|
||||||
desc string
|
desc string
|
||||||
pkgpath string
|
pkgpath string
|
||||||
|
|
Loading…
Reference in New Issue