Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Analyzer = &analysis.Analyzer{ Name: "toomanytests", Doc: "too many tests in the package", Run: func(pass *analysis.Pass) (any, error) { cnt := 0 for _, f := range pass.Files { astFile := pass.Fset.File(f.Pos()) if !isTestFile(astFile) { continue } for _, n := range f.Decls { funcDecl, ok := n.(*ast.FuncDecl) if ok { if strings.HasPrefix(funcDecl.Name.Name, "Test") && funcDecl.Recv == nil && funcDecl.Name.Name != "TestMain" { cnt++ } } } if cnt > 50 { pass.Reportf(f.Pos(), "%s: Too many test cases in one package", pass.Pkg.Name()) return nil, nil } } return nil, nil }, }
Analyzer is the analyzer struct of toomanytests
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.