fix(writer): propagate is_dependency so find_dead_code works for all languages - #1609
Merged
Merged
Conversation
find_dead_code filters on `func.is_dependency = false`. Roughly half the language extractors never emit the property per item, and in Cypher `null = false` is null rather than false -- so every function from those extractors was silently discarded and the tool returned an empty list. Reproduced on a 4-function Kotlin project (both backends): every Function node had is_dependency = null and `cgc analyze dead-code` reported "No dead code found" despite an obviously-uncalled function. Python was unaffected because python.py emits the property itself. setdefault is used so extractors that compute it per item keep their value. Module is excluded -- it is the one label in item_mappings with no is_dependency column in the schema. Fixes the 7th report in #1595. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ |
Contributor
🔍 PR Code Graph Analysisfix(writer): propagate is_dependency so find_dead_code works for all languages (#1609) 📊 Interactive VisualizationView the blast radius graph: PR Reviewer Dashboard 📦 ArtifactsThe graph JSON has been uploaded as a build artifact: Generated by CodeGraphContext using FalkorDB Lite |
rrodriguesNutrium
added a commit
to rrodriguesNutrium/CodeGraphContext
that referenced
this pull request
Aug 13, 2026
CodeGraphContext#1609 fixed the is_dependency propagation and added a writer-level test. This adds the complementary end-to-end case: parse real source with a real parser, write via GraphWriter.add_file_to_graph, then call CodeFinder.find_dead_code and assert a genuinely uncalled function is reported. It builds no file_data by hand, which is the point. Hand-built fixtures naturally include is_dependency, so every existing test passed while the shipped path returned nothing for every project. The language choice is load-bearing: python.py's _find_functions hardcodes is_dependency per function, so a Python fixture would pass with or without the fix. Kotlin does not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 13, 2026
Merged
rrodriguesNutrium
added a commit
to rrodriguesNutrium/CodeGraphContext
that referenced
this pull request
Aug 13, 2026
Kotlin had no golden despite sample_project_kotlin existing in fixtures, so nothing asserted on the Kotlin graph's contents. The goldens are the only tests in the repo that check real graph output end to end. Everything else asserts on the parser's return dict built from hand-written fixtures -- which is how the is_dependency bug fixed in CodeGraphContext#1609 stayed invisible while the suite was green. Baseline captures 216 nodes / 278 edges, with is_dependency=False on all 50 Function nodes and decorators populated on 5. The absolute repo root inside each `uid` is normalised to <REPO_ROOT> so the fixture carries no developer's home directory. `uid` is listed in the test's VOLATILE_NODE_KEYS and is never compared, so this does not affect the assertion. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Shashankss1205
pushed a commit
that referenced
this pull request
Aug 13, 2026
…in (#1598) #1609 fixed the is_dependency propagation and added a writer-level test. This adds the complementary end-to-end case: parse real source with a real parser, write via GraphWriter.add_file_to_graph, then call CodeFinder.find_dead_code and assert a genuinely uncalled function is reported. It builds no file_data by hand, which is the point. Hand-built fixtures naturally include is_dependency, so every existing test passed while the shipped path returned nothing for every project. The language choice is load-bearing: python.py's _find_functions hardcodes is_dependency per function, so a Python fixture would pass with or without the fix. Kotlin does not. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Shashankss1205
pushed a commit
that referenced
this pull request
Aug 13, 2026
…1618) Kotlin had no golden despite sample_project_kotlin existing in fixtures, so nothing asserted on the Kotlin graph's contents. The goldens are the only tests in the repo that check real graph output end to end. Everything else asserts on the parser's return dict built from hand-written fixtures -- which is how the is_dependency bug fixed in #1609 stayed invisible while the suite was green. Baseline captures 216 nodes / 278 edges, with is_dependency=False on all 50 Function nodes and decorators populated on 5. The absolute repo root inside each `uid` is normalised to <REPO_ROOT> so the fixture carries no developer's home directory. `uid` is listed in the test's VOLATILE_NODE_KEYS and is never compared, so this does not affect the assertion. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes the 7th report in #1595 (credit @rrodriguesNutrium). This is a total feature outage for roughly half the supported languages.
The bug
find_dead_codeopens with (code_finder.py:857):but the writer never sets that property on contained items.
add_file_to_graphbuilds each row asrow = dict(item)and adds onlypathandcyclomatic_complexity—is_dependencyis read fromfile_datafor the File node and never propagated down.In Cypher
null = falseevaluates to null, not false, so every affected Function row is discarded and the tool returns an empty list.It's language-dependent
The original report suggested this affects everything. It's narrower and that's why it hid so well: about half the extractors emit
is_dependencyper item and half don't.python.pydoes, so Python works;kotlin.pydoesn't, so Kotlin silently returns nothing.Reproduced on a 4-function Kotlin project, both backends:
Same Python project as a control returned 25 functions both before and after — unaffected, as expected.
The fix
One line in the item loop:
setdefaultrather than assignment so extractors that compute this per item keep their own answer — which also correctly marks functions inside dependency files.Moduleis excluded because it is the one label initem_mappingswith nois_dependencycolumn in the schema.I chose the writer over making the query null-tolerant (
coalesce(...)) because the property is genuinely expected to be present —code_finder.pyreadscaller.is_dependencya few lines later, and the asymmetry between the two sides is itself the hint.Combined effect with #1596
The chain the reporter was actually after now works end to end:
Tests
Three regression tests driving the real
GraphWriterpath with item dicts that omitis_dependency— the reporter correctly identified that existing tests hand-buildfile_datawith the property, which is exactly why the suite never caught this. Verified they fail onmainand pass with the fix.Stacked on #1599 (the CI fix); the integration numbers above include it.