Skip to content

Commit

Permalink
[Fix rubocop#2044] Fix unintended document changes caused by default …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
koic committed Feb 18, 2025
1 parent cd91408 commit a70e104
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tasks/cops_documentation.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ end

desc 'Generate docs of all cops departments'
task generate_cops_documentation: :yard_for_generate_documentation do
RuboCop::ConfigLoader.inject_defaults!("#{__dir__}/../config/default.yml")
plugins = RuboCop::ConfigLoader.default_configuration.loaded_plugins
if plugins.none? { |plugin| plugin.about.name == 'rubocop-rspec' }
RuboCop::ConfigLoader.inject_defaults!("#{__dir__}/../config/default.yml")
end

generator = CopsDocumentationGenerator.new(
departments: %w[RSpec]
Expand Down

0 comments on commit a70e104

Please sign in to comment.