Skip to content

Fix RuboCop offenses detected with rubocop-shopify 3.0.0#457

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:fix_rubocop_shopify_3_0_offenses
Jul 14, 2026
Merged

Fix RuboCop offenses detected with rubocop-shopify 3.0.0#457
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:fix_rubocop_shopify_3_0_offenses

Conversation

@koic

@koic koic commented Jul 14, 2026

Copy link
Copy Markdown
Member

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.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## 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.
@koic

koic commented Jul 14, 2026

Copy link
Copy Markdown
Member Author

I'll merge this now so upcoming CI runs can pass.

@koic koic merged commit 1101900 into modelcontextprotocol:main Jul 14, 2026
11 checks passed
@koic koic deleted the fix_rubocop_shopify_3_0_offenses branch July 14, 2026 16:51
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