test(dead-code): cover find_dead_code end to end through the real parser→writer→query chain - #1598
Conversation
|
@rrodriguesNutrium is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
CI is red on this PR, and I want to save a reviewer the investigation: the failures are pre-existing on The Two distinct clusters, neither related to this diff: 1. 2. i.e. the index/export subprocess errors. That is an infrastructure failure, not a graph-content regression — the golden comparison never runs. Worth being precise about, because this change does add a property ( I ran the full 21-project golden suite green on a related branch too, so the baselines tolerate the added property. One observation, offered as a suggestion rather than part of this PR: the golden test asserts A guard between extraction and comparison — "indexing produced an empty graph, this is an indexing/database failure, not a parser regression" plus the subprocess stderr — would make that class of failure self-diagnosing. Happy to open it as a separate PR if useful. The diff here remains 1 line of source plus a test; |
|
I know the CI is red, I have been merging some PRs and one of them broke this... Will have to check what's the issue before merging others. |
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>
f4a39c6 to
0ef7112
Compare
Shashankss1205
left a comment
There was a problem hiding this comment.
Approving. I verified this test actually has teeth rather than just passing: I swapped in the pre-#1609 writer.py (from 16828c78) and it fails; on current main it passes. So it genuinely closes the gap that let the is_dependency bug ship.
The reasoning in the docstring for using Kotlin rather than Python is the important part and worth preserving — python.py hardcodes "is_dependency": False on every function dict it builds, so a Python-based version of this test would pass even with the bug present and give false confidence. That's exactly the trap the rest of the suite fell into.
Also glad you drove the real tree-sitter parser rather than hand-building file_data. Every hand-built fixture in the suite mirrors what a correct parser would emit, which is precisely why none of them caught it.
Superseded in part by #1609 — rescoped to the test only.
You landed the same one-line fix in #1609 (identical
row.setdefault("is_dependency", is_dependency)), so I have dropped the source change from this branch. It is now purely the complementary test.#1609 added
test_writer_is_dependency_propagation.py, which covers the writer. This covers the other end: the full chain, exercising the tool that was broken.It parses real source with
KotlinTreeSitterParser, writes viaGraphWriter.add_file_to_graph, then callsCodeFinder.find_dead_code()and asserts a genuinely uncalled function is reported. Nothing inmaincurrently exercisesfind_dead_codeagainst a real graph.It builds no
file_databy hand, and that is the entire point. Hand-built fixtures naturally includeis_dependency: Falseon each function dict, so every existing dead-code test passed while the shipped path returned[]for every project, in every language, on every backend. The bug was invisible precisely because no test drove the real path.One detail worth flagging for whoever reviews it: the language choice is load-bearing.
python.py's_find_functionshardcodesis_dependencyper function, so a Python fixture would pass with or without the fix. Kotlin does not. If someone later 'simplifies' this to Python, the test silently stops guarding anything — hence the comment in the file.Verified passing against
mainwith #1609 applied. One file, +90, tests only.Happy to close this instead if you would rather not carry a second test for the same bug — no argument from me either way.