-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from Yoast/JRF/CS/add-phpcs
CS: start using YoastCS 0.5
- Loading branch information
Showing
4 changed files
with
141 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/vendor/ | ||
/composer.lock | ||
.phpcs.xml | ||
phpcs.xml |
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,129 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="Yoast WHIP"> | ||
<description>Yoast WHIP rules for PHP_CodeSniffer</description> | ||
|
||
<!-- | ||
############################################################################# | ||
COMMAND LINE ARGUMENTS | ||
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml | ||
############################################################################# | ||
--> | ||
|
||
<file>.</file> | ||
|
||
<exclude-pattern>vendor/*</exclude-pattern> | ||
|
||
<!-- Only check PHP files. --> | ||
<arg name="extensions" value="php"/> | ||
|
||
<!-- Show progress, show the error codes for each message (source). --> | ||
<arg value="ps"/> | ||
|
||
<!-- Strip the filepaths down to the relevant bit. --> | ||
<arg name="basepath" value="./"/> | ||
|
||
<!-- Check up to 8 files simultanously. --> | ||
<arg name="parallel" value="8"/> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jrfnl
Contributor
|
||
|
||
|
||
<!-- | ||
############################################################################# | ||
USE THE YoastCS RULESET | ||
############################################################################# | ||
--> | ||
|
||
<rule ref="Yoast"> | ||
<!-- Historically, this library has used camelCaps not snakecase for variable and function names. --> | ||
<exclude name="WordPress.NamingConventions.ValidVariableName"/> | ||
<exclude name="WordPress.NamingConventions.ValidFunctionName"/> | ||
|
||
<!-- Historically, this library uses camelCaps file names. --> | ||
<exclude name="Yoast.Files.FileName"/> | ||
</rule> | ||
|
||
<!-- Check that variable names are in camelCaps. --> | ||
<rule ref="Squiz.NamingConventions.ValidVariableName"> | ||
<!-- Private properties should, however, *not* start with an underscore. --> | ||
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/> | ||
</rule> | ||
|
||
<!-- Check that function and method names are in camelCaps. --> | ||
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"> | ||
<properties> | ||
<!-- Allow for two adjacent capital letters for acronyms. --> | ||
<property name="strict" value="false"/> | ||
</properties> | ||
|
||
<!-- Exclude WordPress example function. --> | ||
<exclude-pattern>/src/facades/wordpress\.php$</exclude-pattern> | ||
|
||
<!-- Exclude mocks of WP Core functions which comply with the WP function name rules instead. --> | ||
<exclude-pattern>/tests/doubles/WpCoreFunctionsMock\.php$</exclude-pattern> | ||
</rule> | ||
|
||
|
||
<!-- | ||
############################################################################# | ||
SNIFF SPECIFIC CONFIGURATION | ||
############################################################################# | ||
--> | ||
|
||
<!-- Set the minimum supported WP version. This is used by several sniffs. --> | ||
<config name="minimum_supported_wp_version" value="3.0"/> | ||
|
||
<!-- Verify that everything in the global namespace is prefixed with a plugin specific prefix. --> | ||
<rule ref="WordPress.NamingConventions.PrefixAllGlobals"> | ||
<properties> | ||
<!-- Provide the prefixes to look for. --> | ||
<property name="prefixes" type="array" value="whip"/> | ||
</properties> | ||
|
||
<!-- Valid usage: For testing purposes, allow non-prefixed globals. --> | ||
<exclude-pattern>/tests/doubles/WPCoreFunctionsMock\.php$</exclude-pattern> | ||
</rule> | ||
|
||
|
||
<!-- | ||
############################################################################# | ||
TEMPORARY ADJUSTMENTS | ||
Adjustments which should be removed once the associated issue has been resolved. | ||
############################################################################# | ||
--> | ||
|
||
<!-- Textdomain is passed in dynamically which will not work correctly with gettext(). | ||
Ticket: https://github.com/Yoast/whip/issues/2 --> | ||
<rule ref="WordPress.WP.I18n.NonSingularStringLiteralDomain"> | ||
<type>warning</type> | ||
</rule> | ||
|
||
<rule ref="WordPress.WP.I18n.NonSingularStringLiteralText"> | ||
<!-- False positive. This has already been fixed in WPCS. | ||
The fix will be included in WPCS 1.0.0. | ||
Once this repo moves up to using WPCS 1.0.0, this exclusion can be removed. | ||
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1267 | ||
--> | ||
<exclude-pattern>/tests/doubles/WPCoreFunctionsMock\.php$</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound"> | ||
<!-- These hook setups should be reviewed. | ||
Ticket: https://github.com/Yoast/whip/issues/67 --> | ||
<exclude-pattern>/src/Whip_Host\.php$</exclude-pattern> | ||
</rule> | ||
|
||
<!-- Tests should be documented too. | ||
Ticket: https://github.com/Yoast/whip/issues/66 --> | ||
<rule ref="Generic.Commenting.DocComment.MissingShort"> | ||
<exclude-pattern>/tests/*\.php$</exclude-pattern> | ||
</rule> | ||
<rule ref="Generic.Commenting.DocComment.SpacingBeforeTags"> | ||
<exclude-pattern>/tests/*\.php$</exclude-pattern> | ||
</rule> | ||
<rule ref="Squiz.Commenting.FunctionComment.Missing"> | ||
<exclude-pattern>/tests/*\.php$</exclude-pattern> | ||
</rule> | ||
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag"> | ||
<exclude-pattern>/tests/*\.php$</exclude-pattern> | ||
</rule> | ||
|
||
</ruleset> |
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
@jrfnl Is this documented somewhere?