You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
In JS, direct function call in a file puts it as dead code, which is somewhat misleading #600
I would like to work on this as part of GSSoC 2026. I traced the module-level call path through the current indexing code: resolve_function_call() returns type: "file" when a call has no enclosing function, build_function_call_groups() puts that into file_to_fn, and GraphWriter.write_function_call_groups() persists a valid (:File)-[:CALLS]->(:Function) edge.
The misleading dead-code result appears to happen later because CodeFinder.find_dead_code() only checks OPTIONAL MATCH (caller:Function)-[:CALLS]->(func). A function called directly from a JavaScript file therefore still gets a caller count of zero even though the graph contains a file-level call edge. SystemTools.find_dead_code_tool() has the same label restriction.
My plan is to update the dead-code checks to count valid incoming CALLS edges from module/file callers as well as function callers, preserve the existing dependency/ignore filtering, and add a regression test covering a JavaScript function invoked at top level. Please assign this to me if that scope matches the intended behavior.
Hi @Shashankss1205, I noticed another contributor has claimed this, but I am still very interested in working on this issue if it becomes available. I have already analyzed the codebase and identified the necessary fix in src/codegraphcontext/tools/code_finder.py. Please let me know if you would like me to proceed with a PR or if there is another way I can help!
But a call at JS module level is not inside a function, so the writer persists it as a File-sourced edge — tools/indexing/persistence/writer.py:848 has an explicit caller_label == "File" branch producing (:File)-[:CALLS]->(:Function).
Those edges exist in the graph and are simply not counted, so caller_count = 0 and the function is reported dead. Exactly the symptom in your screenshot.
Why Python doesn't hit this: the Python parser synthesizes a <module> frame (tools/languages/python.py:211, :493), so module-level calls get a Function caller. javascript.py has no equivalent — which is why this is JS-specific.
Corroboration: the report generator does the same query correctly with an anonymous caller — tools/report_generator.py:229:
ANDNOT ()-[:CALLS|HEURISTIC_CALLS]->(fn)
So the two dead-code implementations already disagree, and the report generator has it right on this point.
Fix: drop the :Function label in code_finder.py:823 so any caller counts (the caller.is_dependency filter on the next line needs to tolerate File nodes, which do carry that property). Adding a synthetic module frame to javascript.py would also work but is a much larger change.
Note this is distinct from #1332 (confidence scoring) — that's a ranking/UX request, whereas this is a plain missed-edge bug. Both should stay open.
Activity
github-actions commentedon Feb 7, 2026
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ
eshaanag commentedon Jun 4, 2026
I would like to work on this as part of GSSoC 2026. I traced the module-level call path through the current indexing code:
resolve_function_call()returnstype: "file"when a call has no enclosing function,build_function_call_groups()puts that intofile_to_fn, andGraphWriter.write_function_call_groups()persists a valid(:File)-[:CALLS]->(:Function)edge.The misleading dead-code result appears to happen later because
CodeFinder.find_dead_code()only checksOPTIONAL MATCH (caller:Function)-[:CALLS]->(func). A function called directly from a JavaScript file therefore still gets a caller count of zero even though the graph contains a file-level call edge.SystemTools.find_dead_code_tool()has the same label restriction.My plan is to update the dead-code checks to count valid incoming
CALLSedges from module/file callers as well as function callers, preserve the existing dependency/ignore filtering, and add a regression test covering a JavaScript function invoked at top level. Please assign this to me if that scope matches the intended behavior.github-actions commentedon Jun 6, 2026
Assigning to the PythonDevs (Core Engine Developers) team.
CC: @CodeGraphContext/pythondevs
github-actions commentedon Jun 6, 2026
Assigning to the AdminArchs (Senior Maintainers & Core Architecture) team.
CC: @CodeGraphContext/adminarchs
UnmeshaSingh commentedon Jun 12, 2026
Hi @Shashankss1205! I'm a GSSoC 2026 contributor and I'd like to work on this issue.
I found the exact bug in the codebase. In src/codegraphcontext/tools/code_finder.py at line 806:
OPTIONAL MATCH (caller:Function)-[:CALLS]->(func)
This only matches Function callers, missing valid File-level callers in JavaScript.
My fix -> change line 806 to:
OPTIONAL MATCH (caller)-[:CALLS]->(func)
WHERE (caller:Function OR caller:File)
AND (caller.is_dependency = false)
This ensures JS functions called directly from a file are not incorrectly marked as dead code.
I'll also add a regression test covering a JS function invoked at top level.
No active assigned issues. PR ready within 3 days.Could you please assign this to me?
Thank you!
WHH-JULIET commentedon Jun 17, 2026
Hi @Shashankss1205, I noticed another contributor has claimed this, but I am still very interested in working on this issue if it becomes available. I have already analyzed the codebase and identified the necessary fix in src/codegraphcontext/tools/code_finder.py. Please let me know if you would like me to proceed with a PR or if there is another way I can help!
Shashankss1205 commentedon Aug 2, 2026
Root cause found — this is a one-word fix, and it's a good first issue for anyone who wants it.
tools/code_finder.py:823only counts Function callers:But a call at JS module level is not inside a function, so the writer persists it as a
File-sourced edge —tools/indexing/persistence/writer.py:848has an explicitcaller_label == "File"branch producing(:File)-[:CALLS]->(:Function).Those edges exist in the graph and are simply not counted, so
caller_count = 0and the function is reported dead. Exactly the symptom in your screenshot.Why Python doesn't hit this: the Python parser synthesizes a
<module>frame (tools/languages/python.py:211,:493), so module-level calls get aFunctioncaller.javascript.pyhas no equivalent — which is why this is JS-specific.Corroboration: the report generator does the same query correctly with an anonymous caller —
tools/report_generator.py:229:So the two dead-code implementations already disagree, and the report generator has it right on this point.
Fix: drop the
:Functionlabel incode_finder.py:823so any caller counts (thecaller.is_dependencyfilter on the next line needs to tolerateFilenodes, which do carry that property). Adding a synthetic module frame tojavascript.pywould also work but is a much larger change.Note this is distinct from #1332 (confidence scoring) — that's a ranking/UX request, whereas this is a plain missed-edge bug. Both should stay open.
WHH-JULIET commentedon Aug 3, 2026
/claim
fix(analysis): make dead-code detection correct and self-consistent (#…
chore(release): bump version to 0.5.7 (#1592)