Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scripts/comment-census.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ def extract_blocks(lines: List[str], ext: str) -> Tuple[int, int, List[CommentBl
def analyze_block(lines: List[str]) -> CommentBlock:
"""Analyze a comment block for citations."""
text = ' '.join(lines)
text_without_entities = re.sub(r'&#\d+;', '', text)
return CommentBlock(
lines=len(lines),
cites_issue=bool(ISSUE_PATTERN.search(text)),
cites_adr=bool(ADR_PATTERN.search(text))
cites_issue=bool(ISSUE_PATTERN.search(text_without_entities)),
cites_adr=bool(ADR_PATTERN.search(text_without_entities))
)


Expand Down
21 changes: 21 additions & 0 deletions tests/comment-census.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,24 @@ function main() {}`,
assert.equal(result.status, 0);
assert.match(result.stdout, /comment.*4/i);
});

test("census ignores HTML entities as issue citations", () => {
const result = runCensus({
"test.js": `// Entity j is not an issue
// Neither is ' or "
function main() {}`,
});

assert.equal(result.status, 0);
assert.match(result.stdout, /citing issue.*0/i);
});

test("census still detects real issue citations after stripping entities", () => {
const result = runCensus({
"test.js": `// Entity j mixed with issue #371
function main() {}`,
});

assert.equal(result.status, 0);
assert.match(result.stdout, /citing issue.*1/i);
});