You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(index): cora dead-code flags functions passed as values and functions named in serde attributes #802
Run on this repository after the dead code was removed (#798), cora dead-code flags 43 symbols and none is really dead: 25 are functions named in serde attributes (#[serde(default = "default_true")], deserialize_with, skip_serializing_if, with), 13 are called from production code, mostly passed as a value without parentheses (.and_then(quote_key), .map(ScanFile::post_image), .is_some_and(commit_gate::alias_runs_commit), .map_or_else(TokenInfo::zero, TokenInfo::from_usage)), and 5 are only used by tests (those are correct findings). The Rust extractor records an edge only for a call_expression and for a call inside a macro, so neither form creates one, and cora callers, impact and dead-code treat the function as unused.
Fix: in the Rust extractor, record a Calls edge for a function path passed as an argument (a bare snake_case identifier or a Type::f / module::f path; constants, enum variants and types are skipped) and for the function named in a serde attribute of a struct or enum (the struct is the caller).
Why
Most of a dead-code report is noise today, so people stop reading it, and callers and impact miss real dependents (a function passed to .map is called by the function that passes it).
Testing
Tests first, red before: a function and an associated function passed to .map(..), with a constant, None and an enum variant in the same call that must not create an edge; serde attributes with a plain name and a path (crate::de::lenient); a negative test for a string that only looks like an attribute.
Measured on this repository: the number of symbols cora dead-code reports, before and after (43 now), and how many of the remainder are real.
cargo test --features tree-sitter, cargo fmt --all -- --check and clippy with -D warnings stay green.
Activity