Shopify / Shopify/rubydex

Migrate Spoom to use Rubydex

Open
#290 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
355
Forks
24
Avg merge
2d 6h
Merged PRs (30d)
17

Description

Spoom performs its own indexing to power a few different features from metrics collection to dead code detection.

  1. Code metrics (CodeMetricsVisitor): collects a bunch of metrics about the code and gradual typing usage:

    • number of classes, modules, singleton classes (with and without type members)
    • number of RBS scope annotations (@abstract, @interface, etc.)
    • number of methods (singleton or not)
    • number of attribute accessors
    • number of signatures (sig or RBS comment)
    • number of T. calls
    • number of RBS inline assertion comments

    This can all be replace by querying the global graph if we support RBS comments.

  2. Model representation (Model): builds a complete representation of the declarations, definitions and their relationship form a codebase. This is the meat behind dead code detection and any "smart" analysis that needs advanced features like constant resolution or inheritance linearization.

    I believe this whole part of the codebase should be replace 1:1 by Saturn. This is going to be an invasive change.

  3. Dead code detection (Deadcode) this comes with many sub-features:

    • Indexing both .rb and .erb files
    • Indexing declarations by unqualified names
    • Indexing references to unqualified names (both constants and methods)
    • Plugin system to listen to events such as entering a definition or entering a call

There is some work in progress here: https://github.com/Shopify/spoom/blob/at-test-indexer/lib/spoom/deadcode/index.rb and early results are really encouraging with a 5x speed increase and 2x less memory.

Image

Contributor guide

Open the contributing guide

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.

Research direction

Start by reading lib/spoom/sorbet/metrics/code_metrics_visitor.rb, lib/spoom/model/model.rb, and lib/spoom/deadcode/index.rb. Compare the existing dead-code index with the at-test-indexer branch and identify how Rubydex or Saturn would cover metrics, model representation, and dead-code indexing. Done means these indexing responsibilities are migrated without losing the listed features.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, rust
Domain
devtools, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.