Skip to content

Bump rubocop, fix violations, add Ruby matrix#215

Merged
mokagio merged 4 commits into
masterfrom
mokagio/bump-rubocop
Jun 9, 2026
Merged

Bump rubocop, fix violations, add Ruby matrix#215
mokagio merged 4 commits into
masterfrom
mokagio/bump-rubocop

Conversation

@mokagio

@mokagio mokagio commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Builds on top of #214 to implement "noisy" changes:

  • Update RuboCop to version compatible with modern Ruby
  • Address the various RuboCop violations
  • Run RSpec tests against multiple 3.x Ruby versions

mokagio and others added 3 commits May 26, 2026 14:24
Drops the ~> 0.50.0 (2017) pin and the band-aids it required:
`TargetRubyVersion: 2.4` and the Ruby 2.7 workflow pin (the latter
removed in a follow-up commit).
`Metrics/LineLength` is renamed to `Layout/LineLength` (cop moved
namespace in rubocop 0.79).
`NewCops: disable` keeps the surface stable; flipping it on can be a
follow-up.

This commit knowingly leaves the linter red — violations are addressed
in the next commit.

---

Generated with the help of Claude Code, https://claude.ai/code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mostly autocorrected: trailing whitespace, indentation, block-brace
spacing, redundant regex escapes, gem ordering, frozen-string magic
comments, etc.
`rubocop -a` followed by manual config tweaks to clear what can't be
mechanically fixed without changing public API:

- `Metrics/ClassLength` raised to 250 (DangerSwiftlint is 213 lines).
- `Metrics/MethodLength` raised to 15 (`Swiftlint#run` is 14).
- `Metrics/ParameterLists` excluded for `Swiftlint#run` — the
  positional/keyword signature is the plugin's public contract.
- `Metrics/PerceivedComplexity` adds `swiftlint.rb` to existing exclude.
- `Lint/ConstantDefinitionInBlock` excluded for the rake task —
  intentional rake idiom.
- `Gemspec/RequiredRubyVersion` disabled; the gemspec's minimum is a
  downstream-compatibility statement, not a lint target.
- `spec/.rubocop.yml` migrated from `Metrics/LineLength` to
  `Layout/LineLength` (the namespace move that bit the parent config).

Specs continue to pass (57 examples, 0 failures).

---

Generated with the help of Claude Code, https://claude.ai/code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`spec` now runs across Ruby 3.0–3.4.
`rubocop` no longer needs the Ruby 2.7 pin or the matching FIXME now
that the gem is on a modern release.

`parallel` is pinned to `< 2` in the Gemfile: parallel 2.x requires
Ruby >= 3.3, which would break matrix entries for 3.0–3.2.
The pin is dev-only and doesn't affect downstream consumers.

Smoke-tested locally on Ruby 3.2.2 and 3.3.7; both pass.
3.0 and 3.1 are exercised on CI.

---

Generated with the help of Claude Code, https://claude.ai/code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mokagio mokagio self-assigned this May 26, 2026
Comment thread .github/workflows/ci.yml
Comment on lines 26 to 34
rubocop:
name: RuboCop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- run: bundle exec rubocop

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem worth to run RuboCop on a matrix as it's less important than test coverage, as the latter could discover genuine compatibility issues. But, it should be relatively cheap to add a matrix here too.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this is the right tradeoff 👍

Comment thread Gemfile
Comment on lines +15 to +17
# `parallel` 2.x requires Ruby >= 3.3 — keep it on 1.x so the matrix
# can still install on Ruby 3.0–3.2.
gem 'parallel', '< 2'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, go one step forward and drop 3.0-3.2 given they are no longer supported...

Image

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine with dropping those versions. The only devs who would face an issue would be devs updating their CI, so, they'd be keeping up to date with Ruby too. (Or at least, I hope so!)

@mokagio mokagio marked this pull request as ready for review May 26, 2026 06:37
Copilot AI review requested due to automatic review settings May 26, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Modernizes the project’s Ruby tooling by upgrading RuboCop, applying the resulting formatting/lint fixes, and expanding CI to run the RSpec suite across multiple Ruby 3.x versions.

Changes:

  • Upgrade RuboCop to a modern release and update RuboCop configuration (including new cop namespaces/settings).
  • Apply RuboCop-driven code/spec formatting fixes and small refactors.
  • Update GitHub Actions to run RSpec on a Ruby 3.0–3.4 matrix and remove the RuboCop Ruby 2.7 pin.

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/swiftlint_spec.rb Spec require/path and formatting adjustments to satisfy newer RuboCop rules.
spec/spec_helper.rb Updates ROOT resolution and load path setup (currently introduces a broken $LOAD_PATH entry).
spec/danger_plugin_spec.rb Spec formatting/whitespace and block style fixes.
spec/.rubocop.yml Updates deprecated cop namespace (Metrics/LineLengthLayout/LineLength).
lib/danger_plugin.rb Formatting refactors and minor code cleanups to satisfy RuboCop.
Gemfile Bumps RuboCop constraint and adds dev dependency constraints for Ruby matrix compatibility.
Gemfile.lock Locks updated RuboCop and transitive dependencies.
ext/swiftlint/swiftlint.rb Minor style cleanups (method parens, early return) per RuboCop.
ext/swiftlint/Rakefile Freezes a URL constant to satisfy frozen string / style rules.
danger-swiftlint.gemspec Modernizes path expansion and reorders dependencies.
bin/danger-swiftlint Simplifies load path setup using __dir__.
.rubocop.yml Updates RuboCop baseline config for Ruby 3.0+ and adds targeted exclusions.
.github/workflows/ci.yml Adds Ruby matrix to RSpec job and removes RuboCop’s Ruby 2.7 pin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/spec_helper.rb Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@ashfurrow ashfurrow left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Left some notes. We can redirect to the main branch and merge when you see fit.

Thanks again for this. It was good to see you around GitHub!

Comment thread .github/workflows/ci.yml
Comment on lines 26 to 34
rubocop:
name: RuboCop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- run: bundle exec rubocop

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this is the right tradeoff 👍

Comment thread Gemfile
Comment on lines +15 to +17
# `parallel` 2.x requires Ruby >= 3.3 — keep it on 1.x so the matrix
# can still install on Ruby 3.0–3.2.
gem 'parallel', '< 2'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine with dropping those versions. The only devs who would face an issue would be devs updating their CI, so, they'd be keeping up to date with Ruby too. (Or at least, I hope so!)

@mokagio mokagio changed the base branch from mokagio/add-gha-ci to master June 9, 2026 05:38
@mokagio mokagio merged commit 86c4215 into master Jun 9, 2026
6 checks passed
@mokagio mokagio deleted the mokagio/bump-rubocop branch June 9, 2026 05:39
@mokagio

mokagio commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

It was good to see you around GitHub!

Likewise! I subscribe to this repo and it was nice to see the notification pop up for #213. Hope everything is well.

pgrbot-01 pushed a commit to Progressive-Insurance/danger-ruby-swiftlint that referenced this pull request Jun 12, 2026
Follow up to
ashfurrow#215 (comment),
which highlighted Ruby versions < 3.3 are no longer receiving support.
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.

3 participants