Option to omit private methods from gem RBIs, with a per-gem opt-in
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Start with the Methods listener that skips private methods during tapioca gem and with merge_with_exported_rbi, which the issue says must run after filtering. Read how typed_overrides is parsed from the config to model the new gem options. Done means private_methods: false omits private methods except for gems in private_methods_for, and gems that export their own RBIs keep their private markers after the merge.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
tapioca gem emits every private method it finds. Application code only reaches a gem's private methods through implicit-receiver calls from subclasses, including modules, or DSLs like Rake::DSL, so for most gems these definitions add size and diff churn without affecting type checking.
In a large Rails app (501 gems in the bundle, RBIs generated for 395), 332 of the generated RBIs contain private methods. After stripping private methods from all of them, srb tc passes once private methods are restored for just 9 gems:
rake:Rake::DSL#task,#namespace,#desc, called at the top level of every.rakefileactiverecord:default_scope,transaction_include_any_action?tapioca:Tapioca::Dsl::Compiler#compile_method_parameters_to_rbi,#compile_method_return_type_to_rbi,.all_classes, used by custom DSL compilersrbi:RBI::Visitor#visit_*, whichRBI::RBSPrinteroverrides withoverridesigs in the gem's own RBIkarafka:Karafka::Instrumentation::Vendors::Datadog::MetricsListener#consumer_tagsand#namespaced_metric, overridden by a subclass in another gemsuper_diff,shoulda-matchers,rubocop, and one internal gem: helpers called from subclasses
Potential reduction
Keeping private methods for those 9 gems and omitting them for the other 386:
| Before | After | Change | |
|---|---|---|---|
| Method definitions | 198,737 | 177,402 | -10.7% |
| RBI size, excluding comments | 14.3 MB | 13.3 MB | -7.2% |
| RBI size, total | 38.8 MB | 37.0 MB | -4.8% |
| RBI lines, total | 1,082,949 | 1,020,568 | -5.8% |
Gem upgrades that only touch private methods would also stop producing RBI diffs.
Proposal
A gem option that turns private methods off, plus a list of gems that keep them, similar in shape to typed_overrides:
gem:
private_methods: false
private_methods_for:
- rake
- activerecord
Defaulting private_methods to true keeps today's output.
Implementation note
We prototyped this with a patch loaded from sorbet/tapioca/require.rb. The filtering has to run after merge_with_exported_rbi. When the Methods listener skips private methods instead, gems that export their own RBIs (pdf-reader, rbi, spoom, prism) declare many of those methods without a private marker, and the merge brings them back as public methods.
Happy to open a PR if this sounds reasonable.
- Ngôn ngữ chính
- Ruby
- Star
- 874
- Fork
- 169
- Merge trung bình
- 3 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 10
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Shopify/tapioca
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Shopify/tapioca#2662 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`has_secure_password` reset token finders are missing from DSL RBIsCó thể đã có người làm @RaphaelFakhri đã nhận 5 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Improve `check-shims` performanceCó thể đã có người làm @KaanOzkan đã nhận 28 ngày trước. Đang mở
Shopify/tapioca#2728 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của Shopify/tapioca
Issue tương tự
-
verified
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
akitaonrails/ai-book-2026#10 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
TheOdinProject/curriculum#31495 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
zerocracy/judges-action#2984 ·
Maintainer thường phản hồi trong vòng 1 ngày