engine

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

allowlist_fold.go — the run-scoped state exemption suppression needs beyond the finding it is judging. Split from engine.go, which the 750-line vendor cap bounds; same package.

Package engine runs compiled rules over a FileSet: phase 1 fans files out to a worker pool, phase 2 fans finalizers out to a second one (spec §6). A crashed rule is an engine error, never a pass (spec §11).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(rls []*config.Rule, fset *scan.FileSet, workers int) ([]finding.Finding, error)

Run evaluates every rule against every in-scope file, then finalizers. workers <= 0 means GOMAXPROCS. Findings come back deterministically sorted and include suppressed findings (spec §5 exemptions): callers that gate on findings must filter with finding.Unsuppressed.

Types

type Timing added in v0.6.2

type Timing map[string]time.Duration

Run evaluates every rule against every in-scope file, then finalizers. workers <= 0 means GOMAXPROCS. Findings come back deterministically sorted and include suppressed findings (spec §5 exemptions): callers that gate on findings must filter with finding.Unsuppressed. Timing records per-rule total evaluation wall time: phase 1 sums the rule's per-file evaluations, phase 2 adds its finalizer. It is observability, never input to a verdict — no finding, sort order, or exit code reads it.

func RunTimed added in v0.6.2

func RunTimed(rls []*config.Rule, fset *scan.FileSet, workers int, progress func(ruleID string, elapsed time.Duration)) ([]finding.Finding, Timing, error)

RunTimed is Run plus per-rule wall-clock accounting, and an optional completion callback: progress (may be nil) is invoked under the findings mutex as each finalizer finishes, with the rule's ID and its accumulated total — the hook behind `check -progress`. That flag exists because a whole-corpus lane can run for minutes with no output (every report format writes at the end), and an operator staring at a silent job cannot tell a slow rule from a hung one. Phase 1 cannot report per-rule completion the same way (a rule is complete only once every file has been visited), so the callback is finalizer-only; Timing covers both phases either way.

func RunTimedHinted added in v0.6.4

func RunTimedHinted(rls []*config.Rule, fset *scan.FileSet, workers int, progress func(ruleID string, elapsed time.Duration), prior Timing) ([]finding.Finding, Timing, error)

RunTimedHinted is RunTimed plus a scheduling hint: prior (may be nil) maps a rule id to the wall time that rule took in a PREVIOUS run — a Timing this package returned, carried across runs by `check --durations <report>`.

It changes the ORDER phase 2 dispatches each pool in, and nothing else. See dispatchOrder for what the order is and why the head start it recovers is worth taking. The hint is advisory in the strongest sense: a stale entry, a partial map, a rule the map does not name, or no map at all are all ordinary inputs, because dispatch order cannot reach a verdict. Findings are sorted before they are returned, the engine error is selected by declaration index, and the ordering is a permutation, so every rule still runs exactly once (TestRunDispatchOrderRunsEveryRuleExactlyOnceInEveryPool).

It does NOT re-order phase 1, and there is nothing there to re-order for: phase 1's pools dispatch FILE indices, and a worker evaluates every applicable rule against the file it took, so a rule's position in that inner loop does not decide when it starts.

Jump to

Keyboard shortcuts

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