Ruby Code Analysis
Full analysis of Ruby applications, Rails monoliths, and gem dependency structures
What Axiom Refract Analyzes in Ruby
Require and Autoload Resolution
Resolves require, require_relative, and autoload statements. Handles Rails autoloading conventions (Zeitwerk and classic) that infer file paths from constant names without explicit require statements.
Rails Convention Mapping
Maps Rails MVC structures — models, controllers, views, helpers, concerns, and mailers — using naming conventions. Identifies ActiveRecord associations, route-to-controller mappings, and callback chains.
Module Mixin Dependency Graph
Traces include, extend, and prepend chains across modules and classes. Maps the mixin graph that determines method resolution order and identifies excessive mixin usage patterns.
Metaprogramming Detection
Identifies common metaprogramming patterns including define_method, method_missing, class_eval, and instance_eval. Flags dynamically defined methods that create structural relationships invisible to static analysis.
How It Works
Ruby is parsed using a hand-hardened Tree-sitter grammar supporting Ruby 2.7 through 3.3 syntax, including pattern matching (case/in), numbered block parameters, and data class definitions. The parser handles Ruby's permissive syntax including optional parentheses, multiple return value styles, and block/proc/lambda variations. Rails-specific conventions are detected by recognizing ApplicationRecord, ApplicationController, and similar base class inheritance patterns.
Common Findings in Ruby Codebases
ActiveRecord Model Bloat
Rails models frequently accumulate hundreds of methods through associations, callbacks, scopes, and concerns. Axiom identifies models with high method counts and centrality scores that have become architectural bottlenecks.
Concern Spaghetti
Rails concerns (modules included in models and controllers) create hidden coupling when multiple concerns interact through shared state. Axiom maps concern inclusion graphs and identifies overlapping concern dependencies.
Callback Chain Complexity
ActiveRecord callbacks (before_save, after_commit, etc.) create implicit execution chains that are difficult to trace manually. Axiom maps callback registrations and their structural dependencies.
Polyglot Support
Ruby is one of 145+ languages Axiom Refract supports through Tree-sitter AST parsing. Ruby analysis covers Gemfile, Gemfile.lock, .gemspec files, Rakefile, and Bundler configurations. Rails-specific files including database.yml, routes.rb, and initializers are parsed for additional structural context. Your entire codebase is analyzed in a single scan — regardless of how many languages it contains.