pub fn compute_dead_code<S: BuildHasher>(
graph: &RepoGraph,
entry_def_indices: &HashSet<DefIndex, S>,
include_test_paths: bool,
) -> DeadCodeReportExpand description
Compute the set of definitions unreachable from any entry point.
Returns dead clusters (connected components in the unreachable subgraph), sorted by size descending.
ยงAlgorithm
- Optionally filter test paths from
entry_def_indices(wheninclude_test_pathsisfalse). Test-path heuristic: the file path containstest_,_test,tests/,spec/,specs/, orbench. - BFS forward over
RepoGraph::def_calleesfrom the entry seeds -> reachable set. - Complement
(all_defs - reachable)= dead set. - Connected-components on the dead subgraph via
def_callees + def_callerstreated as undirected (union-find). - For each cluster: pick the highest-rank def as the cluster root;
size= member count;total_lines= sum of(end_line - start_line)per member. - Sort clusters by size descending.