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

cop.documentation_url is nil for extension cops #12884

Closed
Earlopain opened this issue May 4, 2024 · 0 comments · Fixed by #12907
Closed

cop.documentation_url is nil for extension cops #12884

Earlopain opened this issue May 4, 2024 · 0 comments · Fixed by #12907

Comments

@Earlopain
Copy link
Contributor

Is your feature request related to a problem? Please describe.

This one here:

# Cops (other than builtin) are encouraged to implement this
# @return [String, nil]
#
# @api public
def self.documentation_url
Documentation.url_for(self) if builtin?
end

It only returns something for cops in this repository. The Ruby LSP makes use of this method to link to a cops documentation in code lenses:

image
The blue link takes me to https://docs.rubocop.org/rubocop/cops_style.html#stylestringliterals

Here is how it looks for rubocop-rails (and basically all other extension) cops:
image

The method has the following comment:

Cops (other than builtin) are encouraged to implement this

This hasn't happenend yet. I'd like to do so, however I don't really know how I would do that since the Documentation class is private.

Describe the solution you'd like

rubocop --show-docs-url Rails/Exit prints the correct url, so I wanted to just copy how it does that over. However I don't know how the get to the config/config store in the context of that method without requiring users to pass it in themselves.

Earlopain added a commit to Earlopain/rubocop that referenced this issue May 16, 2024
The current implementation is not very useful to consumers since it requires every extension to
overwrite this method.
No official extension currenty does that.

The behaviour of `--show-docs-url` is almost what's required. It takes a config to construct this url.

The url it provides falls back to the default RuboCop docs url which is undesirable in all cases I can think about. That behaviour has been removed.
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 16, 2024
The current implementation is not very useful to consumers since it requires every extension to
overwrite this method.
No official extension currenty does that.

The behaviour of `--show-docs-url` is almost what's required. It takes a config to construct this url.

The url it provides falls back to the default RuboCop docs url which is undesirable in all cases I can think about. That behaviour has been removed.
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 16, 2024
The current implementation is not very useful to consumers since it requires every extension to
overwrite this method.
No official extension currenty does that.

The behaviour of `--show-docs-url` is almost what's required. It takes a config to construct this url.

The url it provides falls back to the default RuboCop docs url which is undesirable in all cases I can think about. That behaviour has been removed.
bbatsov pushed a commit that referenced this issue May 20, 2024
The current implementation is not very useful to consumers since it requires every extension to
overwrite this method.
No official extension currenty does that.

The behaviour of `--show-docs-url` is almost what's required. It takes a config to construct this url.

The url it provides falls back to the default RuboCop docs url which is undesirable in all cases I can think about. That behaviour has been removed.
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.

1 participant