BannedPattern class

One banned: entry: copy this project does not ship, plus the reason a reviewer should read when it fires.

The motivating case is punctuation policy — a project that has ruled out em-dashes in user-facing copy — but the mechanism is general: any literal or regular expression that should never reach a screen.

Two kinds of exception, because real projects have both:

  • This one use is right. dialect check --ack banned_pattern:… fingerprints the value it excused, so editing the copy retires the waiver by itself.
  • These keys are ruled exempt, permanently. except names them. A ruling survives a typo fix, so it must not expire when the value changes the way an ack does.

A permanent list is the thing that rots, so banned_pattern audits its own: a key in except whose value no longer contains the pattern is reported, and the list can only shrink.

Constructors

BannedPattern({required String pattern, required String reason, bool isRegex = false, List<String> locales = const [], List<String> except = const []})

Properties

except → List<String>
Keys ruled exempt from this pattern for good — a standing decision, not a one-off waiver. Audited: see BannedPattern.
final
hashCode → int
The hash code for this object.
no setterinherited
isRegex → bool
Whether pattern is a regular expression. Literal is the default so a pattern full of punctuation needs no escaping.
final
locales → List<String>
Locales this applies to. Empty means every locale, including the source. [en] scopes a rule about English phrasing to English.
final
pattern → String
The literal text (default) or regular expression (regex: true) that must not appear in a value.
final
reason → String
Why it is banned, and what to write instead. Shown verbatim as the issue hint, so it should read as advice, not as a restatement of the pattern.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

appliesTo(String locale) → bool
Whether this pattern is enforced in locale, where the source locale is named by its own tag (a ban on em-dashes applies to the English source as much as to any translation).
excuses(String key) → bool
Whether key is permanently exempt from this pattern.
firstMatch(String value) → String?
The first occurrence of this pattern in value, or null. Returning the matched text (rather than a bool) lets the issue quote what it actually found, which matters when the pattern is a regex.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited