fix(dead-code): resolve cross-crate method calls + skip public API by default - #529
Merged
Merged
Conversation
…sitives
Method calls inside Rust impl blocks were never walked for call edges
(only top-level free functions were), and method/qualified call targets
stored the raw AST text ('self.export_full', 'std::mem::drop') which can
never join against bare symbol names. Both made find_dead_code flag
symbols that are called across files/crates — 557 false positives on a
5-crate workspace (#519).
- impl-block function bodies now get extract_calls_from_node like free
functions, recording their internal calls
- new normalize_callee_name reduces targets to the final name segment,
so self.x(), manager.y() and std::mem::drop() all land on x/y/drop
- applies to every language routed through the shared walker
Regression tests: bare-name edge extraction (AST level) and a two-file
cross-crate dead-code integration mirroring the uteke case.
Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
Majority of dead-code noise on library workspaces is pub API meant for external consumption — 557 findings on uteke were mostly pub fns in lib crates (#520). Missing internal callers does not make them dead. - find_dead_code skips pub (incl. pub(crate)) and export items by default, keyed off captured signatures; DeadCodeOptions.include_pub_api opts back in - new --include-pub CLI flag and include_pub_api MCP parameter - cora dead-code now resolves the project root exactly like cora index, so queries hit the same workspace project after #522 On cora-code itself: 213 findings drop to 89 with the default filter. Regression test covers pub-skip default, opt-in flag, private helper. Signed-off-by: ajianaz <ajianaz@users.noreply.github.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 #519
Fixes #520
Stacked pair (both target the dead-code usability problem on the uteke workspace, so they share a branch; #520 builds directly on top of #519's edge resolution).
What
#519 — cross-crate method calls not resolved (557 FPs)
self.export_full,std::mem::drop) which can never join against bare symbol namesextract_calls_from_node; newnormalize_callee_namereduces targets to the final name segment. Applies to every language routed through the shared tree-sitter walker#520 — pub API surface counted as dead code
find_dead_codeskipspub(incl.pub(crate)) andexportitems by default, keyed off captured signatures--include-pubCLI flag andinclude_pub_apiMCP parameter opt back incora dead-codenow resolves the project root exactly likecora indexWhy
Dead-code detection produced unusable output on real workspaces: 557 false positives from unresolved cross-crate method calls, plus public API surface counted as dead code.
Testing
All commits signed-off (DCO).