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
department-level enable/disable does not work #9752
Comments
I don't understand. Invalid configuration should make RuboCop stop and report the error, not be ignored. Do you get any error or warning message? |
I wrote the above because you said that department level enable/disable doesn't work at all. And that sounds strange to me, because I know that it basically works. 🙂 About the original ticket, I can see that Also, there's no concept of department hierarchy implemented in RuboCop, so I hope that helps. |
OK, so department is always everything up until the last slash, as opposed to everything up to the first slash. So if you have a rule A/B/C/D you can disable A/B/C (if it has a I can throw a PR at the chefstyle folks to add a default to Thanks! |
Yes.
Yes.
Great!
It's one of those things that feel like it should be fairly easy, but you can't say for sure until you've actually done it. I can try to implement it. Let's keep this issue open for a while. |
When there are cop departments that seem to have a structure, like in the cookstyle gem where departments are named `Chef/Style`, `Chef/Correctness`, etc., it's easy to assume that there is a `Chef` department that can disable all departments under it. This is not the case, but the error message `Error: unrecognized cop Chef found in .cookstyle.yml` is not informative enough. If an unrecognized cop or department is the first part of existing departments, we list the existing departments. This should help the user realize what needs to be changed. Also, we change the wording of `unrecognized cop` to `unrecognized cop or department`, and extend the did-you-mean functionality to also look for similar department names.
When there are cop departments that seem to have a structure, like in the cookstyle gem where departments are named `Chef/Style`, `Chef/Correctness`, etc., it's easy to assume that there is a `Chef` department that can disable all departments under it. This is not the case, but the error message `Error: unrecognized cop Chef found in .cookstyle.yml` is not informative enough. If an unrecognized cop or department is the first part of existing departments, we list the existing departments. This should help the user realize what needs to be changed. Also, we change the wording of `unrecognized cop` to `unrecognized cop or department`, and extend the did-you-mean functionality to also look for similar department names.
Hey @jonas054 since you closed this, should I open up a separate enhancement for hierarchical departments? |
Yes, feel free to do so. I'll take a look at the problem. Please tag me in the new issue and reference this issue in it. |
Over in rubocop/rubocop#9752 we figured out that the reason end-users can't enable/disable Cookstyle departments is because `Enabled` isn't in the config and thus [can't be overridden](rubocop/rubocop#9752 (comment)). This change will allow a user to not only do the obvious: ```yaml Chef/Correctness: Enabled: false ``` But more interestingly do something like this: ```yaml AllCops: DisabledByDefault: true Chef/Correctness: Enabled: true ``` CC @jonas054
Over in rubocop/rubocop#9752 we figured out that the reason end-users can't enable/disable Cookstyle departments is because `Enabled` isn't in the config and thus [can't be overridden](rubocop/rubocop#9752 (comment)). This change will allow a user to not only do the obvious: ```yaml Chef/Correctness: Enabled: false ``` But more interestingly do something like this: ```yaml AllCops: DisabledByDefault: true Chef/Correctness: Enabled: true ``` CC @jonas054
Over in rubocop/rubocop#9752 we figured out that the reason end-users can't enable/disable Cookstyle departments is because `Enabled` isn't in the config and thus [can't be overridden](rubocop/rubocop#9752 (comment)). This change will allow a user to not only do the obvious: ```yaml Chef/Correctness: Enabled: false ``` But more interestingly do something like this: ```yaml AllCops: DisabledByDefault: true Chef/Correctness: Enabled: true ``` CC @jonas054 Signed-off-by: Phil Dibowitz <phil@ipom.com>
UPDATE: On further investigation, department-level enable/disable just doesn't work.
The docs say this should work works:
But it turns out this doesn't work at all. This is because
Style
is seen as an "invalid" config in Config::Validator.validate() and thus ignored. :/Original ticket (for context)
This is probably not a rubocop bug, but I dunno where else to ask.
In the cookstyle project, we just sit ontop of the awesomeness that is Rubocop, and define a bunch of our own Cops and departments.
However, departments defined by our own cops don't seem to be enable-able the way, say
Style
is. So I can do this:But what I can't do is (
Chef/Correctness
here is a department, you can see code for cops in that department here).or even:
What's really strange is that in robocop I don't see any special setup for the
Style
orLayout
etc modules, so I would think this would "just work"... but it doesn't seem to. When I we try we get:If I do just
Chef
, then I get:I'm sure is some minor dumb thing we're doing or not doing that's preventing this from working like the rubocop-built-in departments.
Any help would be greatly appreciated.
The text was updated successfully, but these errors were encountered: