Skip to content

Prune unused requires in lib/grape.rb#2742

Open
ericproulx wants to merge 1 commit into
masterfrom
chore/prune-requires
Open

Prune unused requires in lib/grape.rb#2742
ericproulx wants to merge 1 commit into
masterfrom
chore/prune-requires

Conversation

@ericproulx
Copy link
Copy Markdown
Contributor

Summary

Audit of lib/grape.rb requires against actual lib/ usage:

Dropped (no callers anywhere in lib/):

  • active_support/version — redundant; require 'active_support' itself loads the version file first.
  • pathname — no Pathname reference.

Narrowed:

  • active_support/inflectoractive_support/core_ext/string/inflections. Only String#demodulize and String#underscore are used (validations.rb, util/registry.rb); the full Inflector class/rule machinery isn't reached.

Kept after false start (worth flagging):

  • active_support/core_ext/hash/indifferent_access looked unused on first pass (we only construct ActiveSupport::HashWithIndifferentAccess.new(...) directly, never call Hash#with_indifferent_access). But HashWithIndifferentAccess.new(hash) internally calls nested_under_indifferent_access on its input, which is added by this core_ext. Dropping it broke ~200 specs. Restored with an inline comment.

Test plan

  • bundle exec rspec — 2313 examples, 0 failures
  • bundle exec rubocop lib/grape.rb — clean
  • CI green

🤖 Generated with Claude Code

Three removals (verified via grep across `lib/` + full RSpec run):

- `active_support/version` — redundant; `require 'active_support'`
  itself loads the version file first.
- `pathname` — no `Pathname` reference anywhere in the gem.

One narrow:

- `active_support/inflector` → `active_support/core_ext/string/inflections`
  — only the String inflector extensions (`demodulize`, `underscore`) are
  used (in `validations.rb` and `util/registry.rb`); the rest of the
  Inflector class/rule machinery isn't reached.

Kept with a comment after a false start during the audit:

- `active_support/core_ext/hash/indifferent_access` — looked unused
  (we only construct `ActiveSupport::HashWithIndifferentAccess.new(...)`
  directly, never call `Hash#with_indifferent_access`), but
  `HashWithIndifferentAccess.new(hash)` internally calls
  `nested_under_indifferent_access` on its input, which is added by
  this core_ext. Dropping it broke ~200 specs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ericproulx ericproulx force-pushed the chore/prune-requires branch from 3eb1aab to 935b343 Compare May 23, 2026 18:46
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

Danger Report

Errors

  • One of the lines below found in CHANGELOG.md doesn't match the expected format. Please make it look like the other lines, pay attention to version numbers, periods, spaces and date formats.

Markdowns

* [#PRNUMBER](https://github.com/ruby-grape/grape/pull/PRNUMBER): Prune unused requires in `lib/grape.rb`; narrow `active_support/inflector` to `core_ext/string/inflections` - [@ericproulx](https://github.com/ericproulx).
does not include a pull request link

View run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant