-
-
Notifications
You must be signed in to change notification settings - Fork 638
Add RBS validation and runtime type checking to CI #1950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 54 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (18)
WalkthroughAdds RBS signatures for ReactOnRailsPro, adds RBS/Steep tooling and Steepfile, updates rake tasks and RSpec hooks to run/enable RBS runtime checks, adjusts CI workflows to validate RBS signatures (Steep check kept commented/TODO), and updates docs and dev dependencies. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant CI as CI Job
participant Rake as Rake
participant RBS as rbs CLI
participant Steep as steep CLI
participant Test as RSpec
CI->>Rake: invoke rbs validate step (bundle exec rake rbs:validate)
Rake->>RBS: run `rbs -I sig validate` (Open3.capture3)
alt RBS passes
RBS-->>CI: exit 0 (success)
else RBS fails
RBS-->>CI: non‑zero exit + captured stdout/stderr
end
Note over Rake,Steep: Local developer flow
Rake->>Rake: `rake rbs:validate` → runs RBS validate
Rake->>Steep: `rake rbs:steep` → runs `steep check` (captures output)
Rake->>Rake: `rake rbs:all` depends on validate + steep
Note over Test: Runtime hook injection
Rake->>Test: run specs with env from `rbs_runtime_env_vars` (sets RBS_TEST_TARGET, RUBYOPT for RBS test hook)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review: Add RBS validation and runtime type checking to CIOverall AssessmentThis PR successfully implements comprehensive RBS type checking infrastructure following industry best practices. The implementation is well-structured and provides three complementary layers of type safety: validation, runtime checking, and static analysis. Strengths
Critical Issues1. Runtime Type Checking May Cause CI Failures Location: rakelib/run_rspec.rake:27 Adding runtime type checking will cause tests to fail if method signatures don't match actual usage. Recommendation: Verify all existing RBS signatures are accurate before merging, or document expected test failures. 2. Type Signature Accuracy Location: react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs:11-12 DEFAULT_DEPENDENCY_GLOBS and DEFAULT_EXCLUDED_DEPENDENCY_GLOBS use Array[untyped] - these should be Array[String]. 3. Pro Package Incomplete The Pro package only has validation, not runtime checking or Steep analysis. Consider adding the three-layer approach to Pro for consistency. 4. Documentation Gap No updates about RBS type checking in documentation. Add a section explaining how to run checks and add signatures. Performance Considerations
Monitor CI times after merge. Consider running Steep only on main/PR branches if it becomes slow. Pre-Merge Checklist
SummaryHigh-quality PR adding valuable type safety. Main concern: ensure runtime checking doesn't break tests. Recommendation: Approve with minor changes - fix Array[untyped] and verify tests pass. Great work! The three-layer approach is exactly right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/pro-lint.yml (1)
126-127: Consider using rake task for consistency.The main lint workflow (
.github/workflows/lint-js-and-ruby.yml) usesbundle exec rake rbs:validateandbundle exec rake rbs:steep, but this Pro workflow uses the direct commandbundle exec rbs -I sig validate. Additionally, the Steep check is missing here.Consider updating to match the main workflow for consistency:
- - name: Validate RBS type signatures - run: bundle exec rbs -I sig validate + - name: Validate RBS type signatures + run: bundle exec rake rbs:validate + + - name: Run Steep type checker + run: bundle exec rake rbs:steepBenefits:
- Consistent approach across workflows
- Standardized success/failure messaging from rake tasks
- Includes Steep static analysis for more comprehensive type checking
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Gemfile.lockis excluded by!**/*.lock
📒 Files selected for processing (11)
.github/workflows/lint-js-and-ruby.yml(1 hunks).github/workflows/pro-lint.yml(1 hunks)Gemfile.development_dependencies(1 hunks)Steepfile(1 hunks)rakelib/rbs.rake(1 hunks)rakelib/run_rspec.rake(1 hunks)react_on_rails_pro/sig/react_on_rails_pro.rbs(1 hunks)react_on_rails_pro/sig/react_on_rails_pro/cache.rbs(1 hunks)react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs(1 hunks)react_on_rails_pro/sig/react_on_rails_pro/error.rbs(1 hunks)react_on_rails_pro/sig/react_on_rails_pro/utils.rbs(1 hunks)
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1875
File: lib/react_on_rails/utils.rb:112-124
Timestamp: 2025-10-23T17:22:01.074Z
Learning: In React on Rails, when Pro is installed but not licensed, the intended behavior is to raise an error on boot. The `react_on_rails_pro?` method validates licenses and should raise errors early (including during path resolution in methods like `server_bundle?`) to enforce licensing requirements rather than failing later with obscure errors.
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation is handled in deeper level calls of the React on Rails Pro codebase, so it doesn't need to be validated again in the `rsc_payload_react_component` helper method.
📚 Learning: 2025-09-16T08:01:11.146Z
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1770
File: lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx:2-2
Timestamp: 2025-09-16T08:01:11.146Z
Learning: React on Rails uses webpack CSS Modules configuration with namedExports: true, which requires the import syntax `import * as style from './file.module.css'` rather than the default export pattern. This configuration enables better tree shaking and bundle size optimization for CSS modules.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/utils.rbsreact_on_rails_pro/sig/react_on_rails_pro.rbsreact_on_rails_pro/sig/react_on_rails_pro/configuration.rbsreact_on_rails_pro/sig/react_on_rails_pro/cache.rbsreact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2025-02-12T16:38:06.537Z
Learnt from: Romex91
Repo: shakacode/react_on_rails PR: 1697
File: package-scripts.yml:28-28
Timestamp: 2025-02-12T16:38:06.537Z
Learning: The file `node_package/lib/ReactOnRails.full.js` is autogenerated during the build process and should not be present in the repository.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/utils.rbsreact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2025-10-23T17:22:01.074Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1875
File: lib/react_on_rails/utils.rb:112-124
Timestamp: 2025-10-23T17:22:01.074Z
Learning: In React on Rails, when Pro is installed but not licensed, the intended behavior is to raise an error on boot. The `react_on_rails_pro?` method validates licenses and should raise errors early (including during path resolution in methods like `server_bundle?`) to enforce licensing requirements rather than failing later with obscure errors.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/utils.rbsreact_on_rails_pro/sig/react_on_rails_pro.rbsreact_on_rails_pro/sig/react_on_rails_pro/configuration.rbsreact_on_rails_pro/sig/react_on_rails_pro/cache.rbsreact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2025-09-15T21:24:48.207Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1781
File: node_package/src/ClientSideRenderer.ts:82-95
Timestamp: 2025-09-15T21:24:48.207Z
Learning: In React on Rails, the force_load feature includes both explicit `data-force-load="true"` usage and the ability to hydrate components during the page loading state (`document.readyState === 'loading'`). Both capabilities require a Pro license, so the condition `!railsContext.rorPro && (isComponentForceLoaded || document.readyState === 'loading')` correctly gates both scenarios.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/utils.rbsreact_on_rails_pro/sig/react_on_rails_pro.rbsreact_on_rails_pro/sig/react_on_rails_pro/configuration.rbsreact_on_rails_pro/sig/react_on_rails_pro/cache.rbsreact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2025-02-18T13:08:01.477Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/utils.rbsreact_on_rails_pro/sig/react_on_rails_pro.rbsreact_on_rails_pro/sig/react_on_rails_pro/configuration.rbsreact_on_rails_pro/sig/react_on_rails_pro/cache.rbsreact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2025-04-26T21:55:55.874Z
Learnt from: alexeyr-ci2
Repo: shakacode/react_on_rails PR: 1732
File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44
Timestamp: 2025-04-26T21:55:55.874Z
Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/utils.rbsreact_on_rails_pro/sig/react_on_rails_pro/configuration.rbs
📚 Learning: 2025-02-13T16:50:47.848Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: node_package/src/clientStartup.ts:18-21
Timestamp: 2025-02-13T16:50:47.848Z
Learning: In the react_on_rails module, the `reactOnRailsPageUnloaded` function in clientStartup.ts is intentionally kept private as it's only used internally as a callback for `onPageUnloaded`.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro.rbsreact_on_rails_pro/sig/react_on_rails_pro/cache.rbsreact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2025-07-08T05:57:29.630Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1745
File: node_package/src/RSCRequestTracker.ts:8-14
Timestamp: 2025-07-08T05:57:29.630Z
Learning: The global `generateRSCPayload` function in React on Rails Pro (RORP) is provided by the framework during rendering requests, not implemented in application code. The `declare global` statements are used to document the expected interface that RORP will inject at runtime.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro.rbsreact_on_rails_pro/sig/react_on_rails_pro/configuration.rbsreact_on_rails_pro/sig/react_on_rails_pro/cache.rbsreact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2024-06-27T05:22:46.156Z
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1622
File: spec/dummy/spec/rake/assets_precompile_rake_spec.rb:12-12
Timestamp: 2024-06-27T05:22:46.156Z
Learning: When stubbing environment variables in RSpec tests, use `before` and `after` hooks to ensure that the original values are restored after the tests, preventing any side effects on other tests. Example provided by justin808:
```ruby
describe "My test" do
before do
original_value = ENV["VARIABLE_NAME"]
allow(ENV).to receive(:[]).with("VARIABLE_NAME").and_return("stubbed_value")
end
after do
allow(ENV).to receive(:[]).with("VARIABLE_NAME").and_call_original
ENV["VARIABLE_NAME"] = original_value
end
it "tests something" do
# Your test code here
end
end
```
This practice ensures test isolation and reliability.
Applied to files:
rakelib/run_rspec.rake
📚 Learning: 2025-02-13T14:29:49.267Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: spec/react_on_rails/utils_spec.rb:218-218
Timestamp: 2025-02-13T14:29:49.267Z
Learning: In RSpec tests, prefer using local variables over constants within test blocks to avoid constant redefinition warnings and maintain better test isolation.
Applied to files:
rakelib/run_rspec.rake
📚 Learning: 2024-12-12T13:07:09.929Z
Learnt from: alexeyr-ci
Repo: shakacode/react_on_rails PR: 1644
File: node_package/src/ReactOnRailsRSC.ts:87-87
Timestamp: 2024-12-12T13:07:09.929Z
Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging.
Applied to files:
rakelib/run_rspec.rakereact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2025-02-18T13:08:01.477Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation is handled in deeper level calls of the React on Rails Pro codebase, so it doesn't need to be validated again in the `rsc_payload_react_component` helper method.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/configuration.rbsreact_on_rails_pro/sig/react_on_rails_pro/error.rbs
📚 Learning: 2025-02-13T16:50:26.861Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: node_package/src/turbolinksUtils.ts:34-36
Timestamp: 2025-02-13T16:50:26.861Z
Learning: In React on Rails, when checking for Turbolinks version 5 using `turbolinksVersion5()`, always ensure `Turbolinks` exists first by checking `turbolinksInstalled()` to prevent TypeError when accessing properties.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/error.rbs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: build
- GitHub Check: build-dummy-app-webpack-test-bundles
- GitHub Check: build-dummy-app-webpack-test-bundles (3.2, 20, minimum)
- GitHub Check: build-dummy-app-webpack-test-bundles (3.4, 22, latest)
- GitHub Check: rspec-package-tests (3.4, latest)
- GitHub Check: rspec-package-tests (3.2, minimum)
- GitHub Check: lint-js-and-ruby
- GitHub Check: build-dummy-app-webpack-test-bundles
- GitHub Check: claude-review
🔇 Additional comments (4)
.github/workflows/lint-js-and-ruby.yml (1)
92-95: LGTM! Well-integrated type checking steps.The new RBS validation and Steep type checking steps are well-positioned in the workflow after Ruby linting. Using the rake tasks (
rbs:validateandrbs:steep) provides consistency and proper error handling.Steepfile (1)
1-24: LGTM! Solid foundation for type checking.The Steepfile configuration provides a good starting point for static type analysis. The target definition correctly specifies the source (
lib) and signature (sig) directories, and includes commonly-used standard library signatures.rakelib/rbs.rake (1)
38-57: LGTM! Excellent implementation following established patterns.The new
rbs:steeptask follows the same structure as the existingrbs:validatetask with:
- Clear status messages
- Proper error handling for all cases (success, failure, command not found)
- Appropriate exit codes
The
rbs:alltask provides a convenient way to run both checks in sequence.react_on_rails_pro/sig/react_on_rails_pro.rbs (1)
1-5: LGTM! Method implementations verified.Both
configureandconfigurationmethods exist in the ReactOnRailsPro module atreact_on_rails_pro/lib/react_on_rails_pro/configuration.rb. The implementations match their RBS signatures:configureyields a Configuration block (line 4-7), andconfigurationprovides lazy-loaded access to the Configuration instance (line 9+).
| attr_accessor prerender_caching: bool? | ||
| attr_accessor renderer_http_pool_size: Integer? | ||
| attr_accessor renderer_http_pool_timeout: Integer? | ||
| attr_accessor renderer_http_pool_warn_timeout: Float? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow integers for warn timeout.
Many existing configs (including spec/dummy/config/initializers/react_on_rails_pro.rb) assign config.renderer_http_pool_warn_timeout = 5, which is an Integer. With runtime RBS enabled, this setter will now raise a TypeError because Integer is not a Float. Please widen the type to accept any numeric value. (github.com)
- attr_accessor renderer_http_pool_warn_timeout: Float?
+ attr_accessor renderer_http_pool_warn_timeout: Numeric?📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| attr_accessor renderer_http_pool_warn_timeout: Float? | |
| attr_accessor renderer_http_pool_warn_timeout: Numeric? |
🤖 Prompt for AI Agents
In react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs around line 34,
the attr_accessor currently restricts renderer_http_pool_warn_timeout to Float?
which rejects Integer assignments at runtime; change the type to accept any
numeric value (e.g., Numeric?) while preserving nilability so existing integer
assignments like `= 5` no longer raise a TypeError.
| attr_accessor rendering_returns_promises: bool? | ||
| attr_accessor remote_bundle_cache_adapter: Module? | ||
| attr_accessor ssr_pre_hook_js: String? | ||
| attr_accessor assets_to_copy: Array[String]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accept Pathname entries in assets_to_copy.
Our sample initializer passes Rails.root.join(...) values to config.assets_to_copy, which yield Pathname objects. The new signature forces String, so runtime checking will blow up immediately. Please permit both String and Pathname. (github.com)
- attr_accessor assets_to_copy: Array[String]?
+ attr_accessor assets_to_copy: Array[String | Pathname]?📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| attr_accessor assets_to_copy: Array[String]? | |
| attr_accessor assets_to_copy: Array[String | Pathname]? |
🤖 Prompt for AI Agents
In react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs around line 40,
the typed signature for assets_to_copy currently only permits Array[String] but
the initializer may pass Pathname objects; update the signature to accept both
String and Pathname (e.g. an array element union) and keep the optionality, so
callers can provide Array[String | Pathname] or nil; adjust any related type
aliases/imports if needed to reference Pathname in the rbs file.
Code Review: Add RBS validation and runtime type checking to CII've reviewed PR #1950 and have the following feedback: ✅ Strengths
🐛 Issues FoundCritical: RBS Type Signature Errors1. Cache module signature is incorrect (react_on_rails_pro/sig/react_on_rails_pro/cache.rbs:3) The signature shows: def self.fetch: (String key) { () -> String } -> StringBut the actual implementation in
Recommendation: The RBS signature should match the actual API: class ReactOnRailsPro::Cache
class << self
def fetch_react_component: (String component_name, Hash[Symbol, untyped] options) { () -> untyped } -> untyped
def use_cache?: (Hash[Symbol, untyped] options) -> bool
def base_cache_key: (String type, ?prerender: bool?) -> Array[untyped]
def dependencies_cache_key: () -> String?
def react_component_cache_key: (String component_name, Hash[Symbol, untyped] options) -> Array[untyped]
end
end2. Utils module has missing methods (react_on_rails_pro/sig/react_on_rails_pro/utils.rbs) The signature only includes: def self.bundle_js_file_path: (String bundle_name) -> String
def self.running_on_windows?: () -> boolBut the actual
Also, Recommendation: Add comprehensive signatures for all public methods in Utils module. Minor Issues3. Steep configuration may need more libraries (Steepfile:18-23) The Steepfile includes basic libraries but may need additional ones based on the actual dependencies used in the codebase (e.g., 4. Runtime type checking only applies to gem tests (rakelib/run_rspec.rake:24-28) Runtime checking is only enabled for 📋 Suggestions
🔒 Security ConsiderationsNo security concerns identified. Type checking actually improves security by catching type-related bugs. ⚡ Performance Considerations
✅ Test CoverageThe PR appropriately integrates type checking into existing test workflows. The runtime checking during gem tests will help validate signatures against actual usage. Action ItemsBefore merging:
SummaryThis is a valuable addition to the project's quality infrastructure. The main issues are incorrect RBS signatures that need to be fixed before the CI checks will pass. Once the signatures accurately reflect the actual code, this will provide excellent type safety guarantees. Great work on adopting modern Ruby type checking practices! 🎉 |
PR Review: Add RBS validation and runtime type checking to CISummaryThis PR implements comprehensive RBS type checking infrastructure for both the main gem and Pro package. The implementation follows best practices from Evil Martians' "Climbing Steep Hills" article with a three-pronged approach: validation, runtime checking, and static analysis. Strengths1. Well-Structured CI Integration ✓
2. Runtime Type Checking ✓
3. Good Documentation ✓
4. Incremental Adoption ✓
Issues and Recommendations1. Potential Issue: Array Type Precision (Minor)Location: react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs:12-13 Using Array[untyped] defeats the purpose of type checking. These appear to be string arrays based on the attribute signatures. Recommendation: Change to Array[String] 2. Potential Bug: System Call Error Handling (Medium)Location: rakelib/rbs.rake:13, rakelib/rbs.rake:43 Direct system calls without bundle exec might fail in environments where gems aren't in PATH. If someone runs bundle install --path vendor/bundle, gem binaries won't be in PATH. Recommendation: Use bundle exec rbs and bundle exec steep in the system calls. 3. Test Coverage Gap (Medium)No tests verify that RBS signatures are loaded correctly or that runtime type checking works. Consider adding tests in spec/react_on_rails/ to verify the rake tasks work correctly. 4. Pro Gem Gemfile.lock Missing (Minor)Added rbs to Pro gem dependencies but Gemfile.lock not updated. Run bundle install in react_on_rails_pro/. Security ConcernsNo security issues identified. This PR improves security through better type validation. Performance Considerations
Monitor CI build times after merge. When Steep is enabled, it can be slow on large codebases (1-5 minutes). Code QualityStrengths:
Minor improvements possible:
Final RecommendationStatus: ✅ Approve with Minor Changes Required Changes:
Suggested Changes:
Overall Assessment: Great work on following the Evil Martians article and setting up all three type checking approaches! 📝 Review completed by Claude Code |
Code Review: Add RBS validation and runtime type checking to CISummaryThis PR adds comprehensive RBS type checking infrastructure. Overall well-structured implementation following Ruby type checking best practices, with a few issues to address. Critical Issues1. Inconsistency in rbs.rake - bundle exec removed incorrectly Problem: Removing bundle exec assumes rake runs in bundle context, but this only happens with 'bundle exec rake'. Direct 'rake' calls will fail if gems aren't in system path. Recommendation: Keep 'bundle exec' in system calls for both rbs and steep commands. 2. Missing Error Handling for Runtime Type Checking Problems: Silent failures if RBS fails to load, no opt-out mechanism, environment pollution via RUBYOPT. Recommendation: Add conditional check with ENV opt-out and RBS availability validation. High Priority3. Type Signature Accuracy - react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs:11-12 4. Cache.fetch Block Signature - react_on_rails_pro/sig/react_on_rails_pro/cache.rbs:3 Medium Priority5. Steepfile Scope - Use 'check lib' with ignore patterns vs listing individual files Positive Observations
Recommendations SummaryMust fix: Issues 1 and 2 ConclusionSolid foundation for type safety. After addressing bundle exec and runtime checking validation, ready to merge. Great work! Status: Requesting changes for issues 1 and 2 |
Pull Request Review: Add RBS validation and runtime type checking to CIOverall AssessmentThis is a well-structured PR that implements comprehensive type checking for the React on Rails gem. The approach is methodical and follows Ruby best practices for gradual type adoption. Overall: ✅ Approved with minor suggestions ✅ Code Quality & Best PracticesStrengths
|
Code Review: RBS Validation and Runtime Type CheckingI've reviewed this PR and overall it's a solid implementation of RBS type checking infrastructure. Here's my feedback: ✅ Strengths
🔍 Issues & Concerns1. Critical: Inconsistency in rake tasks (rakelib/rbs.rake)Issue: The file shows two different versions:
Current state in repository: # Line 13 - BEFORE changes
result = system("bundle exec rbs -I sig validate")
# Line 13 - AFTER changes (in diff)
result = system("rbs -I sig validate")Problem: The comment says "use rbs directly, not bundle exec since we're already in bundle context", but:
Recommendation: Verify that the changes from commit 058d25e were properly applied. The file should use 2. Runtime Type Checking Scope (rakelib/run_rspec.rake:25-27)Issue: Runtime type checking only runs for Current: task :gem do
run_tests_in("",
rspec_args: File.join("spec", "react_on_rails"),
env_vars: "RBS_TEST_TARGET='ReactOnRails::*' RUBYOPT='-rrbs/test/setup'")
endQuestions:
Recommendation: Document why runtime checking is only enabled for 3. Steepfile - Incomplete Library DependenciesThe Steepfile only lists 5 library dependencies: library "pathname"
library "singleton"
library "logger"
library "monitor"
library "securerandom"Missing common Rails/Ruby dependencies that the codebase likely uses:
Impact: Steep may not properly type-check code that uses these libraries, leading to false positives/negatives. Recommendation:
4. Type Signature Quality (Pro Package)Concern: Some type signatures use DEFAULT_DEPENDENCY_GLOBS: Array[untyped]
DEFAULT_EXCLUDED_DEPENDENCY_GLOBS: Array[untyped]From implementation (configuration.rb:49-50): DEFAULT_DEPENDENCY_GLOBS = [].freeze
DEFAULT_EXCLUDED_DEPENDENCY_GLOBS = [].freezeRecommendation: These should be DEFAULT_DEPENDENCY_GLOBS: Array[String]
DEFAULT_EXCLUDED_DEPENDENCY_GLOBS: Array[String]5. Cache Module Type Signature Accuracydef self.fetch: (String key) { () -> String } -> StringQuestion: Does the block always return
Recommendation: Verify the actual usage and ensure the signature matches all use cases. 🎯 RecommendationsHigh Priority
Medium Priority
Nice to Have
🧪 Testing RecommendationsBefore merging:
📚 Documentation SuggestionsConsider adding to CLAUDE.md:
Security & Performance✅ No security concerns - type signatures are compile/check-time only SummaryThis is a well-structured PR that lays excellent groundwork for type safety. The main issues are:
The phased rollout approach (validation now, Steep later) is pragmatic and reduces risk. Verdict: ✅ Approve with minor fixes recommended Great work on adopting modern Ruby type checking! This will significantly improve code quality and IDE support. 🤖 Review by Claude Code |
Code Review - PR #1950: Add RBS validation and runtime type checking to CISummaryThis PR adds comprehensive RBS type checking infrastructure for both the main gem and Pro package. Overall, this is a solid enhancement that follows Ruby type-checking best practices. Strengths1. Excellent Three-Pronged ApproachThe implementation follows Evil Martians best practices with static validation, runtime checking, and static analysis with Steep. 2. Well-Structured RBS Signatures for ProThe Pro gem type signatures are well-crafted with complete coverage of Configuration class and proper use of nilable types. 3. Smart CI Integration StrategyPragmatic approach: validation enabled, Steep disabled until signatures are complete (374 errors to fix first). 4. Clear DocumentationThe PR description is excellent with clear explanations and test plan. Issues & Concerns1. CRITICAL: Inconsistency in run_rspec.rake (lines 24-26)Issue: The PR diff shows RBS runtime checking added to the :gem task, but the actual file does NOT contain this change. The runtime type checking configuration appears to be missing from the code! Impact: Tests won't validate RBS signatures at runtime, defeating one of the three pillars of the type-checking strategy. Action Required: Verify the change is actually applied to the file. 2. Inconsistency: bundle exec (rakelib/rbs.rake:13 vs :steep task)Issue: rbs:validate uses "bundle exec rbs" but rbs:steep uses "steep check" without bundle exec. This is inconsistent and potentially fragile. Recommendation: Be consistent - standardize on one approach for reliability. 3. Missing Runtime Checking for Pro GemMain gem gets runtime checking via RBS_TEST_TARGET but Pro gem only gets static validation. Consider adding runtime type checking to Pro gem tests for consistency. 4. Missing Test Coverage VerificationTest plan shows CI validation items unchecked. Has this actually been tested in CI? Performance ConsiderationsRuntime type checking with rbs/test/setup can slow down test execution 10-30%. Consider documenting this and making it optional via ENV variable. RecommendationsHigh Priority (Must Fix):
Medium Priority: Low Priority: ConclusionOverall Assessment: Well-thought-out PR with sound strategy and well-crafted signatures. Blocking Issues: run_rspec.rake and bundle exec inconsistencies need resolution. Score: 7.5/10 (would be 9/10 if inconsistencies resolved) Great work bringing type safety to React on Rails! |
rakelib/run_rspec.rake
Outdated
| run_tests_in("", rspec_args: File.join("spec", "react_on_rails")) | ||
| run_tests_in("", | ||
| rspec_args: File.join("spec", "react_on_rails"), | ||
| env_vars: "RBS_TEST_TARGET='ReactOnRails::*' RUBYOPT='-rrbs/test/setup'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might make sense to pass these options when starting the server in integration tests too, but not 100% sure.
| check "lib/react_on_rails.rb" | ||
| check "lib/react_on_rails/configuration.rb" | ||
| check "lib/react_on_rails/controller.rb" | ||
| check "lib/react_on_rails/git_utils.rb" | ||
| check "lib/react_on_rails/helper.rb" | ||
| check "lib/react_on_rails/packer_utils.rb" | ||
| check "lib/react_on_rails/server_rendering_pool.rb" | ||
| check "lib/react_on_rails/test_helper.rb" | ||
| check "lib/react_on_rails/utils.rb" | ||
| check "lib/react_on_rails/version_checker.rb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not have to maintain this list, just iterate over all files in lib and check for each if it has a signature in sig.
Code Review - PR #1950: Add RBS validation and runtime type checking to CISummaryThis PR adds comprehensive RBS type checking infrastructure to both the main gem and Pro package. Overall, this is a well-structured and valuable addition that will improve type safety. I've identified several issues that should be addressed before merging. Critical Issues1. Inconsistency in rakelib/rbs.rakeLocation: Issue: The diff shows a comment change to "use rbs directly, not bundle exec since we're already in bundle context" but the actual code at line 13 still uses Impact: This inconsistency is confusing and suggests incomplete refactoring. Recommendation: Either remove 2. Incomplete Runtime Checking CoverageLocation: Issue: Runtime type checking (RBS_TEST_TARGET) is only enabled for the Impact: Incomplete test coverage. If dummy/example tests exercise gem code paths not covered by gem specs, type errors could slip through. Recommendation: Consider enabling runtime checking for dummy and example tasks if they exercise ReactOnRails:: code per the Evil Martians article emphasis on comprehensive runtime checking. High Priority Issues3. Pro Gem Configuration Types Could Be More SpecificLocation: Issue: Uses Recommendation: Replace with more specific types where possible (e.g., 4. Limited Steepfile ScopeLocation: Issue: Only 10 files are checked. The limited positive list makes it easy to forget adding new files. Recommendation: Add comments documenting which directories/files are intentionally excluded and why. Consider creating a follow-up issue to expand coverage incrementally. Medium Priority Issues5. Steep Disabled in CILocation: Issue: Steep is commented out with TODO about 374 type errors. Recommendation: File a follow-up issue with concrete plan to enable Steep in CI. Consider running Steep only on the 10 files listed in Steepfile if those are clean. 6. Pro Gem Missing Steep ConfigurationLocation: Issue: Pro gem gets RBS validation but lacks Steepfile, steep rake tasks, and runtime checking in tests. Recommendation: Add Steep configuration to Pro gem for consistency. Positive Aspects
Performance ConsiderationsRuntime checking adds overhead during tests - monitor test suite execution time. Consider using RBS_TEST_SAMPLE_SIZE if slowdown is significant. Steep can be slow on large codebases - consider running only on changed files in PRs once enabled, or caching analysis results. Test Coverage Analysis✅ RBS validation runs in CI (syntax checking) Recommendations SummaryMust Fix Before Merge
Should Fix Before Merge
Nice to Have
ConclusionThis is a solid foundation for type safety. The approach follows best practices and implementation is clean. However, the limited scope (Steep disabled, only 10 files checked, no Pro gem Steep config) means this is more scaffolding than complete type safety. Recommendation: Approve with changes for critical issues. Ensure clear roadmap for:
The infrastructure is good - now it needs to be fully utilized. Great work following the Evil Martians guide and setting up comprehensive type checking infrastructure! |
Code Review - PR #1950: Add RBS validation and runtime type checking to CII've reviewed this PR implementing comprehensive RBS type checking. Overall, this is a well-structured addition that follows Ruby typing best practices. Here are my findings: ✅ Strengths
🔍 Issues & ConcernsCritical Issues
Moderate Issues
Minor Issues
🎯 Recommendations
📊 Overall AssessmentThis is a valuable addition that will improve code quality and catch type-related bugs early. However, the critical issues with Recommendation: Request changes to address critical issues #1 and #2 before approval. 🤖 Generated with Claude Code |
Code Review: RBS Validation and Runtime Type CheckingThank you for this comprehensive PR implementing RBS type checking! This is a well-structured addition that follows best practices from the Evil Martians guide. Here's my feedback: ✅ Strengths
🔍 Issues & SuggestionsCritical Issues
Minor Issues
🔒 Security Considerations
⚡ Performance Considerations
🧪 Test Coverage
📋 Code Quality
🎯 Overall AssessmentThis is a high-quality PR that takes a pragmatic approach to gradual type adoption. The implementation is solid, documentation is excellent, and the architecture is sound. Recommendation: Request changes to address the 3 critical issues, especially enabling runtime checking in CI. The minor issues can be addressed in follow-up PRs. 📝 Action ItemsMust fix before merge:
Nice to have: Great work on this comprehensive type safety implementation! 🎉 |
Code Review - PR #1950: Add RBS validation and runtime type checking to CIOverviewThis PR adds comprehensive RBS type checking infrastructure following Evil Martians best practices. The implementation is well-structured and thoughtful, with excellent documentation. Here's my detailed feedback: ✅ Strengths1. Excellent Documentation
2. Smart Incremental Approach
3. Comprehensive Type Safety
4. Pro Package Integration
🔧 Issues & Recommendations1. Critical: Inconsistent
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
Steepfile (1)
28-37: Consider the trade-offs of automating the file list.A past review suggested automating this list by iterating over
lib/files and checking for corresponding signatures insig/. While this would reduce maintenance burden, the explicit list approach has benefits for incremental adoption:Pros of automation:
- No need to manually update the list when adding new typed files
- Reduces chance of forgetting to add files to Steepfile
Pros of explicit list (current approach):
- Clear visibility of what's actually being checked
- Prevents accidentally type-checking files without proper signatures
- Aligns with the documented "positive list" strategy for gradual rollout
Given the PR's incremental adoption goals, the current approach is reasonable. However, consider automation once type coverage is more mature.
Example automation approach for future consideration:
# Automatically check all files with RBS signatures Dir.glob("lib/react_on_rails/*.rb").each do |lib_file| sig_file = lib_file.sub(%r{^lib/}, "sig/").sub(/\.rb$/, ".rbs") check lib_file if File.exist?(sig_file) end
🧹 Nitpick comments (2)
rakelib/run_rspec.rake (2)
37-47: Consider returning a Hash instead of a string for better composability.The method returns a space-separated string of environment variables, which requires careful handling downstream (e.g., line 64 uses
reject(&:empty?).join(" ")). A Hash would be more robust and composable.Apply this diff to improve type safety and composability:
- def rbs_runtime_env_vars - return "" unless ENV["ENABLE_RBS_RUNTIME_CHECKING"] + def rbs_runtime_env_hash + return {} unless ENV["ENABLE_RBS_RUNTIME_CHECKING"] begin require "rbs" - "RBS_TEST_TARGET='ReactOnRails::*' RUBYOPT='-rrbs/test/setup'" + { + "RBS_TEST_TARGET" => "ReactOnRails::*", + "RUBYOPT" => "-rrbs/test/setup" + } rescue LoadError warn "Warning: RBS gem not available, skipping runtime type checking" - "" + {} end endThen update the callers to use the Hash (example for line 53):
run_tests_in("", rspec_args: File.join("spec", "react_on_rails"), env_hash: rbs_runtime_env_hash)And update
run_tests_into accept and mergeenv_hashinto the environment variables construction at lines 139-144.
63-68: String concatenation is fragile; consider structured approach.The array-reject-join pattern works but mixes string manipulation with environment variable composition. This would be cleaner with a Hash-based approach (as suggested for
rbs_runtime_env_vars).With the Hash approach, this would become:
env_hash = rbs_runtime_env_hash.merge("DISABLE_TURBOLINKS" => "TRUE") run_tests_in(spec_dummy_dir, env_hash: env_hash, command_name: "dummy_no_turbolinks")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.rubocop.yml(1 hunks)Steepfile(1 hunks)rakelib/rbs.rake(2 hunks)rakelib/run_rspec.rake(1 hunks)react_on_rails_pro/sig/react_on_rails_pro/cache.rbs(1 hunks)react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- .rubocop.yml
🚧 Files skipped from review as they are similar to previous changes (1)
- react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1875
File: lib/react_on_rails/utils.rb:112-124
Timestamp: 2025-10-23T17:22:01.074Z
Learning: In React on Rails, when Pro is installed but not licensed, the intended behavior is to raise an error on boot. The `react_on_rails_pro?` method validates licenses and should raise errors early (including during path resolution in methods like `server_bundle?`) to enforce licensing requirements rather than failing later with obscure errors.
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1745
File: node_package/src/RSCRequestTracker.ts:8-14
Timestamp: 2025-07-08T05:57:29.630Z
Learning: The global `generateRSCPayload` function in React on Rails Pro (RORP) is provided by the framework during rendering requests, not implemented in application code. The `declare global` statements are used to document the expected interface that RORP will inject at runtime.
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation is handled in deeper level calls of the React on Rails Pro codebase, so it doesn't need to be validated again in the `rsc_payload_react_component` helper method.
Learnt from: alexeyr-ci
Repo: shakacode/react_on_rails PR: 1644
File: node_package/src/ReactOnRailsRSC.ts:87-87
Timestamp: 2024-12-12T13:07:09.929Z
Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging.
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1770
File: lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx:2-2
Timestamp: 2025-09-16T08:01:11.146Z
Learning: React on Rails uses webpack CSS Modules configuration with namedExports: true, which requires the import syntax `import * as style from './file.module.css'` rather than the default export pattern. This configuration enables better tree shaking and bundle size optimization for CSS modules.
📚 Learning: 2025-09-29T14:45:42.687Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1833
File: lib/react_on_rails/dev/process_manager.rb:72-83
Timestamp: 2025-09-29T14:45:42.687Z
Learning: In Ruby bundler contexts, when bundler intercepts system commands for executables not in the Gemfile, both version checks (like `system("foreman", "--version")`) and execution commands (like `system("foreman", "start", ...)`) fail equally, both returning false. This means availability checks using version flags accurately reflect whether execution commands will work in the current bundler context.
Applied to files:
rakelib/rbs.rake
📚 Learning: 2025-02-18T13:08:01.477Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.
Applied to files:
rakelib/rbs.rakereact_on_rails_pro/sig/react_on_rails_pro/cache.rbsrakelib/run_rspec.rake
📚 Learning: 2025-07-08T05:57:29.630Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1745
File: node_package/src/RSCRequestTracker.ts:8-14
Timestamp: 2025-07-08T05:57:29.630Z
Learning: The global `generateRSCPayload` function in React on Rails Pro (RORP) is provided by the framework during rendering requests, not implemented in application code. The `declare global` statements are used to document the expected interface that RORP will inject at runtime.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-09-16T08:01:11.146Z
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1770
File: lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx:2-2
Timestamp: 2025-09-16T08:01:11.146Z
Learning: React on Rails uses webpack CSS Modules configuration with namedExports: true, which requires the import syntax `import * as style from './file.module.css'` rather than the default export pattern. This configuration enables better tree shaking and bundle size optimization for CSS modules.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-09-15T21:24:48.207Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1781
File: node_package/src/ClientSideRenderer.ts:82-95
Timestamp: 2025-09-15T21:24:48.207Z
Learning: In React on Rails, the force_load feature includes both explicit `data-force-load="true"` usage and the ability to hydrate components during the page loading state (`document.readyState === 'loading'`). Both capabilities require a Pro license, so the condition `!railsContext.rorPro && (isComponentForceLoaded || document.readyState === 'loading')` correctly gates both scenarios.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-02-13T16:50:47.848Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: node_package/src/clientStartup.ts:18-21
Timestamp: 2025-02-13T16:50:47.848Z
Learning: In the react_on_rails module, the `reactOnRailsPageUnloaded` function in clientStartup.ts is intentionally kept private as it's only used internally as a callback for `onPageUnloaded`.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-02-12T16:38:06.537Z
Learnt from: Romex91
Repo: shakacode/react_on_rails PR: 1697
File: package-scripts.yml:28-28
Timestamp: 2025-02-12T16:38:06.537Z
Learning: The file `node_package/lib/ReactOnRails.full.js` is autogenerated during the build process and should not be present in the repository.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-02-18T13:08:01.477Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation is handled in deeper level calls of the React on Rails Pro codebase, so it doesn't need to be validated again in the `rsc_payload_react_component` helper method.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-10-23T17:22:01.074Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1875
File: lib/react_on_rails/utils.rb:112-124
Timestamp: 2025-10-23T17:22:01.074Z
Learning: In React on Rails, when Pro is installed but not licensed, the intended behavior is to raise an error on boot. The `react_on_rails_pro?` method validates licenses and should raise errors early (including during path resolution in methods like `server_bundle?`) to enforce licensing requirements rather than failing later with obscure errors.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-04-26T21:55:55.874Z
Learnt from: alexeyr-ci2
Repo: shakacode/react_on_rails PR: 1732
File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44
Timestamp: 2025-04-26T21:55:55.874Z
Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-06-09T08:01:35.973Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1696
File: node_package/src/RSCProvider.tsx:40-41
Timestamp: 2025-06-09T08:01:35.973Z
Learning: In React components, cache objects (like Map, Record, etc.) that are created within the component's scope or factory function closure are automatically garbage collected when the component unmounts. This pattern is acceptable and doesn't cause memory leaks because the cache is tied to the component lifecycle, unlike global or module-level caches that persist indefinitely.
Applied to files:
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs
📚 Learning: 2025-02-13T14:29:49.267Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: spec/react_on_rails/utils_spec.rb:218-218
Timestamp: 2025-02-13T14:29:49.267Z
Learning: In RSpec tests, prefer using local variables over constants within test blocks to avoid constant redefinition warnings and maintain better test isolation.
Applied to files:
rakelib/run_rspec.rake
📚 Learning: 2024-06-27T05:22:46.156Z
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1622
File: spec/dummy/spec/rake/assets_precompile_rake_spec.rb:12-12
Timestamp: 2024-06-27T05:22:46.156Z
Learning: When stubbing environment variables in RSpec tests, use `before` and `after` hooks to ensure that the original values are restored after the tests, preventing any side effects on other tests. Example provided by justin808:
```ruby
describe "My test" do
before do
original_value = ENV["VARIABLE_NAME"]
allow(ENV).to receive(:[]).with("VARIABLE_NAME").and_return("stubbed_value")
end
after do
allow(ENV).to receive(:[]).with("VARIABLE_NAME").and_call_original
ENV["VARIABLE_NAME"] = original_value
end
it "tests something" do
# Your test code here
end
end
```
This practice ensures test isolation and reliability.
Applied to files:
rakelib/run_rspec.rake
🔇 Additional comments (7)
Steepfile (2)
1-23: Excellent documentation of the incremental adoption strategy.The comments clearly explain the rationale for using a positive list approach and provide clear instructions for adding new files to type checking. This will help maintainers understand the strategy.
39-51: LGTM! Configuration is appropriate.The signature directory, diagnostics, and library declarations are properly configured for the files being checked.
rakelib/rbs.rake (2)
43-65: LGTM! Consistent implementation with the validate task.The steep task follows the same pattern as the validate task, which provides consistency. The error handling appropriately distinguishes between validation failures and command-not-found scenarios.
67-68: LGTM! Useful composite task.The
:alltask provides a convenient way to run both RBS validation and Steep type checking in sequence.rakelib/run_rspec.rake (2)
50-54: LGTM! Gem task properly configured for RBS runtime checking.The task correctly passes RBS environment variables for unit tests as documented in the coverage strategy.
57-60: LGTM! Integration tests correctly configured with RBS runtime checking.This addresses the past review comment about whether integration tests should have these options - they do, which aligns with the documented coverage strategy.
react_on_rails_pro/sig/react_on_rails_pro/cache.rbs (1)
1-13: ****The RBS signatures are correct as written. The return type difference between
base_cache_keyandreact_component_cache_keyis intentional and accurate:
base_cache_keyreturnsArray[String]because it builds a fixed array of strings:[type, ReactOnRails::VERSION, ReactOnRailsPro::VERSION](plus optional bundle_hash).react_component_cache_keyreturnsArray[untyped]because it spreads the base key array and appendscache_key_value—an arbitrary value extracted fromoptions[:cache_key]that can be any type (as confirmed by test fixtures showing object instances in the returned array).The original concern about consistency is unfounded; the signatures correctly reflect the implementation's runtime behavior.
Likely an incorrect or invalid review comment.
Code Review: RBS Validation and Runtime Type CheckingI've reviewed PR #1950 and overall this is a well-structured implementation that follows industry best practices. Here's my detailed feedback: ✅ Strengths
🔍 Issues & RecommendationsCritical Issues1. RBS Runtime Checking Not Actually Enabled (rakelib/run_rspec.rake:23-67) The runtime checking implementation has a logical flaw - Recommendations:
2. Silent stderr Suppression May Hide Real Issues (rakelib/rbs.rake:13-16) The Performance & Best Practices3. Redundant bundle exec in Rake Tasks (rakelib/rbs.rake:13, 42) The comments claim 4. Missing Test Coverage No tests verify that:
Consider adding at least one test that intentionally violates a type signature to verify runtime checking works. Documentation5. Missing CLAUDE.md Updates CLAUDE.md doesn't mention how to enable RBS runtime checking, when to update RBS signatures, or how to run RBS validation locally. Consider adding an "RBS Type Checking" section. 📊 Test Plan AssessmentBefore merging, verify:
🎯 SummaryOverall Assessment: Solid foundation for type safety, but the runtime checking component needs attention before merge. Priority Actions:
Verdict: Request changes for item #1 (runtime checking), others can be follow-up PRs. Great work on the comprehensive approach to type safety! The Steepfile documentation and CI integration are particularly well done. |
PR Review: Add RBS validation and runtime type checking to CIThank you for this comprehensive PR implementing RBS type checking! This is a well-structured enhancement that follows Ruby typing best practices. Here's my detailed review: ✅ Strengths
🔍 Code Quality Observationsrakelib/rbs.rake (lines 39-54)The desc "Run Steep type checker"
task :steep do
require "steep" # Add explicit require for consistency
puts "Running Steep type checker..."
# ... rest of implementation
endrakelib/run_rspec.rake (lines 37-48)The
However, there's a minor issue: the method is defined at module level but used within tasks. Consider moving it to the # In task_helpers.rb or at the top of the namespace
module ReactOnRails
module TaskHelpers
def rbs_runtime_env_vars
# ... implementation
end
end
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
CLAUDE.md(1 hunks)rakelib/rbs.rake(3 hunks)rakelib/run_rspec.rake(1 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1875
File: lib/react_on_rails/utils.rb:112-124
Timestamp: 2025-10-23T17:22:01.074Z
Learning: In React on Rails, when Pro is installed but not licensed, the intended behavior is to raise an error on boot. The `react_on_rails_pro?` method validates licenses and should raise errors early (including during path resolution in methods like `server_bundle?`) to enforce licensing requirements rather than failing later with obscure errors.
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1745
File: node_package/src/RSCRequestTracker.ts:8-14
Timestamp: 2025-07-08T05:57:29.630Z
Learning: The global `generateRSCPayload` function in React on Rails Pro (RORP) is provided by the framework during rendering requests, not implemented in application code. The `declare global` statements are used to document the expected interface that RORP will inject at runtime.
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation is handled in deeper level calls of the React on Rails Pro codebase, so it doesn't need to be validated again in the `rsc_payload_react_component` helper method.
Learnt from: alexeyr-ci
Repo: shakacode/react_on_rails PR: 1644
File: node_package/src/ReactOnRailsRSC.ts:87-87
Timestamp: 2024-12-12T13:07:09.929Z
Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging.
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1770
File: lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx:2-2
Timestamp: 2025-09-16T08:01:11.146Z
Learning: React on Rails uses webpack CSS Modules configuration with namedExports: true, which requires the import syntax `import * as style from './file.module.css'` rather than the default export pattern. This configuration enables better tree shaking and bundle size optimization for CSS modules.
📚 Learning: 2025-02-13T14:29:49.267Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: spec/react_on_rails/utils_spec.rb:218-218
Timestamp: 2025-02-13T14:29:49.267Z
Learning: In RSpec tests, prefer using local variables over constants within test blocks to avoid constant redefinition warnings and maintain better test isolation.
Applied to files:
rakelib/run_rspec.rake
📚 Learning: 2024-06-27T05:22:46.156Z
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1622
File: spec/dummy/spec/rake/assets_precompile_rake_spec.rb:12-12
Timestamp: 2024-06-27T05:22:46.156Z
Learning: When stubbing environment variables in RSpec tests, use `before` and `after` hooks to ensure that the original values are restored after the tests, preventing any side effects on other tests. Example provided by justin808:
```ruby
describe "My test" do
before do
original_value = ENV["VARIABLE_NAME"]
allow(ENV).to receive(:[]).with("VARIABLE_NAME").and_return("stubbed_value")
end
after do
allow(ENV).to receive(:[]).with("VARIABLE_NAME").and_call_original
ENV["VARIABLE_NAME"] = original_value
end
it "tests something" do
# Your test code here
end
end
```
This practice ensures test isolation and reliability.
Applied to files:
rakelib/run_rspec.rake
📚 Learning: 2025-09-29T14:45:42.687Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1833
File: lib/react_on_rails/dev/process_manager.rb:72-83
Timestamp: 2025-09-29T14:45:42.687Z
Learning: In Ruby bundler contexts, when bundler intercepts system commands for executables not in the Gemfile, both version checks (like `system("foreman", "--version")`) and execution commands (like `system("foreman", "start", ...)`) fail equally, both returning false. This means availability checks using version flags accurately reflect whether execution commands will work in the current bundler context.
Applied to files:
rakelib/rbs.rake
📚 Learning: 2025-02-18T13:08:01.477Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1644
File: lib/react_on_rails/helper.rb:190-197
Timestamp: 2025-02-18T13:08:01.477Z
Learning: RSC support validation in React on Rails Pro is handled through a chain of validations:
1. Pro version check in `run_stream_inside_fiber`
2. RSC support check during pack generation via `ReactOnRailsPro.configuration.enable_rsc_support`
3. RSC support validation during component registration
This makes additional validation in the helper methods unnecessary.
Applied to files:
rakelib/rbs.rakeCLAUDE.md
📚 Learning: 2025-02-12T16:38:06.537Z
Learnt from: Romex91
Repo: shakacode/react_on_rails PR: 1697
File: package-scripts.yml:28-28
Timestamp: 2025-02-12T16:38:06.537Z
Learning: The file `node_package/lib/ReactOnRails.full.js` is autogenerated during the build process and should not be present in the repository.
Applied to files:
CLAUDE.md
📚 Learning: 2025-10-23T17:22:01.074Z
Learnt from: AbanoubGhadban
Repo: shakacode/react_on_rails PR: 1875
File: lib/react_on_rails/utils.rb:112-124
Timestamp: 2025-10-23T17:22:01.074Z
Learning: In React on Rails, when Pro is installed but not licensed, the intended behavior is to raise an error on boot. The `react_on_rails_pro?` method validates licenses and should raise errors early (including during path resolution in methods like `server_bundle?`) to enforce licensing requirements rather than failing later with obscure errors.
Applied to files:
CLAUDE.md
📚 Learning: 2025-09-16T08:01:11.146Z
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1770
File: lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx:2-2
Timestamp: 2025-09-16T08:01:11.146Z
Learning: React on Rails uses webpack CSS Modules configuration with namedExports: true, which requires the import syntax `import * as style from './file.module.css'` rather than the default export pattern. This configuration enables better tree shaking and bundle size optimization for CSS modules.
Applied to files:
CLAUDE.md
📚 Learning: 2025-04-26T21:55:55.874Z
Learnt from: alexeyr-ci2
Repo: shakacode/react_on_rails PR: 1732
File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44
Timestamp: 2025-04-26T21:55:55.874Z
Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime.
Applied to files:
CLAUDE.md
dba6179 to
efca28f
Compare
|
@claude review this PR |
|
Claude finished @justin808's task —— View job PR Review: Add RBS validation and runtime type checking to CII've completed a thorough review of this PR. Overall, this is an excellent implementation of comprehensive RBS type checking that follows industry best practices. The three-layer approach (validation, runtime checking, and static analysis) is exactly right. ✅ Strengths1. Well-Architected Type Checking Strategy
2. Excellent Documentation
3. Thoughtful Runtime Checking Implementation
4. Clean CI Integration
5. Comprehensive Pro Package Signatures
6. Code Quality
🔍 Issues FoundCritical Issues1. Runtime Checking RUBYOPT Clobbers Existing Flags (run_rspec.rake:42) Issue: The code sets Impact: Developers who have custom RUBYOPT settings will lose them during test runs with RBS enabled. Current code: "RBS_TEST_TARGET='ReactOnRails::*' RUBYOPT='-rrbs/test/setup'"Recommended fix: existing_rubyopt = ENV["RUBYOPT"]
rubyopt_parts = ["-rrbs/test/setup", existing_rubyopt].compact.reject(&:empty?)
"RBS_TEST_TARGET='ReactOnRails::*' RUBYOPT='#{rubyopt_parts.join(" ")}'"This preserves any existing RUBYOPT flags while adding the RBS runtime hook. High Priority Issues2. Missing Issue: The rake tasks use bare stdout, stderr, status = Open3.capture3("rbs -I sig validate")
stdout, stderr, status = Open3.capture3("steep check")Impact: This will fail if the gems aren't in the system PATH, which is common in CI environments or when using Recommended fix: stdout, stderr, status = Open3.capture3("bundle exec rbs -I sig validate")
stdout, stderr, status = Open3.capture3("bundle exec steep check")The comment "use rbs directly, not bundle exec since we're already in bundle context" is misleading. While the rake process runs in bundle context, spawned shell commands via Medium Priority Issues3. Pro Configuration Type Signature May Be Too Restrictive (react_on_rails_pro/sig/react_on_rails_pro/configuration.rbs:34, 40) Potential Issues:
Impact: Runtime type checking will raise TypeError for common usage patterns. Recommendation: Review actual usage in Pro package and widen types if needed. 4. No Test Coverage for Type Checking Infrastructure Missing tests:
Recommendation: Add at least one integration test that:
This would validate the entire system works as expected. 5. Performance Impact Not Documented Issue: Runtime type checking adds overhead to test execution (typically 5-15%). Recommendation:
Minor Issues6. Duplicate Lines 87 and 98 both run Recommendation: Remove the duplicate at line 98. 7. Inconsistent RBS Command Between Main and Pro
Recommendation: Use rake tasks consistently for better error messages and standardization. 🎯 RecommendationsBefore Merge (High Priority)
After Merge (Medium Priority)
Future Enhancements
🔒 Security & PerformanceSecurity: ✅ No security concerns identified. Type checking is development/test-only. Performance:
📊 Code Review Summary
Overall Score: 4.5/5 - Excellent work with a few fixable issues. 🎉 ConclusionThis is a high-quality PR that establishes solid type checking infrastructure for React on Rails. The incremental adoption strategy is pragmatic and the implementation follows Ruby type checking best practices. Main concerns:
Once these issues are addressed, this will provide excellent type safety guarantees and catch bugs early in development. Recommendation: Request changes for issues #1 and #2, which are straightforward fixes. Issue #3 should be verified against actual Pro package usage. Great work on adopting modern Ruby type checking practices! 🎉 CI Status: 2 failures in "Main test" and "Pro Integration Tests" - these appear unrelated to the RBS changes based on the test names. |
PR Review: Add RBS validation and runtime type checking to CIOverall AssessmentThis is an excellent PR that implements comprehensive RBS type checking with a well-thought-out incremental approach. The implementation follows best practices from the Evil Martians article and provides solid foundations for type safety. The code quality is high, documentation is thorough, and the testing approach is sound. ✅ Strengths1. Excellent Incremental Approach
2. Comprehensive Three-Pronged Strategy
3. Well-Designed Runtime Type Checking
4. Excellent Testing
5. Thorough Documentation
6. Pro Package Integration
🔍 Code Quality ObservationsMinor Issues & Suggestions1. Potential Issue: Runtime Checking in Integration TestsIn env_vars = [rbs_runtime_env_vars, "DISABLE_TURBOLINKS=TRUE"].reject(&:empty?).join(" ")Concern: If Suggestion: Consider a more robust approach: env_vars_array = []
env_vars_array << rbs_runtime_env_vars unless rbs_runtime_env_vars.empty?
env_vars_array << "DISABLE_TURBOLINKS=TRUE"
env_vars = env_vars_array.join(" ")Or ensure the 2. Test Coverage GapThe runtime checking test ( Verify: Does the Suggestion: Add a comment indicating which RBS signature file defines this type, or add an assertion that the signature exists before testing violations. 3. Rake Task Error HandlingIn stdout, stderr, status = Open3.capture3("bundle exec rbs -I sig validate")Minor improvement: Consider adding a timeout to prevent hung processes: stdout, stderr, status = Open3.capture3("bundle exec rbs -I sig validate", timeout: 60)This is especially important for CI environments. 4. Pro Package Rake Tasks Missing SteepThe Pro package has Question: Is this intentional? Should the Pro package also support Steep type checking? If not, a comment explaining why would be helpful. 5. RuboCop ExclusionIn - '**/Steepfile'Good catch - this is correct since Steepfile doesn't follow snake_case convention. Consider if any other RBS-related files need exclusions. 🔒 Security ConsiderationsNo security concerns identified. The changes are limited to type checking infrastructure with no user-facing changes or data handling modifications. ⚡ Performance ConsiderationsWell documented: The 5-15% overhead for runtime type checking during tests is acceptable and properly documented in CLAUDE.md. The opt-out mechanism allows developers to disable it during rapid iteration. Suggestion: Consider collecting actual metrics from CI runs before/after to validate the estimated overhead and update documentation accordingly. 📊 Test CoverageExcellent coverage for the new functionality:
Potential gap: No integration test that runs actual RSpec with RBS enabled end-to-end. Consider adding a simple test that:
🎯 Best PracticesThe PR follows all the repository conventions from CLAUDE.md:
📋 Checklist ReviewFrom the PR description:
🚀 Recommendations Before MergeMust FixNone - the PR is solid as-is. Should Consider
Nice to Have
🎓 Learning from This PRThis PR is an excellent example of:
The approach here can serve as a model for other gradual type adoption efforts. Final VerdictLGTM with minor suggestions 🎉 This PR is ready to merge. The suggestions above are minor improvements that could be addressed in follow-up PRs. The core implementation is solid, well-tested, and properly documented. The intentional decision to disable Steep in CI until errors are fixed (comment in Great work on this comprehensive type checking implementation! |
This commit implements comprehensive RBS type checking for both the main gem and Pro package:
1. CI Integration:
- Added `rake rbs:validate` to main lint workflow
- Added RBS validation to Pro gem lint workflow
- Added Steep static type checker to CI pipeline
2. Runtime Type Checking:
- Configured RSpec to run with RBS runtime checking for gem tests
- Tests now run with RBS_TEST_TARGET='ReactOnRails::*' RUBYOPT='-rrbs/test/setup'
- This provides runtime validation of type signatures during test execution
3. Steep Static Type Checker:
- Added steep gem to development dependencies
- Created Steepfile configuration for static type analysis
- Added `rake rbs:steep` task for running static type checks
- Added `rake rbs:all` task to run both validation and steep checks
4. Pro Gem RBS Types:
- Created sig/ directory structure for Pro gem
- Added type signatures for:
- ReactOnRailsPro module
- Configuration class with all attributes
- Error, Cache, and Utils modules
- Foundation for expanding type coverage in Pro package
5. Documentation:
- Configured Steepfile to check lib/ directory
- Set up library dependencies for proper type resolution
Follows best practices from Evil Martians' "Climbing Steep Hills" article:
- Static validation with rbs validate
- Runtime checking with rbs/test/setup
- Static analysis with Steep
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
The Pro gem has its own Gemfile.development_dependencies and needs rbs added to run RBS validation in CI.
This commit addresses the 1527 Steep type errors that were causing CI to fail. Changes: - Updated Steepfile to only check files with complete RBS signatures (10 files) instead of the entire lib/ directory (which has 140+ files) - Temporarily disabled Steep CI check until RBS signatures are complete (374 remaining errors in files with partial signatures) - Fixed rake tasks to avoid nested bundle exec calls that were causing bundler errors in local development The RBS validation step continues to work correctly and validates that all type signatures are syntactically correct and internally consistent. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Critical Fixes: - Fix bundle exec consistency in rbs.rake for both rbs and steep tasks - Add comprehensive error handling for runtime type checking in run_rspec.rake - Fix type signature accuracy: Array[untyped] -> Array[String] in Pro configuration - Rewrite cache.rbs to match actual implementation (was describing non-existent method) Enhanced Runtime Type Checking: - Extract runtime checking into reusable rbs_runtime_env_vars helper - Extend coverage to :dummy and :dummy_no_turbolinks tasks - Add opt-in mechanism via ENV["ENABLE_RBS_RUNTIME_CHECKING"] - Add comprehensive documentation explaining coverage strategy per Evil Martians best practices Documentation Improvements: - Add extensive Steepfile documentation explaining positive-list approach - Document all intentionally excluded files/directories with reasons - Add step-by-step guide for adding new files to type checking - Explain why bundle exec is necessary even in rake context Configuration: - Add Steepfile to RuboCop Naming/FileName exclusions - Alphabetically order checked files for easy maintenance All changes improve type safety, prevent silent failures, and make the system more maintainable for future developers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
CRITICAL FIXES: 1. Runtime Type Checking Now Actually Works - Changed from opt-in (never enabled) to enabled-by-default with opt-out - Was: ENV["ENABLE_RBS_RUNTIME_CHECKING"] (never set anywhere) - Now: Enabled by default, disable with DISABLE_RBS_RUNTIME_CHECKING=true - This activates the third pillar of type safety (static, steep, runtime) 2. Improved Error Handling in RBS Validation - Replace fragile stderr redirection with Open3.capture3 - Properly separates validation errors from warnings - No longer hides real issues with 2>/dev/null - Shows both stdout and stderr when validation fails 3. Remove Redundant bundle exec - Removed unnecessary 'bundle exec' from rake tasks - When running 'bundle exec rake', already in bundle context - Reduces overhead and simplifies implementation - Uses direct 'rbs' and 'steep' commands DOCUMENTATION: 4. Comprehensive RBS Documentation in CLAUDE.md - Added "RBS Type Checking" section with quick start - Documents runtime checking behavior (enabled by default) - Explains how to disable for faster test runs - Step-by-step guide for adding new type signatures - Lists files currently type-checked - Pro package validation instructions These fixes ensure runtime type checking actually runs in tests, providing comprehensive type safety validation that catches errors static analysis misses. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Critical fixes: - Preserve existing RUBYOPT flags instead of clobbering them - Add bundle exec to rbs and steep commands in rake tasks - Remove duplicate yarn install in CI workflow - Standardize RBS commands between main and Pro workflows Improvements: - Add test coverage for RBS type checking infrastructure - Document performance impact (5-15% overhead) in CLAUDE.md - Create rbs.rake for Pro package for consistency - Add guidance on when to disable runtime checking Files modified: - rakelib/run_rspec.rake: Fix RUBYOPT handling to append vs replace - rakelib/rbs.rake: Add bundle exec with explanatory comments - .github/workflows/lint-js-and-ruby.yml: Remove duplicate yarn install - .github/workflows/pro-lint.yml: Use rake rbs:validate consistently - react_on_rails_pro/rakelib/rbs.rake: New file for Pro consistency - spec/react_on_rails/rake_tasks_spec.rb: Test RBS rake tasks - spec/react_on_rails/rbs_runtime_checking_spec.rb: Test runtime checking - CLAUDE.md: Add performance impact documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Minor improvements: - Fix env vars concatenation for robustness with complex variables - Document Configuration RBS signature in test (sig/react_on_rails/configuration.rbs:4) - Add timeout (60s) to Open3.capture3 commands to prevent hung processes in CI - Document why Pro package omits Steep tasks (doesn't use Steep type checker) Files modified: - rakelib/run_rspec.rake: Improve env vars handling for DISABLE_TURBOLINKS - rakelib/rbs.rake: Add timeout parameter to Open3.capture3 calls - react_on_rails_pro/rakelib/rbs.rake: Add comment explaining Steep omission + timeout - spec/react_on_rails/rbs_runtime_checking_spec.rb: Document RBS signature location 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Replace Open3.capture3 timeout option with Timeout.timeout wrapper for Ruby 3.0+ compatibility - Remove duplicate RBS definitions for PrerenderError and JsonParseError from sig/react_on_rails.rbs - Add comment explaining error class definitions are in separate files - Improve test documentation with clearer explanation of RBS runtime checking - Add timeout handling to Pro package RBS rake tasks - Add RuboCop disable for BlockLength in Pro package RBS rake file The timeout option for Open3.capture3 was added in Ruby 3.3, but we support Ruby >= 3.0.0. Using Timeout.timeout provides compatibility across all supported Ruby versions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
544da89 to
bd1265e
Compare
Change require_relative from "../spec_helper" to "spec_helper" to match the correct path structure. The spec_helper is located at spec/react_on_rails/spec_helper.rb, not spec/spec_helper.rb. This fixes the LoadError in CI minimum dependency tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Summary
This PR implements comprehensive RBS type checking for both the main gem and Pro package as a follow-up to #1945.
Changes
CI Integration
rake rbs:validateto main lint workflowRuntime Type Checking
RBS_TEST_TARGET='ReactOnRails::*' RUBYOPT='-rrbs/test/setup'Steep Static Type Checker
rake rbs:steeptask for running static type checksrake rbs:alltask to run both validation and steep checksPro Gem RBS Types
Implementation Details
This PR follows best practices from Evil Martians' "Climbing Steep Hills" article:
rbs validaterbs/test/setupThe combination of these three approaches provides comprehensive type safety:
Test Plan
🤖 Generated with Claude Code
This change is
Summary by CodeRabbit
Chores
Documentation