Documentation
¶
Overview ¶
Package guards provides source-level regression checks. Consumers run these from their own test suite to prevent a known bug class from silently coming back through a refactor.
Each guard reads files under a directory, applies a regex (or absence check), and reports a failure via the testing.TB so the failure is attributable to the call site.
Index ¶
- func BitBoxDedupOrder(t TB, root, include string)
- func MustMatchAtLeast(t TB, root, include string, pattern *regexp.Regexp, min int, reason string)
- func MustNotMatch(t TB, root, include string, pattern *regexp.Regexp, reason string)
- func MustOrderPaired(t TB, root, include string, first, second *regexp.Regexp, reason string)
- func NoHardcoded10sTransportTimeout(t TB, root, include string)
- func NoNonAsciiInEIP712Literals(t TB, root, include string)
- func RunQuirk(t TB, root, include, quirkID string) int
- type Match
- type TB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitBoxDedupOrder ¶
BitBoxDedupOrder fails if any source file under root reverses the `seenPackets.contains/has/includes` → `seenPackets.clear/removeAll/delete` ordering. Thin wrapper around quirk P2.
func MustMatchAtLeast ¶
MustMatchAtLeast fails t if pattern does not match at least min times. Useful for "every exported func must call recoverPanic" style checks when paired with a tight pattern.
func MustNotMatch ¶
MustNotMatch fails t if pattern matches any line in any file under root matching include (a doublestar-free glob, e.g. "*.go"). reason is shown alongside the failure to explain the rule.
func MustOrderPaired ¶
MustOrderPaired fails t if any file contains `second` on a line that precedes the first occurrence of `first`. The classic motivating bug: `seenPackets.removeAll(...)` called before `seenPackets.contains(...)` in a BLE packet de-dup check.
func NoHardcoded10sTransportTimeout ¶
NoHardcoded10sTransportTimeout fails if any source file contains a hard-coded 10-second timeout pattern in a BitBox transport context. Thin wrapper around quirk A2.
func NoNonAsciiInEIP712Literals ¶
NoNonAsciiInEIP712Literals fails if any file in an EIP-712 context contains string literals with non-ASCII bytes. Thin wrapper around quirk E1.
func RunQuirk ¶
RunQuirk applies every detect rule of the named quirk to source files under `root` matching `include` (a single glob like "*.go"). Each finding becomes a t.Errorf so the failure is attributable to the call site.
Returns the number of findings emitted; usually you discard the value and rely on the test framework's failure tracking.