Skip to content

Commit 30b09a3

Browse files
committed
[Fix #2044] Fix unintended document changes caused by default 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 #2044.
1 parent cd91408 commit 30b09a3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tasks/cops_documentation.rake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ end
1212

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

1720
generator = CopsDocumentationGenerator.new(
1821
departments: %w[RSpec]

0 commit comments

Comments
 (0)