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

Default rake task makes unintended changes to docs? #2044

Closed
bquorning opened this issue Feb 16, 2025 · 6 comments · Fixed by #2047
Closed

Default rake task makes unintended changes to docs? #2044

bquorning opened this issue Feb 16, 2025 · 6 comments · Fixed by #2047

Comments

@bquorning
Copy link
Collaborator

Running rake locally causes a seemingly unintended change to docs.

I tried “bisecting” the default rake command to find the issue, and interestingly bundle exec rake confirm_config documentation_syntax_check confirm_documentation does not trigger the issue, but bundle exec rake internal_investigation confirm_documentation does:

diff --git a/docs/modules/ROOT/pages/cops_rspec.adoc b/docs/modules/ROOT/pages/cops_rspec.adoc
index 31946294..64666d40 100644
--- a/docs/modules/ROOT/pages/cops_rspec.adoc
+++ b/docs/modules/ROOT/pages/cops_rspec.adoc
@@ -537,17 +537,6 @@ expect { run }
   .and not_change { Foo.baz }
 ----
 
-[#configurable-attributes-rspecchangebyzero]
-=== Configurable attributes
-
-|===
-| Name | Default value | Configurable values
-
-| NegatedMatcher
-| `<none>`
-| 
-|===
-
 [#references-rspecchangebyzero]
 === References

I noticed this on the latest master branch (dac4256) with the most recent dependencies installed.

@bquorning
Copy link
Collaborator Author

cc @pirj, @ydah

@ydah
Copy link
Member

ydah commented Feb 17, 2025

I confirmed that if this line is commented out, it does not occur.

RuboCop::ConfigLoader.inject_defaults!("#{__dir__}/../config/default.yml")

@bquorning
Copy link
Collaborator Author

Ah, so perhaps when rake (default) is run, the inject code and the plugin code is in conflict?

@bquorning
Copy link
Collaborator Author

cc @koic

koic added a commit to koic/rubocop-rspec that referenced this issue Feb 18, 2025
…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
Copy link
Member

koic commented Feb 18, 2025

Sorry for taking up your time due to the documentation generation issue. This is a workaround fix, and #2047 has been opened. I plan to address the issue in RuboCop core in the future to allow for simpler usage.

koic added a commit to koic/rubocop-rspec that referenced this issue Feb 18, 2025
…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.
@bquorning
Copy link
Collaborator Author

No worries @koic, and thank you for having a look – and for fixing it too.

bquorning added a commit that referenced this issue Feb 18, 2025
…used_by_default_rake_task

[Fix #2044] Fix unintended document changes caused by default Rake task
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 a pull request may close this issue.

3 participants