Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluginfy RuboCop RSpec #2042

Merged
merged 1 commit into from
Feb 16, 2025
Merged

Conversation

koic
Copy link
Member

@koic koic commented Feb 15, 2025

This PR adds support for RuboCop's Plugin feature: rubocop/rubocop#13792

It replaces the ad-hoc Inject with RuboCop plugins introduced in RuboCop 1.72.

NOTE: Version 1.72.1 or later is specified, as it includes rubocop/rubocop#13837, which removes the Inject from spec_helper.rb. While 1.72.0 is sufficient for runtime, but specifying the patch version 1.72.1 keeps things simple.


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

If you have created a new cop:

  • Added the new cop to config/default.yml.
  • The cop is configured as Enabled: pending in config/default.yml.
  • The cop is configured as Enabled: true in .rubocop.yml.
  • The cop documents examples of good and bad code.
  • The tests assert both that bad code is reported and that good code is not reported.
  • Set VersionAdded: "<<next>>" in default/config.yml.

If you have modified an existing cop's configuration options:

  • Set VersionChanged: "<<next>>" in config/default.yml.

@koic koic requested a review from a team as a code owner February 15, 2025 18:41
@koic koic force-pushed the pluginfy_with_lint_roller branch from 5a3a9e6 to eba373f Compare February 15, 2025 18:52
Copy link
Collaborator

@bquorning bquorning left a comment

Choose a reason for hiding this comment

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

Our users will not be able to continue using require in their config file, right? They need to start using plugins instead?

rubocop-rspec.gemspec Outdated Show resolved Hide resolved
@koic koic force-pushed the pluginfy_with_lint_roller branch 5 times, most recently from d4325ec to b96ee8d Compare February 15, 2025 20:05
Copy link
Collaborator

@bquorning bquorning left a comment

Choose a reason for hiding this comment

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

CI is failing because module RuboCop::RSpec::Plugin#about never gets called. Would it make sense to make an assertion on e.g.

env = Struct.new(:config_store).new(RuboCop::ConfigStore.new))
RuboCop::Version.extension_versions(env)

including the string "rubocop-rspec"?

.rubocop.yml Show resolved Hide resolved
@koic
Copy link
Member Author

koic commented Feb 15, 2025

Our users will not be able to continue using require in their config file, right? They need to start using plugins instead?

For compatibility, the old require specification will still work. However, warning will be displayed to encourage updating to plugins. Therefore, users can replace it with plugins at any time.

@koic
Copy link
Member Author

koic commented Feb 15, 2025

CI is failing because module RuboCop::RSpec::Plugin#about never gets called.

Sorry, Plugin#about is something that gets called back from the RuboCop engine, so to be honest, I’m not sure if this coverage is meaningful.

@koic
Copy link
Member Author

koic commented Feb 15, 2025

Note, a simple plugin migration guide is available for reference:
https://docs.rubocop.org/rubocop/1.72/plugin_migration_guide.html

@bquorning
Copy link
Collaborator

cc @pirj, @ydah

Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Nice!

I’m away from my computer for a few days and can’t test manually.

This PR adds support for RuboCop's Plugin feature:
rubocop/rubocop#13792

It replaces the ad-hoc `Inject` with RuboCop plugins introduced in RuboCop 1.72.

NOTE: Version 1.72.1 or later is specified, as it includes rubocop/rubocop#13837,
which removes the `Inject` from spec_helper.rb. While 1.72.0 is sufficient for runtime,
but specifying the patch version 1.72.1 keeps things simple.
@koic koic force-pushed the pluginfy_with_lint_roller branch from b96ee8d to 5f09fdf Compare February 16, 2025 06:42
@bquorning
Copy link
Collaborator

Thank you @koic 🙏🏼

@bquorning bquorning merged commit 17640ad into rubocop:master Feb 16, 2025
27 checks passed
@koic koic deleted the pluginfy_with_lint_roller branch February 16, 2025 07:31
Copy link
Member

@ydah ydah left a comment

Choose a reason for hiding this comment

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

Thank you!

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.

4 participants