Skip to content

Add Ruby support to repository analysis - #97

Merged
anhnh2002 merged 1 commit into
mainfrom
feat/ruby-analyzer
Aug 24, 2026
Merged

Add Ruby support to repository analysis#97
anhnh2002 merged 1 commit into
mainfrom
feat/ruby-analyzer

Conversation

@anhnh2002

@anhnh2002 anhnh2002 commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a Ruby language analyzer, closing a coverage gap: .rb was already in CODE_EXTENSIONS and the default include patterns, but there was no analyzer and ruby was missing from the language whitelist, so Ruby files silently produced zero components.

How

New analyzers/ruby.py following the same tree-sitter pattern as the Kotlin/PHP analyzers (#33):

  • Components: module, class (with superclass as base_classes), instance methods, singleton methods (def self.x, def Foo.x, class << self), and top-level functions. initialize is registered for call resolution but not emitted as a component, mirroring the JS constructor rule.
  • Relationships: inheritance, include/extend/prepend mixins, Const.new instantiation, and method calls with implicit-self, constant, and inferred receivers (x = Foo.new; x.bar). Intra-file calls resolve against a same-file symbol table; unresolved callees stay bare logical names for the global resolver.
  • Noise control: curated frozensets of Kernel/Enumerable/String methods and stdlib constants keep puts/each/File.read-style calls out of the graph.

Registration follows the Kotlin precedent end-to-end: language whitelist, dispatcher branch + wrapper, CLI validation/repo validator, prompt code-fence map, MCP change detection, cytoscape class, entry-point/function patterns, and the tree-sitter-ruby dependency in pyproject.toml + requirements.txt.

Tests

tests/test_ruby_analyzer.py (first analyzer tests in the suite): unit tests for component extraction, docstrings/parameters, and call relationships, plus a DependencyParser end-to-end test proving the whitelist/dispatcher wiring. Sanity-checked against the Logstash repo: 3,200 Ruby components extracted (previously 0), including logstash-core/lib, lib/pluginmanager, and x-pack.

The touched files also carry the mechanical ruff cleanup the Lint job requires (it runs modern-default ruff over every changed file, same situation as before): import sorting, formatting, typing modernization, logger.exception, and noqa'd intentional blanket handlers. No behavior changes outside the Ruby addition.

New tree-sitter based Ruby analyzer extracting modules, classes,
methods, and singleton methods, with call relationships for
inheritance, include/extend/prepend mixins, instantiation, and
method calls (implicit-self, constant, and inferred receivers).
Kernel/stdlib noise is pruned via curated core-method and builtin
constant sets.

Wired through the language whitelist, dispatcher, CLI validation,
prompt code-fence map, MCP change detection, and packaging
(tree-sitter-ruby dependency). Includes analyzer unit tests and a
DependencyParser end-to-end test.

Touched files also get the mechanical ruff cleanup the CI lint job
requires (modern defaults over every changed file): import sorting,
ruff format, typing modernization, logger.exception, and noqa'd
intentional blanket handlers.
@anhnh2002
anhnh2002 merged commit 8e4b82b into main Aug 24, 2026
2 checks passed
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