From 1fdeb1692e0bf54f07926710b72fe30e350c946f Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 14 Nov 2018 17:51:06 -0500 Subject: [PATCH] go/analysis/internal/unitchecker: three fixes - add a no-op -tags flag for legacy compatibility. Tags processing is done by go vet, but it passes the flag on. Exercised by cmd/go TestGoVetWithTags. - rename OtherFiles to NonGoFiles in the JSON *.cfg file, to match the name actually used for this field (see github.com/golang/go/issues/27665). We really need to publish the types for this protocol. Exercised by cmd/go TestScript/vet_asm. - suppress diagnostics in cfg.VetxOnly mode. Exercised by cmd/go TestTestVet. Change-Id: I63259f1bd01531d110362e38190a220389b2ec4b Reviewed-on: https://go-review.googlesource.com/c/149608 Run-TryBot: Alan Donovan TryBot-Result: Gobot Gobot Reviewed-by: Michael Matloob --- go/analysis/cmd/vet-lite/main.go | 1 + go/analysis/internal/unitchecker/unitchecker.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/go/analysis/cmd/vet-lite/main.go b/go/analysis/cmd/vet-lite/main.go index b4b0e631..e847d8df 100644 --- a/go/analysis/cmd/vet-lite/main.go +++ b/go/analysis/cmd/vet-lite/main.go @@ -96,6 +96,7 @@ func main() { for _, name := range []string{"source", "v", "all"} { _ = flag.Bool(name, false, "no effect (deprecated)") } + _ = flag.String("tags", "", "no effect (deprecated)") flag.Usage = func() { fmt.Fprintln(os.Stderr, `Usage of vet: diff --git a/go/analysis/internal/unitchecker/unitchecker.go b/go/analysis/internal/unitchecker/unitchecker.go index 32b50c1b..8ca42ab6 100644 --- a/go/analysis/internal/unitchecker/unitchecker.go +++ b/go/analysis/internal/unitchecker/unitchecker.go @@ -58,7 +58,7 @@ type Config struct { Dir string ImportPath string GoFiles []string - OtherFiles []string // TODO(adonovan): make go vet populate this (github.com/golang/go/issues/27665) + NonGoFiles []string ImportMap map[string]string PackageFile map[string]string Standard map[string]bool @@ -82,7 +82,7 @@ func Main(configFile string, analyzers []*analysis.Analyzer) { log.Fatal(err) } - if len(diags) > 0 { + if !cfg.VetxOnly && len(diags) > 0 { for _, diag := range diags { fmt.Fprintf(os.Stderr, "%s: %s\n", fset.Position(diag.Pos), diag.Message) } @@ -250,7 +250,7 @@ func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]an Analyzer: a, Fset: fset, Files: files, - OtherFiles: cfg.OtherFiles, + OtherFiles: cfg.NonGoFiles, Pkg: pkg, TypesInfo: info, ResultOf: inputs,