[Fix #9752] Improve error message for top level department #9936
+45
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a smaller change than the one suggested in #9752. Instead of allowing to use top level departments in configuration, I just made a better error message. I think this change has a lower risk of causing new problems down the line.
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 aChef
department that can disable all departments under it. This is not the case, but the error messageError: 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. Example:
Also, we change the wording of
unrecognized cop
tounrecognized cop or department
, and extend the did-you-mean functionality to also look for similar department names.