matchesRule function ✓ 100.0%
Last updated: 2026-03-02T15:32:34.984Z
Metrics
LOC: 11
Complexity: 6
Params: 2
Coverage: 100.0% (6/6 lines, 74x executed)
Signature
matchesRule(normalized: string, rule: KeywordRule): : boolean
Source Code
function matchesRule(normalized: string, rule: KeywordRule): boolean {
for (const pattern of rule.patterns) {
if (rule.wholeWord) {
const re = new RegExp(`(?<![a-z0-9])${escapeRegex(pattern)}(?![a-z0-9])`);
if (re.test(normalized)) return true;
} else {
if (normalized.includes(pattern)) return true;
}
}
return false;
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| escapeRegex | calls |
| normalized | dynamic_call |
Impact (Incoming)
| Source | Type |
|---|---|
| detect | calls |