bugfix(audit): word-boundary terminology match — fix false positive on substring#10
Open
CryptoJones wants to merge 1 commit into
Open
bugfix(audit): word-boundary terminology match — fix false positive on substring#10CryptoJones wants to merge 1 commit into
CryptoJones wants to merge 1 commit into
Conversation
…n substring
TerminologyUsedCheck did a naive substring search:
if term.lower() not in other_text.lower(): flag()
That false-positives whenever a defined term happens to appear inside
a longer word in some other planning file:
term 'lien' matches 'client', 'reliant', 'aliens'
term 'tier' matches 'tiers', 'outlier', 'frontier'
term 'rebate' matches 'rebated'
term 'state' matches 'estate', 'statement', 'statehouse'
When that happens the term gets silently rated as "used elsewhere" and
NEVER flagged — undermining the whole point of the check, which is to
catch dead glossary entries.
Fix: same word-boundary regex with kebab-friendly boundary chars used
by the patterns.py fix:
(?<![\w-]){re.escape(term)}(?![\w-])
Matches multi-word and kebab-case terms as complete tokens; refuses to
match inside a longer identifier.
Test added: define `lien` in DOMAIN.md; the clean_project fixture's
rendered files mention `client` everywhere (which contains `lien` as
a substring). Pre-fix the check silently swallowed the warning;
post-fix `lien` is correctly flagged as orphaned.
148/148 tests pass; ruff + mypy clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TerminologyUsedCheck did a naive substring search:
That false-positives whenever a defined term happens to appear inside
a longer word in some other planning file:
term 'lien' matches 'client', 'reliant', 'aliens'
term 'tier' matches 'tiers', 'outlier', 'frontier'
term 'rebate' matches 'rebated'
term 'state' matches 'estate', 'statement', 'statehouse'
When that happens the term gets silently rated as "used elsewhere" and
NEVER flagged — undermining the whole point of the check, which is to
catch dead glossary entries.
Fix: same word-boundary regex with kebab-friendly boundary chars used
by the patterns.py fix:
(?<![\w-]){re.escape(term)}(?![\w-])
Matches multi-word and kebab-case terms as complete tokens; refuses to
match inside a longer identifier.
Test added: define
lienin DOMAIN.md; the clean_project fixture'srendered files mention
clienteverywhere (which containslienasa substring). Pre-fix the check silently swallowed the warning;
post-fix
lienis correctly flagged as orphaned.148/148 tests pass; ruff + mypy clean.