-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
PrefixAllGlobals: verify that namespace names use a prefix #1515
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.4.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals prefixes acronym,tgmpa,test_this,test\that | ||
|
||
namespace TGMPA; | ||
|
||
namespace Acronym\B\C; | ||
|
||
namespace AcronymPlugin\B\C; | ||
|
||
namespace Test_This\C; | ||
|
||
namespace Test\This\C; | ||
|
||
namespace Test\That\C; | ||
|
||
namespace Test \ /* comment */ This \ C; | ||
|
||
namespace A\B\C; // Bad. | ||
|
||
use namespace\DEF; // Not our target. | ||
namespace\cname::method(); // Not our target. | ||
$acronym_result = namespace \ blah \ mine(); // Not our target. | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals prefixes wordpress | ||
namespace wordpress\myplugin; | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals prefixes wordpress\myplugin | ||
namespace wordpress\myplugin; | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.PrefixAllGlobals prefixes false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
One thing I've found beneficial when working on VIPCS, was to add a comment for each test case to identify what case was being tested. e.g.
etc. Same goes for
// Bad
cases - adding a comment as to what aspect of the logic something fails.I think this makes it easier to follow and understand the test cases, and helps avoid redundant test cases that don't test anything new.
Could comments like that be added here?
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.
Go right ahead if you feel the need. To me, those comments don't add any value as this sniff only has one purpose which is checking if something is prefixed.
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.
But the different test cases are checking all the different ways that it can be prefixed - the how, rather than the what.
I'm not going to be able to get these comments in the near future. The review is already approved. Probably needs a new ticket to add comments in for OK and Bad tests cases across all the sniffs.
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.
That is documented in both the sniff as well as the commit message.
There are definitely some cases where additional comments in the unit test files could have value, but let's not go overboard.
Sounds like a plan, low priority though as there are plenty of real issues to address still. Possibly mark it as
good first issue
?As we changed to one approval, feel free to merge it.