Documentation
¶
Index ¶
- Variables
- func LoadPackages(dir string, test bool, patterns []string) ([]*packages.Package, error)
- func ResolveSeverity(category string, policy severity.DiagnosticPolicy) severity.Severity
- func RunPipeline(cfg Config, pkgs []*packages.Package, opts *checker.Options) iter.Seq2[*PhaseResult, error]
- type Config
- type Phase
- type PhaseResult
- type Pipeline
Constants ¶
This section is empty.
Variables ¶
var ( ErrCriticalDiagnostic = errors.New("critical diagnostic") ErrAfterPhase = errors.New("after-phase callback error") )
Functions ¶
func LoadPackages ¶
LoadPackages loads Go packages from the given directory using the specified patterns. When dir is non-empty it is set as the working directory for the package loader; production callers pass "" so that the current working directory is used, while checkertest passes the testdata directory.
func ResolveSeverity ¶
func ResolveSeverity(category string, policy severity.DiagnosticPolicy) severity.Severity
ResolveSeverity finds the severity for a given category.
func RunPipeline ¶
func RunPipeline(cfg Config, pkgs []*packages.Package, opts *checker.Options) iter.Seq2[*PhaseResult, error]
RunPipeline returns an iterator that executes each phase in the config's pipeline sequentially, yielding a *PhaseResult per phase.
For each phase it runs checker.Analyze, then scans root diagnostics using the config's severity.DiagnosticPolicy. Diagnostics classified as severity.SeverityError or severity.SeverityWarn set the corresponding HasError/HasWarn flags on the PhaseResult.
If a severity.SeverityCritical diagnostic is found, the result and an error are yielded together and iteration stops immediately (the AfterPhase callback is NOT invoked and subsequent phases are skipped).
For non-critical phases the AfterPhase callback runs before the result is yielded. If AfterPhase returns an error, the result and the wrapped error are yielded together and iteration stops. If the caller breaks out of the loop, the AfterPhase callback for the current phase has already been invoked.
The opts parameter is passed through to checker.Analyze; production callers set SanityCheck/Sequential/FactLog while checkertest passes nil.
Types ¶
type Config ¶
type Config struct {
// Pipeline defines the phase-ordered analyzer execution plan.
Pipeline Pipeline
// DiagnosticPolicy determines how diagnostic categories map to severity levels and exit codes.
DiagnosticPolicy severity.DiagnosticPolicy
}
Config controls the behavior of the checker.
type Phase ¶
type Phase struct {
// Name is a human-readable label for logging/debugging.
Name string
// Analyzers are the analysis passes to run in this phase.
// Analyzers within a phase may run concurrently across packages.
Analyzers []*analysis.Analyzer
// AfterPhase is an optional callback invoked after all analyzers in this phase
// have completed on all packages and fixes have been applied.
// It receives the resulting Graph, enabling callers to extract per-package
// Action.Result values and aggregate them for consumption by subsequent phases.
AfterPhase func(graph *checker.Graph) error
}
Phase represents a group of analyzers that run together. All analyzers in a phase complete on ALL packages before the next phase starts.
type PhaseResult ¶
type PhaseResult struct {
// Phase is the name of the executed phase.
Phase string
// Graph is the analysis result graph produced by [checker.Analyze] for this phase.
Graph *checker.Graph
// HasError is true if any diagnostics with severity Error were detected in this phase.
HasError bool
// HasWarn is true if any diagnostics with severity Warn were detected in this phase.
HasWarn bool
}
PhaseResult holds the result of executing a single phase.