diff options
| author | Alan Donovan <adonovan@google.com> | 2025-10-10 15:49:53 -0400 |
|---|---|---|
| committer | Alan Donovan <adonovan@google.com> | 2025-10-17 14:39:00 -0700 |
| commit | a5f55a441ef497d8e2a12610f4ec2bd32fdc04b2 (patch) | |
| tree | d59a3180f8aab25d6b7474c5efd59b308761d37b /src/cmd/fix | |
| parent | 80876f4b42c807e0f90eab20a3e8a98ef95f2cb0 (diff) | |
| download | go-a5f55a441ef497d8e2a12610f4ec2bd32fdc04b2.tar.xz | |
cmd/fix: add modernize and inline analyzers
We ran 'go mod vendor' to pull in the newly used packages.
Also, add a cmd/go script test that minimally
exercises each analyzer, analogous to the cmd/vet test.
For #75266
For #75267
For #71859
Change-Id: I334daea048e3d2f614a1788292a3175acf173932
Reviewed-on: https://go-review.googlesource.com/c/go/+/710995
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Bypass: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Diffstat (limited to 'src/cmd/fix')
| -rw-r--r-- | src/cmd/fix/main.go | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/cmd/fix/main.go b/src/cmd/fix/main.go index 422fa82745..8fc412fe29 100644 --- a/src/cmd/fix/main.go +++ b/src/cmd/fix/main.go @@ -22,10 +22,13 @@ package main import ( "cmd/internal/objabi" "cmd/internal/telemetry/counter" + "slices" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/buildtag" "golang.org/x/tools/go/analysis/passes/hostport" + "golang.org/x/tools/go/analysis/passes/inline" + "golang.org/x/tools/go/analysis/passes/modernize" "golang.org/x/tools/go/analysis/unitchecker" ) @@ -38,22 +41,23 @@ func main() { unitchecker.Main(suite...) // (never returns) } -// The fix suite analyzers produce fixes that are safe to apply. -// (Diagnostics may not describe actual problems, -// but their fixes must be unambiguously safe to apply.) -var suite = []*analysis.Analyzer{ - buildtag.Analyzer, - hostport.Analyzer, - // TODO(adonovan): now the modernize (proposal #75266) and - // inline (proposal #75267) analyzers are published, revendor - // x/tools and add them here. - // - // TODO(adonovan):add any other vet analyzers whose fixes are always safe. +// The fix suite analyzers produce fixes are unambiguously safe to apply, +// even if the diagnostics might not describe actual problems. +var suite = slices.Concat( + []*analysis.Analyzer{ + buildtag.Analyzer, + hostport.Analyzer, + inline.Analyzer, + }, + modernize.Suite, + // TODO(adonovan): add any other vet analyzers whose fixes are always safe. // Candidates to audit: sigchanyzer, printf, assign, unreachable. + // Many of staticcheck's analyzers would make good candidates + // (e.g. rewriting WriteString(fmt.Sprintf()) to Fprintf.) // Rejected: // - composites: some types (e.g. PointXY{1,2}) don't want field names. // - timeformat: flipping MM/DD is a behavior change, but the code // could potentially be a workaround for another bug. // - stringintconv: offers two fixes, user input required to choose. // - fieldalignment: poor signal/noise; fix could be a regression. -} +) |
