checker

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Overview

Package checker defines the implementation of the checker commands. The same code drives the multi-analysis driver, the single-analysis driver that is conventionally provided for convenience along with each analysis package, and the test driver.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Debug is a set of single-letter flags:
	//
	//	f	show [f]acts as they are created
	// 	p	disable [p]arallel execution of analyzers
	//	s	do additional [s]anity checks on fact types and serialization
	//	t	show [t]iming info (NB: use 'p' flag to avoid GC/scheduler noise)
	//	v	show [v]erbose logging
	//
	Debug = ""

	// Log files for optional performance tracing.
	CPUProfile, MemProfile, Trace string

	// IncludeTests indicates whether test files should be analyzed too.
	IncludeTests = true

	// Fix determines whether to apply all suggested fixes.
	Fix bool
)

Functions

func RegisterFlags

func RegisterFlags()

RegisterFlags registers command-line flags used by the analysis driver.

func Run

func Run(args []string, analyzers []*analysis.Analyzer, opts ...Option) (exitcode int)

Run loads the packages specified by args using go/packages, then applies the specified analyzers to them. Analysis flags must already have been set. Analyzers must be valid according to analysis.Validate. It provides most of the logic for the main functions of both the singlechecker and the multi-analysis commands. It returns the appropriate exit code.

func RunWithResult added in v0.1.7

func RunWithResult(args []string, analyzers []*analysis.Analyzer, opts ...Option) (analyzerResults map[*analysis.Analyzer]interface{}, diagnostics []analysis.SimpleDiagnostic, err error)

Run loads the packages specified by args using go/packages, then applies the specified analyzers to them. Analysis flags must already have been set. Analyzers must be valid according to analysis.Validate.

Returns results and diagnostics produced by the analyzers.

Types

type Option added in v0.1.3

type Option func(option *checkerOptions)

func WithBypassImportAnalysis added in v0.1.9

func WithBypassImportAnalysis(shouldBypass bool) Option

WithBypassImportAnalysis dictates whether analysis is performed on imported packages.

func WithLoadConfig added in v0.1.3

func WithLoadConfig(config packages.Config) Option

func WithRunDespiteLoadErrors added in v0.1.5

func WithRunDespiteLoadErrors(shouldRun bool) Option

type TestAnalyzerResult

type TestAnalyzerResult struct {
	Pass        *analysis.Pass
	Diagnostics []analysis.Diagnostic
	Facts       map[types.Object][]analysis.Fact
	Result      interface{}
	Err         error
}

func TestAnalyzer

func TestAnalyzer(a *analysis.Analyzer, pkgs []*packages.Package) []*TestAnalyzerResult

TestAnalyzer applies an analyzer to a set of packages (and their dependencies if necessary) and returns the results. The analyzer must be valid according to analysis.Validate.

Facts about pkg are returned in a map keyed by object; package facts have a nil key.

This entry point is used only by analysistest.

Jump to

Keyboard shortcuts

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