Prune unused requires in lib/grape.rb#2742
Open
ericproulx wants to merge 1 commit into
Open
Conversation
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>
3eb1aab to
935b343
Compare
Danger ReportErrors
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit of
lib/grape.rbrequires against actuallib/usage:Dropped (no callers anywhere in
lib/):active_support/version— redundant;require 'active_support'itself loads the version file first.pathname— noPathnamereference.Narrowed:
active_support/inflector→active_support/core_ext/string/inflections. OnlyString#demodulizeandString#underscoreare 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_accesslooked unused on first pass (we only constructActiveSupport::HashWithIndifferentAccess.new(...)directly, never callHash#with_indifferent_access). ButHashWithIndifferentAccess.new(hash)internally callsnested_under_indifferent_accesson 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 failuresbundle exec rubocop lib/grape.rb— clean🤖 Generated with Claude Code