Skip to content

Adopt Shopify's Ruby style guide via rubocop-shopify - #15

Merged
JPDuchesne merged 1 commit into
mainfrom
jpd/rubocop-shopify
Jul 24, 2026
Merged

Adopt Shopify's Ruby style guide via rubocop-shopify#15
JPDuchesne merged 1 commit into
mainfrom
jpd/rubocop-shopify

Conversation

@JPDuchesne

Copy link
Copy Markdown
Contributor

Summary

Mirrors ast-transform's setup: .rubocop.yml inherits rubocop-shopify (~> 3.0), a lint CI job runs RuboCop on Ruby 4.0, and dev style runs it locally. 183 offenses fixed; bundle exec rubocop is clean.

Judgment calls

  • Lint/Void excluded for test/example_rspock_test.rb (documented in .rubocop.yml): bare comparisons and Given/When/Then/Where constants are the RSpock dialect — the AST transform rewrites them into assertions, so they are not void.
  • Dev dependencies moved from gemspec to Gemfile (Gemspec/DevelopmentDependencies), as done in ast-transform.
  • Transformation#on_block: node.children[0]&.children[1] only guarded the first call in the chain (Lint/SafeNavigationChain); now an explicit nil check with unchanged semantics.
  • BlockCapture.capture moves under class << self (Style/ClassMethodsDefinitions).
  • Long lines inside expected-output heredocs are untouched: Layout/LineLength exempts heredocs (AllowHeredoc default), and they pin real emitted output.

Everything else is autocorrected layout, frozen_string_literal magic comments, and hash-syntax modernization.

Test plan

  • dev test: 242 tests, 0 failures
  • dev style: 59 files inspected, no offenses

Made with Cursor

Made with Cursor

Mirrors ast-transform: .rubocop.yml inherits the Shopify config, a lint
CI job runs rubocop on Ruby 4.0, and dev style runs it locally.

- example_rspock_test.rb is excluded from Lint/Void: bare comparisons
  and block-name constants ARE the RSpock dialect there.
- Development dependencies move from the gemspec to the Gemfile
  (Gemspec/DevelopmentDependencies).
- on_block's half-guarded safe navigation (`children[0]&.children[1]`)
  becomes an explicit nil check (Lint/SafeNavigationChain).
- BlockCapture.capture moves under class << self.
- Everything else is autocorrected layout and magic comments.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@JPDuchesne
JPDuchesne merged commit 8f33755 into main Jul 24, 2026
4 checks passed
@JPDuchesne
JPDuchesne deleted the jpd/rubocop-shopify branch July 24, 2026 21:52
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.

2 participants