perf: drop unused dotenv and lazy-load scaffold templates (remove ActiveSupport from boot) (#30)#80
Conversation
…iveSupport from boot) (#30)
|
Warning Review limit reached
Next review available in: 15 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
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 |
Summary
Removes two heavy/dead runtime dependencies from the gem's boot path (perf, P2).
dotenvwas a dead runtime dependency — declared in the gemspec but neverrequired or referenced anywhere inlib/,bin/, ortest/. Dropped.camelizecall.lib/skill_bench/rails/skill_templates.rbdidrequire 'active_support/inflector'solely to callString#camelizein a scaffold generator, and that file wasrequire_relative'd at top-level boot. So everyskill-bench runpaid the cost of loading all of ActiveSupport. Replacedcamelizewith a tiny local helper and made the scaffold file lazy-loaded, so a normal run no longer touches ActiveSupport at all — and ActiveSupport is removed from the runtime deps.What I verified (grep)
grep -rniE "activesupport|active_support|\.camelize|\.underscore|\.classify|deep_symbolize|deep_merge|\.blank\?|\.present\?|with_indifferent" lib bin:skill_templates.rb:46,70—name.camelize→ the only actual ActiveSupport runtime calls.skill_templates.rb:51(extend ActiveSupport::Concern) andcategory_data.rb:47,49,50(ActiveSupport::Concern) — these are string content inside generated templates / template data, not real calls. They stay (the generated Rails code is supposed to contain them).commands/skill_new.rb:69— a pre-existing localcamelizedefinition, not an ActiveSupport usage.README.mddocs.Conclusion:
camelizewas the sole real ActiveSupport usage → ActiveSupport can be dropped.grep -rniE "dotenv|Dotenv" lib bin test→ no matches.dotenvis genuinely unreferenced → dropped.Deps removed vs kept
activesupport (>= 6.0)(only used for onecamelize, now localized) anddotenv (~> 3.2.0)(entirely unused). Both were leaf deps — neither survives inGemfile.lockas a transitive dependency of anything else, so a chain of sub-gems (i18n,tzinfo,connection_pool,drb,base64,securerandom, …) drops out too.cgi,faraday,json,parallel— all genuinely used at runtime.The local camelize helper
Added to
SkillBench::Rails::SkillTemplates, replacingString#camelize:It splits on
_and-, upcases the first letter of each segment, and preserves already-CamelCase input (it does not lowercase the remainder). For the snake_case inputs the scaffold actually uses, this is identical to ActiveSupport'scamelize; it additionally handles-(which ActiveSupport'scamelizedoes not), matching the behavior theservice_objectgenerator already relied on. All three generators (service_object,concern,active_record_model) now route through this one helper (DRY) — the old inlinesplit(/[-_]/).map(&:capitalize).joininservice_objectis gone.The lazy require
skill_templates.rbwas loaded at boot via two paths: the top-levelrequire_relativeinlib/skill_bench.rb, andrequire_relative '../rails/skill_templates'at the top ofcommands/skill_new.rb(which is itself required at boot). Both are removed; therequire_relativenow happens insideSkillNew.create_rails_skill, the single point whereRails::SkillTemplatesis referenced. Verified via grep that nothing else referencesRails::SkillTemplatesat boot.Sanity check
Tests
user_creator→UserCreator,order-service→OrderService, already-camelUserCreator→UserCreator, mixedmy-cool_skill→MyCoolSkill.skill_templates_test.rbnow requires the (now lazy-loaded) file explicitly.skill_new/ template tests still pass with the lazy require, and the suite coversrequire 'skill_bench'+skill newoutput generation.Gates (all green from repo root)
bundle exec rubocop— no offensesbundle exec reek— cleanbundle exec rake test— 764 runs, 0 failures, 0 errors (4 pre-existing skips)bundle exec rake yard:coverage— 0 undocumented public objectsCloses #30