Option to omit private methods from gem RBIs, with a per-gem opt-in
Maintainer antworten meist innerhalb von 4 Tagen
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 30/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Ruby
- Sterne
- 874
- Forks
- 167
- Ø Merge
- 5 T. 12 Std.
- Gemergte PRs (30 T.)
- 11
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Shopify/tapioca
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Shopify/tapioca#2662 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 57/100
Maintainer antworten meist innerhalb von 4 Tagen
-
Improve `check-shims` performanceEvtl. vergeben @KaanOzkan hat das vor 17 Tagen übernommen. Offen
Shopify/tapioca#2728 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
Maintainer antworten meist innerhalb von 4 Tagen
-
Prepending a module can cause `tapioca dsl` to produce an untyped signatureEvtl. vergeben @KaanOzkan hat das vor 53 Tagen übernommen. Offenbug
Shopify/tapioca#2705 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 4 Tagen
Alle Issues in Shopify/tapioca
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
ecosyste-ms/repos#1215 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
WikiEducationFoundation/WikiEduDashboard#7157 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
r-uby-dev/llm#292 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 4 Tagen