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 ¶
const ( KindJudged = "judged" KindVacuous = "vacuous" KindBlind = "blind" KindNotJudged = "not-judged" )
Verdict kinds.
const ( CodeVacuous = "PASS-FIXTURE-VACUOUS" CodeBlind = "PASS-FIXTURE-BLIND" )
Verdict codes, carried only by the two failing kinds.
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 ¶
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 ¶
IsEscape reports whether r is outside the verdicts' reach: any cost class other than fast.
func Vacuous ¶
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 ¶
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 ¶
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.