testonly

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReportViolations

func ReportViolations(pass *analysis.Pass, violations []TestOnlyViolation)

ReportViolations reports testonly violations using the new pretty formatter NOTE: violations should already be filtered by @ignore directives in CheckTestOnly

Types

type TestOnlyViolation

type TestOnlyViolation struct {
	Pos         token.Pos
	TestOnlyObj string // Name of the @testonly object being used
	Kind        annotations.TestOnlyKind
	UsedInFile  string // File where @testonly object is used
	Reason      string
	Code        string // Error code from codes package
}

TestOnlyViolation represents a violation of @testonly usage @immutable implements reporting.Violation

func CheckTestOnly

func CheckTestOnly(
	cfg *config.Config,
	pass *analysis.Pass,
	packageAnnotations *annotations.PackageAnnotations,
	ignoreSet *util.IgnoreSet,
) []TestOnlyViolation

CheckTestOnly checks that @testonly annotated items are only used in test files

func (TestOnlyViolation) GetCode

func (v TestOnlyViolation) GetCode() string

GetCode returns the error code for this violation

func (TestOnlyViolation) GetMessage

func (v TestOnlyViolation) GetMessage() string

GetMessage returns the main error message without formatting

func (TestOnlyViolation) GetPos

func (v TestOnlyViolation) GetPos() token.Pos

GetPos returns the position of the violation

Jump to

Keyboard shortcuts

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