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

[Fix #2044] Fix unintended document changes caused by default Rake task #2047

Conversation

koic
Copy link
Member

@koic koic commented Feb 18, 2025

This PR fixes unintended document changes caused by default Rake task.

Problem

The default task causes RuboCop::Config to end up in an unexpected state when internal_investigation task is executed before generate_cops_documentation task. This is due to the fact that plugins are already loaded when RuboCop is executed as part of internal_investigation.

Solution

This change preemptively determines whether configuration adjustments are necessary based on whether rubocop-rspec plugin has already been loaded.

Additional Information

Since this logic should ideally be encapsulated within CopsDocumentationGenerator, it is expected to become unnecessary in the future once the API design and implementation of CopsDocumentationGenerator class are complete. For now, this serves as a temporary workaround.

Fixes #2044.


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 18, 2025 07:56
@koic koic force-pushed the fix_unintended_document_changes_caused_by_default_rake_task branch from 9315b20 to a70e104 Compare February 18, 2025 07:59
…Rake task

This PR fixes unintended document changes caused by  default Rake task.

## Problem

The default task causes `RuboCop::Config` to end up in an unexpected state when
`internal_investigation` task is executed before `generate_cops_documentation` task.
This is due to the fact that plugins are already loaded when RuboCop is executed as
part of `internal_investigation`.

## Solution

This change preemptively determines whether configuration adjustments are necessary
based on whether `rubocop-rspec` plugin has already been loaded.

## Additional Information

Since this logic should ideally be encapsulated within `CopsDocumentationGenerator`,
it is expected to become unnecessary in the future once the API design and implementation of
`CopsDocumentationGenerator` class are complete. For now, this serves as a temporary workaround.

Fixes rubocop#2044.
@koic koic force-pushed the fix_unintended_document_changes_caused_by_default_rake_task branch from a70e104 to 30b09a3 Compare February 18, 2025 07:59
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!

@bquorning bquorning merged commit e8ac379 into rubocop:master Feb 18, 2025
27 checks passed
@koic koic deleted the fix_unintended_document_changes_caused_by_default_rake_task branch February 18, 2025 09:32
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.

Default rake task makes unintended changes to docs?
3 participants