Option to omit private methods from gem RBIs, with a per-gem opt-in
メンテナーはふだん 4 日以内に返信
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Ruby
- スター
- 874
- フォーク
- 167
- 平均マージ
- 5日 12時間
- マージ済み PR(30日)
- 11
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Shopify/tapioca のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Shopify/tapioca#2662 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 57/100
メンテナーはふだん 4 日以内に返信
-
Improve `check-shims` performance対応中かも @KaanOzkan が 19 日前に担当しました。 オープン
Shopify/tapioca#2728 · 担当者 1 名 ·
メンテナーはふだん 4 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
メンテナーはふだん 4 日以内に返信
-
Prepending a module can cause `tapioca dsl` to produce an untyped signature対応中かも @KaanOzkan が 55 日前に担当しました。 オープンbug
Shopify/tapioca#2705 · 担当者 1 名 ·
メンテナーはふだん 4 日以内に返信
Shopify/tapioca の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
taskcluster/taskcluster#9284 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
Unconfirmed users who reset their password are stuck on sign in with no way to send confirmationオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信