Skip to content

fix(index): Ruby methods in modules and classes nested in modules are not indexed #791

Closed

Description

@ajianaz

What

Two gaps in the Tree-sitter extractor for Ruby (src/index/ast.rs), both hidden by the module-wide #[allow(dead_code, unused)] that was removed in #798:

  1. Methods inside a module are never indexed. The match has two "module" arms; the first only records the module and shadows the second, which also extracts the methods (unreachable pattern).
  2. Classes and modules nested inside a module or class are never visited. walk_ruby runs on the direct children of the file root only, so the usual layout module Sinatra; class Base; def halt ... end; end; end indexes the module and nothing inside it.

Why

Ruby code puts most of its classes and methods inside modules (gems, Rails concerns, service modules), so search, callers and impact analysis miss a large part of a Ruby project. Measured on Sinatra (147 Ruby files): 79 methods indexed, and def halt (inside class Base inside module Sinatra) is not found.

Testing

  • Tests first, red before the fix: methods of a module are indexed with the module as parent; a class nested in a module, a module nested in a module and the methods of the nested class are indexed; class methods keep working.
  • Measured on Sinatra before and after: indexed methods, classes and modules, index time, and cora explore halt.
  • cargo test --features tree-sitter, cargo fmt --all -- --check and clippy with -D warnings stay green.

Activity

  1. changed the title [-]fix(index): methods defined inside a Ruby module are not indexed[/-] [+]fix(index): Ruby methods in modules and classes nested in modules are not indexed[/+] on Nov 17, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions