Skip to content

Add detect_dead_constants MCP tool#652

Draft
st0012 wants to merge 1 commit intomainfrom
explore-detect-dead-constants
Draft

Add detect_dead_constants MCP tool#652
st0012 wants to merge 1 commit intomainfrom
explore-detect-dead-constants

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Mar 6, 2026

Summary

Adds a detect_dead_constants MCP tool that finds Ruby constants with zero resolved references — dead code candidates.

Supports kind filter, file_path prefix filter, and pagination. Excludes infrastructure declarations and anonymous classes.

Real-world validation

Tested against RDoc (411 declarations in lib/). Instead of cross-referencing all 411 constants manually with grep, detect_dead_constants narrowed the list to 22 candidates instantly. After filtering false positives (dynamic access via const_get/const_defined?, type annotations), 5 confirmed dead constants were removed: ruby/rdoc#1642

Also tested against Tapioca (48 candidates in lib/), which surfaced 1 confirmed dead constant (ASSOCIATION_METHODS).

@st0012 st0012 force-pushed the explore-detect-dead-constants branch from 78806c4 to 9fc7b28 Compare March 6, 2026 17:11
@st0012 st0012 force-pushed the add-pagination-support-rubydex-mcp branch 2 times, most recently from ab1dff0 to ecd1dc0 Compare March 6, 2026 21:19
Base automatically changed from add-pagination-support-rubydex-mcp to main March 11, 2026 16:52
@st0012 st0012 force-pushed the explore-detect-dead-constants branch from 9fc7b28 to bba9f45 Compare March 12, 2026 12:14
@st0012 st0012 self-assigned this Mar 12, 2026
Find Ruby classes, modules, and constants with zero resolved references
across the codebase. Uses rubydex's semantic resolution for high accuracy
compared to string-matching approaches.

- Params: kind filter, file_path prefix, limit/offset pagination
- Response: name, kind, file, line, owner per dead constant
- Excludes infrastructure declarations (Object, BasicObject, Module, Class)
- Sorted by FQN for deterministic pagination
@st0012 st0012 force-pushed the explore-detect-dead-constants branch from bba9f45 to 8e4a222 Compare March 12, 2026 12:24
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.

1 participant