-
-
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
Remove WordPress-Core from WordPress-VIP standard #676
Conversation
Just some thoughts on this: I know there are a number of rules which are now in the Most coding standards are about code style. However the WP Core coding standard encompasses both code style as well as best practices. Removing the So, what about maybe collecting the code style rules in a separate ruleset which can be included in This would also make life easier for teams which use a different code style (Zend, Symphony), but would like to include the WP coding standards to get the benefit of the best practices. |
Good point, any VIP requirements that have been inherited from I think the simplest way to do this is to just identify the sniffs from But, all of this to say, maybe I'm taking the completely wrong approach. The goal here is to eliminate the noise for VIP code wranglers when reviewing code submissions. So perhaps all that is really needed in this regard is to create a new custom ruleset that extends |
One thing I'd like to highlight here, is that VIP is a commercial venture from one particular company. I realise there are VIP partners who have clients on VIP hosting who therefore need to check all the code they write (and use from 3rd parties) meets certain criteria, but ultimately, this is an Automattic-specific ruleset. Would we allow I know that in many of the projects I do, which won't ever be used on VIP, the default ruleset is Maybe it's worth considering that, now there are more than a few trivial rules, we suggest that Automattic run their own VIP sniffs open source repo, and then they are free to include whatever sniffs from Core, Extras or Docs, as they wish? |
I second @jrfnl's suggestion of possibly splitting the core ruleset. I think that would provide the most flexibility for people who want to extend the rulesets. If someone just wants to have the whitespace or just wants to have the best-practices, they don't want to have to go through the rulesets each time WPCS releases a new versions and tease all of that out from the core ruleset. They'd much rather be able to reference a specific ruleset that just contains the type of rules that they are interested in, and then forget it. As far as removing VIP, I usually use VIP in my custom rulesets, although I do exclude some of the rules. I think that there are a lot of useful best practices that are a part of VIP but not the extra ruleset (although maybe that has changed, I dunno). So I wouldn't really want to see VIP removed completely, unless some of that was retained for the extra ruleset. |
This should definitely be changed over then IMO. |
So should In terms of what would specifically be of help to the VIP code wranglers who don't care about code style but just about best practices (and specifically those which are on their blocker and caution lists), then maybe it's easiest for them to have their own custom rulesets that just exclude/suppress all of the sniffs that aren't relevant to them. These rulesets could just live in their fork at https://github.com/Automattic/WordPress-Coding-Standards |
I think it would be easiest to split Something like: <?xml version="1.0"?>
<ruleset name="WordPress Core">
<rule ref="WordPress-Code-Style"/>
... the other rules ...
</ruleset> The line would between For the <?xml version="1.0"?>
<ruleset name="WordPress VIP">
<description>WordPress VIP Coding Standards</description>
<rule ref="WordPress-Core">
<exclude name="WordPress-Code-Style" />
</rule>
... the other rules ...
</ruleset> What do you think ? |
I haven't worked with the project rulesets to this degree. If PHPCS can handle indirect exclusions like this that would be awesome. So let's say the <?xml version="1.0"?>
<ruleset name="WordPress Core">
<rule ref="WordPress-Code-Style" />
<!-- ... the sniffs for best practices ... -->
</ruleset> Assuming then <?xml version="1.0"?>
<ruleset name="WordPress VIP">
<rule ref="WordPress-Core" />
<!-- ... the other VIP rules for caution and blocker issues ... -->
</ruleset> For the sake of the VIP code wranglers (who don't want strict, i.e. code style), wouldn't it instead be: <?xml version="1.0"?>
<ruleset name="WordPress VIP Critical">
<description>WordPress VIP Coding Standards for blockers and cautions</description>
<rule ref="WordPress-VIP">
<exclude name="WordPress-Code-Style" />
</rule>
</ruleset> Does this work? Namely, |
It should - I checked the PHPCS wiki before I suggested it. Quote taken from https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml:
|
Nice! I didn't see that. It's not reflected on the PEAR documentation page, which is what I had seen: https://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php |
A proposal following up on this can be found in #740 |
The approach of splitting I'm not convinced of the value in splitting up WP Core into yet another subgroup. If a rule is in the handbook, then it's in the handbook, regardless of whether it's for security, whitespace or general formatting. The Core standard is already somewhat broken up, by the directories the Sniffs are stored in, and excludes can be done on that basis. My understanding of the VIP rules here, is that they are for developers who are writing code that could be used on the VIP platform. What the Automattic employees (a different group of people) want is their own ruleset which includes our VIP rules, but excludes certain others. Again, both the VIP, and the "VIP Review" rulesets are very company-specific, and I'm uncomfortable with that. I'd rather our efforts were spent in identifying, agreeing and moving the best practice parts of VIP over to Extras (I agree, some are useful), and encouraging Automattic to create their own "VIP Review" ruleset (it's their internal tool after all), and ideally taking ownership of the VIP ruleset as well. For me, we should be maintaining and improving just the following standards:
In short, I don't think this is our problem to solve, so long as there are sufficient ways for them (or anyone) to exclude whatever individual rules they don't want reported, and no separate ruleset is needed to be created by us for that to happen. |
The current proposal as I've outlined in #740 will not break backward compatibility. The Core ruleset would be split into two completely different rulesets which both would then be included in the
While the original issue was opened by @westonruter with an eye on VIP, I think the Theme Review Automation project might find this splitting off useful as well as they could then include the Core best practice rules without the code style rules (which themes don't have to comply with).
One doesn't exclude the other, but yes, I agree that "our" focus should not be on VIP. |
+1 to this. The highlighting my own emphasis. PR #633 is a start at the separation.
I think I would prefer to keep all of the control in the |
There is a lot of noise reported from the
WordPress-Core
standard that the VIP team doesn't care about. They don't care about whitespace and bracket usage, but rather they care about issues like security and not using restricted functions. As such, theWordPress-VIP
standard should removeWordPress-Core
. If theWordPress-Core
are desired alongside theWordPress-VIP
sniffs then all that is required is for both standards to be used when invoking PHPCS:Either this, or a custom project-specific
ruleset.xml
can be used which calls in both of these standards.