Documentation
¶
Overview ¶
Package corpus is the public API for analysing a formwork rule corpus.
WHY THIS EXISTS. A tool that asks questions ABOUT a corpus — can this rule ever fail, does this rule still fire, does this arm match anything — has to measure scope with the SAME scanner and matcher the gate engine runs. Re-implementing doublestar matching is not a shortcut, it is the known way to get a wrong answer: a downstream census that did so reported "133 of 200 rules match zero files", and every one of those was an artefact of the re-implementation.
Those parts live under internal/, so Go admits only importers whose module path sits under this module's. Downstream analysers reached them by declaring module paths like github.com/buildfoundry-nz/formwork/vacuitycensus from a different repository entirely — Go's internal rule keys on the import-path prefix, so a module can grant itself access by naming itself into another module's path. Three such modules, some 8,000 lines, depend on that today.
That arrangement works only because Go checks a string prefix rather than actual module membership, and it is invisible from here: a rename under internal/ breaks a build in a repository this one has never heard of. This package replaces the workaround with a supported surface, so an analyser can be an ordinary consumer of a published module (buildfoundry-nz/formwork#5).
The types are aliases, not wrappers. A *Rule obtained here IS the engine's rule, so nothing is lost across the boundary and there is no conversion cost.
Index ¶
Constants ¶
const CostHeavy = rules.CostHeavy
CostHeavy marks a checker that shells out or is otherwise expensive.
const SeverityError = finding.SeverityError
SeverityError is the severity that fails a gate.
Variables ¶
This section is empty.
Functions ¶
func UnderBuiltinSkip ¶
UnderBuiltinSkip reports whether a path sits under a directory the engine always skips. An analyser that does not ask will count files the gate cannot see, and report a rule as covering them.
Types ¶
type AnchorProbe ¶
type AnchorProbe = rules.AnchorProbe
AnchorProbe is the fail-closed half of a NAME-anchored rule type.
type File ¶
File is one scanned file.
func NewMemFile ¶
NewMemFile makes an in-memory file, for probing a rule without touching disk.
type Finding ¶
Finding is one rule violation.
func Unsuppressed ¶
Unsuppressed drops findings an allowlist has silenced. An analyser asking whether a rule CAN fail wants the unsuppressed set: a rule whose every finding is allowlisted is not a rule that fires.