[perfect-ruby-on-rails] Introduce Steep Typechecking#227
Open
hayat01sh1da wants to merge 31 commits into
Open
Conversation
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Add an empty line after magic comments.
…ce-steep-typechecking
…ce-steep-typechecking Co-authored-by: Copilot <copilot@github.com>
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
8a11a2b to
b512cb3
Compare
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
…ce-steep-typechecking
Use expect(:event_id) instead.
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.
1. Why (Purpose)
Rails applications are dynamically typed, so regressions in controllers, models, mailers, jobs and forms are only caught at runtime or by tests.
Adding
rbs-inline(signatures derived from annotated source) together withSteep(the type checker) introduces static verification of method existence, arguments and return types across the codebase.A key motivation is that an apparently small error count is usually misleading.
When the Rails framework signatures are absent, Steep degrades whole class hierarchies to
untypedand silently suppresses everything that depends on them.The objective is therefore not "make the reported errors disappear" but stand up a complete, reproducible type-checking pipeline so the check is genuinely green — framework types resolved, application code annotated, and the real type defects that surface afterwards actually fixed.
2. What (Procedures)
Introducing the pipeline follows a fixed sequence:
steep,rbs-inlineandrbs_railsto the development/test bundle.rbs_collection.yaml+ lock) so framework and common-gem signatures are pulled from a shared, version-pinned source.rbs_railsrake task to emit model and route-helper signatures, and runrbs-inlineto emit signatures from annotated application and test code.Steepfilewith separate targets for application and test code, so permissive test-only signatures never weaken the strictly-checked application code.Context-specific note: when the app runs only in containers, every step above is executed inside the container; when model signatures are generated for apps with a database, the database service must be up and prepared first.
3. How (Operation and Maintenance)
3-1. Run the check
Through the project's normal execution environment(locally or inside the container), invoking
steep check.3-2. Regenerate signatures
As a build step — install the RBS collection, run
rbs-inlineover the source, and run therbs_railstask for models and routes. This is mandatory on a fresh checkout whenever generated signatures are treated as build output rather than committed.3-3. Track vs. regenerate
Steepfile, the collection manifest and lock, the rake task registration, and all hand-written shims (force-track them if they live under an otherwise-ignored signature directory).3-4. Maintenance triggers
rbs_railstask.rbs-inline.4. Pros & Cons
4-2. Pros
4-2. Cons