-
-
Notifications
You must be signed in to change notification settings - Fork 263
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 incorrect documentation URLs when using rubocop --show-docs-url
#756
Conversation
Can you solve the following issue? This should apply to each different base URL. % bundle exec rubocop --show-docs-url Rails/ActionControllerTestCase,Layout/ArgumentAlignment,RSpec/Be
https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsactioncontrollertestcase
https://docs.rubocop.org/rubocop-rails/cops_layout.html#layoutargumentalignment
https://docs.rubocop.org/rubocop-rails/cops_rspec.html#rspecbe |
So the existing implementation of the rubocop gem about DocumentationBaseURL is actually broken and this is a feature that should not currently be used until it is fixed? If it looks like something can be easily fixed, I will try to work on that issue on rubocop gem. |
It can be imagined that major 3rd party cop gem users will encounter this confusion with this upstream change. So these PRs should not be merged until the issue is resolved. |
config/default.yml
Outdated
@@ -10,6 +10,7 @@ AllCops: | |||
# Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default. | |||
# See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application | |||
- db/*schema.rb | |||
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koic Oh, my mistake, I meant to define Rails.DocumentationBaseURL, but I had defined AllCops.DocumentationBaseURL. Maybe this will fix that problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Can you add a changelog entry?
I have confirmed that it works well after adding bug fix at 971e509.
I'll squash the commits. |
It turns out that this was my misunderstanding after all, sorry for that. There was nothing wrong with the implementation of the rubocop gem. I checked other related pull requests for the same bug, and they were also fine. |
@r7kamura You've maybe overlooked the following :-) |
@@ -0,0 +1 @@ | |||
* [#756](https://github.com/rubocop/rubocop-rails/pull/756): Add DocumentationBaseURL. ([@r7kamura][]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about the changelog entry for users like this:
* [#756](https://github.com/rubocop/rubocop-rails/pull/756): Add DocumentationBaseURL. ([@r7kamura][]) | |
* [#756](https://github.com/rubocop/rubocop-rails/pull/756): Fix incorrect documentation base URL when using `rubocop --show-docs-url`. ([@r7kamura][]) |
And I think changelog/fix_add_documentationbaseurl.md
is more appropriate than changelog/change_add_documentationbaseurl.md
as the file name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point 🦀
I'll improve them also in the other related pull requests
6a519e2
to
481eaea
Compare
rubocop --show-docs-url
@r7kamura I checked locally and got the following warning. Can you investigate? % bundle exec rubocop --show-docs-url Rails/ActionControllerTestCase,Layout/ArgumentAlignment,RSpec/Be
Warning: Rails does not support Enabled parameter.
Supported parameters are:
- DocumentationBaseURL
https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsactioncontrollertestcase
https://docs.rubocop.org/rubocop/cops_layout.html#layoutargumentalignment
https://docs.rubocop.org/rubocop/cops_rspec.html#rspecbe |
I also checked without options. % bundle exec rubocop
Warning: Rails does not support Enabled parameter.
Supported parameters are:
- DocumentationBaseURL
Inspecting 267 files
...........................................................................................................................................................................................................................................................................
267 files inspected, no offenses detected |
I tried it in a completely clean environment. This did nothing wrong and could not reproduce that warning.
I wondered if you might have added some settings to .rubocop.yml in your environment, so I made the following changes. diff --git a/.rubocop.yml b/.rubocop.yml
index de58178..c1e1f37 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -4,3 +4,6 @@ require:
AllCops:
NewCops: enable
+
+Rails:
+ Enabled: true Then the warning appeared.
I think this is very similar to the following issue. I will try to solve this by adding |
Sure, this seems to solve the issue. diff --git a/config/default.yml b/config/default.yml
index 2a8e141ce..3d8f29635 100644
--- a/config/default.yml
+++ b/config/default.yml
@@ -10,7 +10,6 @@ AllCops:
# Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default.
# See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application
- db/*schema.rb
# Enable checking Active Support extensions.
# See: https://docs.rubocop.org/rubocop/configuration.html#enable-checking-active-support-extensions
ActiveSupportExtensionsEnabled: true
@@ -23,6 +22,10 @@ AllCops:
# as the default.
TargetRailsVersion: ~
Rails:
+ Enabled: true
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails
Lint/NumberConversion:
# Add Rails' duration methods to the ignore list for `Lint/NumberConversion`
# so that calling `to_i` on one of these does not register an offense. |
config/default.yml
Outdated
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails | ||
Enabled: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tweak it? Enabled
is probably a more important parameter than DocumentationBaseURL
.
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails | |
Enabled: true | |
Enabled: true | |
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails |
Thanks! |
Added
DocumentationBaseURL
forrubocop --show-docs-url [COP1,COP2,...]
command to work correctly for rubocop-rails cops.Before
After
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.