Skip to content

fix(code-intel): skip tests, trait impls and lib API in dead-code; type-resolved affected - #741

Merged
ajianaz merged 1 commit into
developfrom
fix/dead-code-defaults
Nov 16, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/dead-code-defaults

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • cora dead-code skips by default: #[test] functions, #[cfg(test)] items, files in test directories or named *_tests.rs, and trait-impl methods. pub items count as API surface only in a crate with a lib target. --include-tests and --include-public add them back.
  • cora affected walks callers up to --depth hops (default 3) following only type- or module-resolved edges, prints the shortest edge path for each file, and reports "showing N of M" when --limit truncates.
  • dead_filters.rs is new; the source-level rules read the file at query time, so no schema change is needed.

Why

On a large workspace 913 of 944 dead-code hits were test functions, and affected returned 118 test files because same-named methods of different types were linked. With the typed call edges from the previous change the walk can follow only the right ones. Closes #716.

Testing

  • Unit tests for the source rules (test paths, #[test], cfg(test), trait-impl headers, lib versus bin-only crates), dead-code integration tests for the defaults and the include flags, and affected tests for depth, cycles, ambiguous names and type qualifiers.
  • On this repository dead-code lists 73 symbols instead of 97 (all test functions gone, 33 real pub items of the bin-only crate now shown).
  • cargo fmt --all -- --check, cargo clippy --all-targets --features tree-sitter -- -D warnings, cargo test --features tree-sitter.

…pe-resolved affected

dead-code now skips #[test] fns, cfg(test) items, files in tests dirs or
*_tests.rs and trait-impl methods by default; pub items only count as API
surface in a crate with a lib target. --include-tests and --include-public
add them back.

affected walks callers up to --depth hops (default 3) following only
type- or module-resolved edges, prints the shortest edge path for each
file and reports 'showing N of M' when --limit truncates.

Closes #716
@ajianaz
ajianaz merged commit bbf8efd into develop Nov 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(code-intel): dead-code should skip tests, trait impls and public library items by default; affected should follow type-resolved edges only

1 participant