Repository navigation
fix(code-intel): skip tests, trait impls and lib API in dead-code; type-resolved affected - #741
Merged
Merged
Conversation
…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
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.
What
cora dead-codeskips by default:#[test]functions,#[cfg(test)]items, files in test directories or named*_tests.rs, and trait-impl methods.pubitems count as API surface only in a crate with a lib target.--include-testsand--include-publicadd them back.cora affectedwalks callers up to--depthhops (default 3) following only type- or module-resolved edges, prints the shortest edge path for each file, and reports "showing N of M" when--limittruncates.dead_filters.rsis 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
affectedreturned 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
#[test],cfg(test), trait-impl headers, lib versus bin-only crates), dead-code integration tests for the defaults and the include flags, andaffectedtests for depth, cycles, ambiguous names and type qualifiers.dead-codelists 73 symbols instead of 97 (all test functions gone, 33 realpubitems 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.