Expose comment groups that aren't attached to a definition

Open
#1,081 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@efegokdemir is already working on this.

Since Oct 24, 2026.

  • #1084 by @efegokdemir — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
ruby, rust
Domain
tooling

Research direction

Start by tracing how Rubydex groups comments during indexing and where it associates them with definitions, focusing on Definition#comments and the document representation. Review the standalone RBS alias example and the related module_function def case to understand which groups are currently discarded. Done means unattached groups are retained and can be queried per document or by prefix without making linter rules reread every file.

Written by the indexing model from the issue text.

Description

Rubydex groups consecutive comments while indexing, but keeps a group only when it sits
directly above a definition, and exposes it only through Definition#comments. Every other
comment group is dropped at index time.

That makes some linter rules expensive. Our case is an RBS inline type alias on its own in a
class body, which isn't attached to anything:

    class Foo
      #: type rel = Shop::PrivateRelation
 
      def bar; end
    end

A rule that needs to see that alias has to re-read every file from disk. Over ~155k files that
costs 16–18s, against about 3s for a rule that only walks Definition#comments, even though
the indexer already read and parsed those comments.
https://delta.shopify.io/shop/world/pull/2278180

Proposal: keep unattached comment groups and expose them per document (e.g. Document#comments),
or offer a graph-wide query by prefix such as #:. A longer-term option is to index inline RBS
annotations, like #: type aliases, as their own definition kind.

Related: comments on a module_function def aren't attached to the method definition either.

Dominant language
Rust
Stars
382
Forks
30
Avg merge
16h 57m
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Shopify/rubydex

All issues in Shopify/rubydex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.