Skip to main content

Pattern Check

The Pattern Check holds each translatable block's source text to regular expressions the caller names. --forbid gives a pattern that must not appear and --require one that must, both repeatable, and both reported at major severity: pattern.forbidden-pattern when a forbidden pattern is found, and pattern.pattern-missing when a required one is absent. A forbidden-pattern finding carries the text it matched, so the block and the offending words are both named.

The patterns are Go regular expressions, matched as written: no implicit case folding and no implicit word boundaries, so (?i)todo is how case is ignored and \bdraft\b is how a whole word is asked for. An empty pattern, one that does not compile, or a rule that both requires and forbids is refused when the check is built, rather than quietly passing everything.

It is the escape hatch beside the checks that know what they are looking for. A voice profile carries the vocabulary a project decided, and terms carry the words it agreed on; a pattern is for the bar that has no vocabulary behind it, such as a placeholder syntax that must survive or a marker that must never ship.

Checkpattern-check
Rule familypattern.*
SourceBuilt-in

Rules

A finding carries one of these rule ids. The family is pattern, which differs from the check id the code registers.

RuleSeverityReportsFix
pattern.forbidden-patternmajor

The block's source text matches a pattern given with --forbid. The finding carries the text it matched.

Remove or reword the matched text, or drop the pattern from the run when the text is intended.

pattern.pattern-missingmajor

The block's source text does not match a pattern given with --require. Every block is held to every required pattern.

Add the required text to the block, or narrow the run to the files the requirement applies to.

Flags

FlagValuesDescription
--forbidGo regular expression, repeatable

Reports every block whose source matches. Repeatable, so several prohibitions can be given in one run.

--requireGo regular expression, repeatable

Reports every block whose source does not match. Repeatable. Applied per block, so a pattern only one section of a document carries reports everywhere else.

Processing notes

  • Off unless a pattern is given, so an ordinary check run reports nothing from it.

  • Runs over translatable blocks; content a reader surfaces as structure or code is never matched.

  • An empty or uncompilable pattern, and a rule that both requires and forbids, are errors when the check is built.

Limitations

  • Reads source text only; whether a translation preserved a pattern is the bilingual qa check's question.

  • A required pattern is asked of every block, so it suits a rule that is true of each block rather than of a document as a whole.

  • Matching is over the block's plain text, so a pattern cannot address the runs a placeholder or an inline code stands for.

← Back to the Check Reference