Skip to content

Implement cora dead-code CLI command #427

Description

@ajianaz

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

  1. Add DeadCode subcommand to src/commands/mod.rs
  2. Create src/commands/dead_code.rs
  3. 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)
  4. Filter entry points: main, new, drop, default, #[tokio::main], pub fn (if visibility info available)
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurescope:cliCLI interface and UXscope:code-intelCode intelligence — indexing, graph, impact analysis

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions