Imports #
_ "embed"
"go/ast"
"go/token"
"go/types"
"regexp"
"strings"
"unicode"
"unicode/utf8"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
_ "embed"
"go/ast"
"go/token"
"go/types"
"regexp"
"strings"
"unicode"
"unicode/utf8"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
var Analyzer = *ast.UnaryExprvar acceptedFuzzTypes = []types.Type{...}go:embed doc.go
var doc stringThis pattern is taken from /go/src/go/doc/example.go
var outputRe = *ast.CallExprtype commentMetadata struct {
isOutput bool
pos token.Pos
}type tokenRange struct {
p token.Pos
e token.Pos
}func (r tokenRange) End() token.Posfunc (r tokenRange) Pos() token.PoscheckAddCalls checks that the arguments of f.Add calls have the same number and type of arguments as the signature of the function passed to (*testing.F).Fuzz
func checkAddCalls(pass *analysis.Pass, fn *ast.FuncDecl, params *types.Tuple)func checkExampleName(pass *analysis.Pass, fn *ast.FuncDecl)func checkExampleOutput(pass *analysis.Pass, fn *ast.FuncDecl, fileComments []*ast.CommentGroup)checkFuzz checks the contents of a fuzz function.
func checkFuzz(pass *analysis.Pass, fn *ast.FuncDecl)checkFuzzCall checks the arguments of f.Fuzz() calls: 1. f.Fuzz() should call a function and it should be of type (*testing.F).Fuzz(). 2. The called function in f.Fuzz(func(){}) should not return result. 3. First argument of func() should be of type *testing.T 4. Second argument onwards should be of type []byte, string, bool, byte, rune, float32, float64, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64 5. func() must not call any *F methods, e.g. (*F).Log, (*F).Error, (*F).Skip The only *F methods that are allowed in the (*F).Fuzz function are (*F).Failed and (*F).Name. Returns the list of parameters to the fuzz function, if they are valid fuzz parameters.
func checkFuzzCall(pass *analysis.Pass, fn *ast.FuncDecl) (params *types.Tuple)func checkTest(pass *analysis.Pass, fn *ast.FuncDecl, prefix string)func formatAcceptedFuzzType() stringValidate that fuzz target function's arguments are of accepted types.
func isAcceptedFuzzType(paramType types.Type) boolfunc isExampleSuffix(s string) boolisFuzzTargetDot reports whether call is (*testing.F).
func isFuzzTargetDot(pass *analysis.Pass, call *ast.CallExpr, name string) boolisFuzzTargetDotAdd reports whether call is (*testing.F).Add().
func isFuzzTargetDotAdd(pass *analysis.Pass, call *ast.CallExpr) boolisFuzzTargetDotFuzz reports whether call is (*testing.F).Fuzz().
func isFuzzTargetDotFuzz(pass *analysis.Pass, call *ast.CallExpr) boolfunc isTestParam(typ ast.Expr, wantType string) boolfunc isTestSuffix(name string) boolfunc isTestingType(typ types.Type, testingType string) boolfunc lookup(pkg *types.Package, name string) []types.Objectfunc run(pass *analysis.Pass) (interface{}, error)Validate the arguments of fuzz target.
func validateFuzzArgs(pass *analysis.Pass, params *types.Tuple, expr ast.Expr) boolGenerated with Arrow