vacuity

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 7 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

Package vacuity judges whether a PASS fixture could ever have failed its rule. A pass fixture is green by definition — no finding — so green alone proves nothing: a fixture the rule never reaches, or one that never contains the subject a name-anchored rule watches, is green under any pattern and any scope. Two verdicts, both fail-by-default in `formwork test`:

  • PASS-FIXTURE-VACUOUS: the rule reaches no file of the fixture AND would have judged nothing in it even with a scope that subtracts nothing.
  • PASS-FIXTURE-BLIND: the rule reaches the fixture but the fixture holds no occurrence of the symbol/sink the rule is anchored on (go/call-confined- to-func-name, go/guard-precedes-call only).

Rules whose verdict does not come from a cheap in-process pass over the tree (anything not CostFast: command, git-diff, ...) are "not-judged" — reported, never failed, never silent.

Index

Constants

View Source
const (
	KindJudged    = "judged"
	KindVacuous   = "vacuous"
	KindBlind     = "blind"
	KindNotJudged = "not-judged"
)

Verdict kinds.

View Source
const (
	CodeVacuous = "PASS-FIXTURE-VACUOUS"
	CodeBlind   = "PASS-FIXTURE-BLIND"
)

Verdict codes, carried only by the two failing kinds.

View Source
const NeverMatches = `$^`

NeverMatches compiles and can never match: end-of-text followed by start-of-text. Substituted for the half of a rule that EXCUSES an occurrence (allowed_func, guard), it turns the rule into "flag every occurrence of the anchor".

Variables

This section is empty.

Functions

func AnchorHits

func AnchorHits(r *config.Rule, fs *scan.FileSet, override map[string]string) (int, error)

AnchorHits recompiles r with override applied to its params and returns how many findings the real engine produces over fs. scope.exclude is left as written: a symbol surviving only in a path the rule excludes is invisible TO THE RULE.

func IsEscape

func IsEscape(r *config.Rule) bool

IsEscape reports whether r is outside the verdicts' reach: any cost class other than fast.

func Vacuous

func Vacuous(r *config.Rule, fs *scan.FileSet) (bool, error)

Vacuous reports whether a clean fixture could never have been judged by r: the rule reaches none of its files AND, with a scope subtracting nothing, the engine finds nothing to say about it. "No in-scope file" alone is not the offence — parking a real violation at an excluded path is how an exclusion glob is held in place — so the second half is decided by engine.Run over a universal-scope twin, which gets polarity right (a ban is violated by a match, a required-pattern by an absence) without re-implementing any matcher.

Heavy rules are out of class: their tool runs at the tree root and never consults scope for its verdict.

Types

type AnchorParamSet

type AnchorParamSet struct {
	AllowedFunc string `yaml:"allowed_func"`
	Symbol      string `yaml:"symbol"`
	Sink        string `yaml:"sink"`
	Funcs       string `yaml:"funcs"`
}

AnchorParamSet is the subset of goast params the blind probe anchors on.

func AnchorParams

func AnchorParams(r *config.Rule) (AnchorParamSet, error)

AnchorParams reads the name-anchoring params off the rule as written. Only metadata is read here; every verdict is still rendered by the engine.

type Verdict

type Verdict struct {
	Kind   string // KindJudged | KindVacuous | KindBlind | KindNotJudged
	Code   string // "" | CodeVacuous | CodeBlind
	Reason string // set for every kind except judged
}

Verdict is the judgement of one pass fixture.

func Judge

func Judge(r *config.Rule, fs *scan.FileSet) (Verdict, error)

Judge judges one pass fixture, fs being the fixture's already-walked tree. An escape rule is not-judged. Otherwise vacuous is checked first, then blind; a rule that is neither is judged. A probe that cannot run is an error — the caller must exit 2, never read it as a pass.

func NotJudgedEscape

func NotJudgedEscape(r *config.Rule) Verdict

NotJudgedEscape is the verdict for a rule outside the verdicts' reach. It is exported so a caller that already knows a rule is an escape (the compile-once command path) can report it without a probe.

Jump to

Keyboard shortcuts

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