Repository navigation
Rust: Implement herb-analysis crate based on Rubydex - #1993
Merged
Merged
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Marco Roth <marco.roth@intergga.ch>
🌿 Interactive Playground and Documentation PreviewA preview deployment has been built for this pull request. Try out the changes live in the interactive playground: 🌱 Grown from commit ✅ Preview deployment has been cleaned up. |
commit: |
…s-rust # Conflicts: # lib/herb/analysis/template_dependencies.rb
marcoroth
marked this pull request as ready for review
August 13, 2026 03:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds a
herb-analysiscrate that brings Herb's cross-file static analysis to Rust, backed by rubydex.It started as a spike to evaluate rubydex as a resolution backend and has grown into a full port of the
Herb::Analysisnamespace, including anactionviewcommand set that mirrors the Ruby CLI subcommands.Motivation
#1667 implements Action View template dependency analysis in Ruby. Its weakest part is helper and constant resolution:
scan_helpers!flat-scans everydefinapp/helpers/**/*.rb, so it misses gem-provided helpers, misses helpers reaching the view through included concerns, and records constants as a naive"#{receiver}.#{name}"with no namespace resolution. That drives theunknown_callswarnings.rubydex indexes the analysed app and the gems in its
Gemfile.lock, and walks real ancestor chains. The question worth answering was what that enables in Rust that Ruby cannot reach, and the answer turned out to be most of the warning noise.What the crate provides
The binary exposes two command families. The first are rubydex-backed introspection commands:
helpersreconstructs everything a template in an arbitrary Rails app can call. It resolves gems fromGemfile.lockacross all three source types (registry, git checkouts including monorepo subdirectories, and path sources), discovers helper modules by theinclude_all_helpersconvention that no static index can infer from code, walksActionView::Basefor the built-ins, readshelper_methoddeclarations off controllers, and derives route helpers fromconfig/routes.rb.The second family ports the Ruby
herb actionviewsubcommands:Behind them sit Rust counterparts for
PartialResolution,PartialIndex,PartialDeclaration,RenderGraph,ProjectIndex,TemplateDependencies,StateFlow, andRubyLocalsIndex, so the three implementations now share one architecture.Where Rust goes further than Ruby
Both
checkcommands print the same sections, in the same order, with the same wording. The counts differ, and that difference is the point, Rust resolves names Ruby's scan cannot see.Measured against rubyevents. The remaining Rust figure is dominated by four
ui_*helpers that a component library generates by convention.checkoutput gained three things on both sides:**locals, there is no signature to learn from. Reporting those as missing methods was misleading.Related #1667