Source file src/cmd/vendor/golang.org/x/tools/go/analysis/suite/fix/fix.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // The fix package defines the suite of analyzers used by cmd/fix,
     6  // the default analysis tool run by "go fix".
     7  // Its behavior is equivalent to:
     8  //
     9  //	func main() { unitchecker.Main(fix.Suite...) }
    10  //
    11  // If you need a different suite, define your own tool
    12  // and run "go vet -vettool=mytool".
    13  package fix
    14  
    15  import (
    16  	"slices"
    17  
    18  	"golang.org/x/tools/go/analysis"
    19  	"golang.org/x/tools/go/analysis/passes/buildtag"
    20  	"golang.org/x/tools/go/analysis/passes/hostport"
    21  	"golang.org/x/tools/go/analysis/passes/inline"
    22  	"golang.org/x/tools/go/analysis/passes/modernize"
    23  )
    24  
    25  // Suite is the suite of analyzers run by cmd/fix.
    26  //
    27  // The fix suite analyzers produce fixes are unambiguously safe to apply,
    28  // even if the diagnostics might not describe actual problems.
    29  var Suite = slices.Concat(
    30  	[]*analysis.Analyzer{
    31  		buildtag.Analyzer,
    32  		hostport.Analyzer,
    33  		inline.Analyzer,
    34  	},
    35  	modernize.Suite,
    36  	// TODO(adonovan): add any other vet analyzers whose fixes are always safe.
    37  	// Candidates to audit: sigchanyzer, printf, assign, unreachable.
    38  	// Many of staticcheck's analyzers would make good candidates
    39  	//   (e.g. rewriting WriteString(fmt.Sprintf()) to Fprintf.)
    40  	// Rejected:
    41  	// - composites: some types (e.g. PointXY{1,2}) don't want field names.
    42  	// - timeformat: flipping MM/DD is a behavior change, but the code
    43  	//    could potentially be a workaround for another bug.
    44  	// - stringintconv: offers two fixes, user input required to choose.
    45  	// - fieldalignment: poor signal/noise; fix could be a regression.
    46  )
    47  

View as plain text