fix(#682): callers stops counting trailing-comment mentions as call sites - #683
Conversation
…l sites Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018teBQSh5eSDmojrx12k2jY
…ites
hasWholeWordMatchOutsideStrings now scans only the line's code prefix:
lineCodePrefix truncates at the first line-comment marker outside string
literals, using the same language table as isCommentOrBlank and the same
quote-skipping scan as the string filter. Block-comment openers and
backticks stay untouched (false negatives only re-admit mentions), a
string'd "https://…" never truncates, and shell's `#` only counts at a
word start (`${#var}` is live syntax).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018teBQSh5eSDmojrx12k2jY
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1cc30d9402
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (line[i] == '"' or line[i] == '\'') { | ||
| if (stringLiteralEnd(line, i)) |end| { | ||
| i = end + 1; | ||
| continue; |
There was a problem hiding this comment.
Track raw literals before cutting line comments
When // occurs outside single- or double-quoted strings without opening a line comment, this truncates valid code—for example, const s = https://x`; renderX()in JavaScript/Go orfoo(); /* https://x */ renderX();in C/C++. The prefix ends beforerenderX, so codedb_callers` drops a genuine call site that was reported before this commit; account for backtick/raw/template literals and block-comment spans before accepting a line-comment marker.
Useful? React with 👍 / 👎.
Closes #682.
What
codedb_callersreportedinit(); // then renderX() draws the frameas a call site ofrenderX— the line starts with code soisCommentOrBlankpasses it, and the string filter sees no quotes. Same shape as the string-literal false positives fixed in c23995e, one filter over.How
New
lineCodePrefixtruncates each candidate line at its first line-comment marker outside string literals before the whole-word scan runs:isCommentOrBlank(//C-family/Zig/Rust/Go,#Python/Ruby/R/shell,--SQL,!Fortran,;LLVM IR, HCL both)stringLiteralEndscan, sofetch("https://x", renderX)never truncates#only counts at a word start —${#var}/$#are live syntax/*could drop the real call infoo(); /* … */ bar(); a false negative merely re-admits a mentionTests
issue-682: excludes a symbol mentioned only in a trailing comment— fails on main (committed first, separately, onissue-682-failing-test), passes hereissue-682: keeps a call after a string containing the comment marker— guards the URL casezig build testgreen🤖 Generated with Claude Code
https://claude.ai/code/session_018teBQSh5eSDmojrx12k2jY