Skip to content

refactor: remove the dead code hidden behind allow(dead_code) - #798

Merged
ajianaz merged 1 commit into
developfrom
refactor/remove-dead-code
Nov 17, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/remove-dead-code

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

All #[allow(dead_code)] attributes and the module-wide #[allow(dead_code, unused)] of src/index/ast.rs are removed, and the compiler's answer is applied (checked on the default build, on the test targets, and with --no-default-features):

  • Deleted, because nothing used them, tests included: read_config, write_config and the YAML agent-config path (ConfigFormat::Yaml, the YAML helpers, the install and validate branches), find_fn_generic, find_pattern_in_file, is_inside_git_repo, is_hook_installed, extract_edges, store_kg_edges, clear_kg_edges_for_file, KgEdge, McpConfig, five error variants that were never created (LlmJsonRepair, DiffTooLarge, ScannerError, HookError, Timeout), the unused IssueType enum with its tests, the EdgeKind::ChildOf variant, a no-op "declaration" arm and a leftover edge_kind variable in the AST extractors, and the unused re-exports of index::graph.
  • Kept for tests only, now #[cfg(test)]: for example run_rules, parse_and_run_rules, SCHEMA_VERSION and several index helpers.
  • extract_calls stays as the regex fallback, now compiled only without the tree-sitter feature (it is what extract_all calls there).
  • cora install --yes stays accepted (scripts may pass it) but has no effect, as before; the internal field that was never read is gone and the help and docs/cli-reference.md say so.
  • What is written but not wired in yet keeps a narrow, commented #[allow(dead_code)] pointing to decide: wire in or remove code that is written but not used (bundling engine, AstNode.parent, context stats) #792 (the file bundling engine, AstNode.parent, context stats); the one Ruby bug the removal uncovered keeps a targeted #[allow(unreachable_patterns)] pointing to fix(index): Ruby methods in modules and classes nested in modules are not indexed #791.

Why

The attributes silenced the compiler, so dead code stayed, went stale and misleads readers; 524 lines are gone and the compiler reports unused code again. Removing the module-wide allow also surfaced three real problems, each in its own issue: methods inside a Ruby module are not indexed (#791), a documented but unwired bundling engine (#792), and --no-default-features already did not compile on develop (#793). Closes #790.

Testing

  • cargo check is warning-free on the default build and on the test targets; cargo test --features tree-sitter: 1543 passed, 0 failed (13 tests of the deleted IssueType went with it); cargo fmt --all -- --check and clippy with -D warnings clean.
  • cargo check --no-default-features fails with the same two errors as on develop before this change (build: cargo build --no-default-features does not compile, and CI does not check it #793), nothing new.
  • Cora review of the staged diff: no findings. It was blocked by two false majors from index-breaking-change until fix(rules): ignore callers that the same diff deletes in index-breaking-change #795 made the rule ignore callers deleted in the same diff; this PR is the real case that measured that fix.
  • Items were only deleted when rustc reported them unused for the test targets as well; everything used by tests was gated, not deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: remove the dead code hidden behind #[allow(dead_code)]

1 participant