Fix RuboCop offenses detected with rubocop-shopify 3.0.0#457
Merged
koic merged 1 commit intoJul 14, 2026
Merged
Conversation
## Motivation and Context This repository does not track Gemfile.lock, so `bundle install` resolves to the latest RuboCop gems. Upgrading rubocop-shopify from 2.x to 3.0.0 surfaces 8 new offenses because the shared config no longer disables `Style/MutableConstant`, newly disables `Lint/RescueException` and `Naming/AccessorMethodName`, and drops `AllowedPatterns` for `Naming/MethodName`. Upgrading rubocop itself to 1.88 surfaces one more offense from the new `Style/ReduceToHash` cop. This change fixes them as follows: - Freeze mutable constants. Regexp constants are also flagged because `TargetRubyVersion` is 2.7, where Regexp literals are not frozen. - Remove inline disable directives that became redundant. - Restore `AllowedPatterns: ['\Atest_']` for `Naming/MethodName` so `def test_` style test names can reference class names such as `NoMethodError`. - Swap out the frozen `SUPPORTED_STABLE_PROTOCOL_VERSIONS` constant in the protocol version fallback test since Mocha cannot stub methods on frozen objects. - Use `to_h` instead of `each_with_object` in `Server#index_resources_by_uri`. Ref: https://rubygems.org/gems/rubocop-shopify/versions/3.0.0 ## How Has This Been Tested? `bundle exec rake` passes: 1402 runs, 0 failures, 0 errors, and RuboCop reports no offenses. The conformance suite also passes against its baseline. ## Breaking Changes None. Freezing these constants only affects code that mutates them in place, which has never been supported.
Member
Author
|
I'll merge this now so upcoming CI runs can pass. |
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.
Motivation and Context
This repository does not track Gemfile.lock, so
bundle installresolves to the latest RuboCop gems. Upgrading rubocop-shopify from 2.x to 3.0.0 surfaces 8 new offenses because the shared config no longer disablesStyle/MutableConstant, newly disablesLint/RescueExceptionandNaming/AccessorMethodName, and dropsAllowedPatternsforNaming/MethodName. Upgrading rubocop itself to 1.88 surfaces one more offense from the newStyle/ReduceToHashcop.This change fixes them as follows:
TargetRubyVersionis 2.7, where Regexp literals are not frozen.AllowedPatterns: ['\Atest_']forNaming/MethodNamesodef test_style test names can reference class names such asNoMethodError.SUPPORTED_STABLE_PROTOCOL_VERSIONSconstant in the protocol version fallback test since Mocha cannot stub methods on frozen objects.to_hinstead ofeach_with_objectinServer#index_resources_by_uri.Ref: https://rubygems.org/gems/rubocop-shopify/versions/3.0.0
How Has This Been Tested?
bundle exec rakepasses: 1402 runs, 0 failures, 0 errors, and RuboCop reports no offenses. The conformance suite also passes against its baseline.Breaking Changes
None. Freezing these constants only affects code that mutates them in place, which has never been supported.
Types of changes
Checklist