Skip to content

feat(code-intel): dead-code should skip tests, trait impls and public library items by default; affected should follow type-resolved edges only #716

Closed

Description

@ajianaz

What problem does this solve?

On tole (8c05cd1, a 124,600-line Rust workspace):

  • cora dead-code lists 944 "potentially dead" symbols; 913 of them are #[test] functions and test helpers (files named *_tests.rs or under tests/), which are called by the test harness and are not dead. Only 31 are not in test files, and the two I checked were false positives (see the macro issue).
  • Library crates such as tole-core are published, so their pub items are API even without an in-workspace caller; trait implementations are called through dispatch.
  • cora affected crates/tole-core/src/web.rs returns 118 test files. The real set is web.rs's own inline tests plus a handful of CLI tests. This is a consequence of name-only resolution (a separate issue), but even with correct edges affected needs a granularity rule.

Proposed solution

  1. dead-code defaults: skip #[test], #[cfg(test)] modules, files matching the configured test glob, main, trait implementation methods, and pub items of a lib crate (flag --include-public, --include-tests to add them back). Report a confidence per hit (no edge at all versus only ambiguous edges).
  2. affected: walk only type-resolved call and import edges, stop at depth N (default 3, flag), and report why each test file is included (the shortest edge path), so the list is checkable.
  3. Add a count and the cut-off to the output when a list is truncated.

Alternatives considered

Keep the current behaviour and document that results need checking with grep (the current state). That makes impact, affected and dead-code unusable for decisions.

Are you willing to contribute the implementation?

Yes, I can do it

Tracking issue with the measured table: codecoradev/tole#669.

Before submitting

  • I searched existing issues and didn't find a duplicate

Activity

  1. added
    enhancement
    scope:code-intel
    epic:code-intelligence
    on Nov 13, 2026
  2. added a commit that references this issue on Nov 16, 2026
    8fa430f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementepic:code-intelligencepriority:mediumscope:code-intel

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions