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 #7077] Rename cops to meet the cop naming guideline #10725
base: master
Are you sure you want to change the base?
[Fix #7077] Rename cops to meet the cop naming guideline #10725
Conversation
Might also be a good idea to spell out the naming guidelines explicitly in the docs and add some internal affairs cop that looks for common problems (mostly problematic words appearing in the name or in the wrong order). I'm also wondering if we can come up with a good replacement for things like Perhaps we should be spelling out |
I've added a small note to to the Development section of our docs, as it seems to be the only one on the topic of creating new cops:
After a while, my old idea of writing it as:
does not seem very specific and guiding. There are some good practices behind good cop naming, but I miserably fail to extract them into concise statements. |
You don't have to be super concise. ;-) |
7c7daec
to
dced8a2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
b33fdc2
to
28d52cb
Compare
Docs (with reference formatting fixes) for easier view https://github.com/rubocop/rubocop/blob/28d52cb0d2c730c7f854961170c8480c85529973/docs/modules/ROOT/pages/development.adoc#choose-a-name |
Just to confirm - right now that's not a breaking change, right? I recall @dvandersluis worked on this a while back. |
---- | ||
|
||
=== Choose a Name | ||
|
||
Pick a department. See the xref:cops.adoc[list of existing departments]. |
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.
Why not make these bullet points?
It is unfortunately:
|
I added a way to set |
Actually I remember now why we didn't. I tried implementing warnings for renames, but we still get an error because there's some other checks, for instance (yellow is the warning from and then RuboCop quits anyways. So there doesn't look like there's an easy way to make a warning happen here. Even if it didn't error, the cop class itself wouldn't know where to find it's config. What we've done in some cases for renamed params is have the config handle both the old (deprecated) case and the new renamed case, and then update the cop to use both. We can't really easily do that with full cop renames though... |
I have an idea about how we might be able to solve this problem, I'm going to play with it tomorrow. In the meantime, as @pirj said, this would be a breaking change. |
…Constructor There is no consensus which term is appropriate, "or-assignment" or "disjunctive assignment". For consistency with `Lint/OrAssignmentToConstant`, and to save a bunch of bytes, a shorter name was chosen.
5520e43
to
b409e45
Compare
---- | ||
|
||
=== Choose a 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.
@bbatsov Does this guide look complete?
@dvandersluis Any breakthrough on the idea to painlessly rename cops between major version updates? |
@pirj I’ve been away from home but I’m hoping to get back to it in next week. |
@dvandersluis We came up with an idea to obsolete cops without actually removing them, see rubocop/rubocop-rspec#1519. The idea is to:
That way, there's an obsoletion warning, but no error trying to load the config. I can rework this PR in the same way. Would you consider this a non-breaking, mergeable change? In 2.0 we'll have to remove cops with the old names along with their configs and that's it. |
Hey @pirj, sorry that I obviously never had the time to work on this like I wanted to. I think your solution makes sense! |
I agree that the new proposal is a non-breaking one (at least in my book) and provides a nice path to complete removal down the road. |
This looks like a good way. One thing, can we use assignment ( |
That was the initial approach, I can't recall why I've switched to inheriting, I'll check if it works. |
Probably, but the doc generation task breaks. # Some cop docs
# !@parse class class NewNameCop < ::RuboCop::Cop::Base; end
NewNameCop = ObsoleteNameCop But for some reason, documentation above the It appears that this is the only way in any case, as obsoletion errors sometimes appear when inheritance is used. |
Luckily, there's a workaround: # !@parse
# # Some cop docs
# class NewNameCop < ::RuboCop::Cop::Base; end
NewNameCop = ObsoleteNameCop See rubocop/rubocop-rspec#1519 for more details. |
As I left a comment on rubocop/rubocop-rspec#1519 (comment), the current implementation should have used inheritance ( |
My apologies, @koic, I'm not convinced enough that duplicate output from the old and the new cop that is an impact on user experience is a good tradeoff for not modifying the code that builds cops' documentation. I may miss something important, but the duplicate output was my experience with the inheritance approach. |
fixes #7077, with an exception, see below
fixes #10089 along the way
Not Done
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.