toomanytests

package
v1.1.0-beta.0...-40d2481 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL