Part of #426.
Task
Implement cora dead-code CLI subcommand.
Spec
cora dead-code # List unreachable functions
cora dead-code --json # JSON output
cora dead-code --include-tests # Include test functions
cora dead-code --min-lines 5 # Filter functions shorter than 5 lines
cora dead-code --kind function # Filter by symbol kind
Implementation
- Add
DeadCode subcommand to src/commands/mod.rs
- Create
src/commands/dead_code.rs
- Query:
SELECT s.name, s.kind, s.file, s.line FROM symbols s LEFT JOIN call_graph cg ON cg.callee = s.name WHERE cg.id IS NULL AND s.kind IN (function, method)
- Filter entry points: main, new, drop, default, #[tokio::main], pub fn (if visibility info available)
- Output: pretty table (default), JSON (
--json), compact
SQL Query (initial draft)
SELECT s.name, s.kind, s.file, s.line, s.signature
FROM symbols s
LEFT JOIN call_graph cg ON cg.callee = s.name AND cg.project_id = s.project_id
WHERE cg.id IS NULL
AND s.kind IN (function, method, procedure)
AND s.name NOT IN (main, new, drop, default, fmt, clone, from)
ORDER BY s.file, s.line
Acceptance
cora dead-code runs without error on cora-code repo
- Returns list of functions with zero callers
--json flag produces valid JSON
--include-tests and --min-lines flags work
Est: 1-2 days
Part of #426.
Task
Implement
cora dead-codeCLI subcommand.Spec
Implementation
DeadCodesubcommand tosrc/commands/mod.rssrc/commands/dead_code.rsSELECT s.name, s.kind, s.file, s.line FROM symbols s LEFT JOIN call_graph cg ON cg.callee = s.name WHERE cg.id IS NULL AND s.kind IN (function, method)--json), compactSQL Query (initial draft)
Acceptance
cora dead-coderuns without error on cora-code repo--jsonflag produces valid JSON--include-testsand--min-linesflags workEst: 1-2 days