|
1 | 1 | <?xml version="1.0"?> |
2 | 2 | <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Coding Standard for WP Test Utils" xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd"> |
3 | | - <description>Check the code of WP Test Utils.</description> |
| 3 | + <description>Check the code of WP Test Utils.</description> |
4 | 4 |
|
5 | | - <!-- |
6 | | - ############################################################################# |
7 | | - COMMAND LINE ARGUMENTS |
8 | | - https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml |
9 | | - ############################################################################# |
10 | | - --> |
| 5 | + <!-- |
| 6 | + ############################################################################# |
| 7 | + COMMAND LINE ARGUMENTS |
| 8 | + https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml |
| 9 | + ############################################################################# |
| 10 | + --> |
11 | 11 |
|
12 | | - <file>.</file> |
| 12 | + <file>.</file> |
13 | 13 |
|
14 | | - <!-- Only check PHP files. --> |
15 | | - <arg name="extensions" value="php"/> |
| 14 | + <!-- Only check PHP files. --> |
| 15 | + <arg name="extensions" value="php"/> |
16 | 16 |
|
17 | | - <!-- Show progress, show the error codes for each message (source). --> |
18 | | - <arg value="ps"/> |
| 17 | + <!-- Show progress, show the error codes for each message (source). --> |
| 18 | + <arg value="ps"/> |
19 | 19 |
|
20 | | - <!-- Strip the filepaths down to the relevant bit. --> |
21 | | - <arg name="basepath" value="./"/> |
| 20 | + <!-- Strip the filepaths down to the relevant bit. --> |
| 21 | + <arg name="basepath" value="./"/> |
22 | 22 |
|
23 | | - <!-- Check up to 8 files simultaneously. --> |
24 | | - <arg name="parallel" value="8"/> |
| 23 | + <!-- Check up to 8 files simultaneously. --> |
| 24 | + <arg name="parallel" value="8"/> |
25 | 25 |
|
26 | 26 | <!-- Cache the results between runs. --> |
27 | 27 | <arg name="cache" value="./.cache/phpcs.cache"/> |
|
41 | 41 | </property> |
42 | 42 | </properties> |
43 | 43 |
|
44 | | - <!-- Use CamelCaps file names to be more in line with the naming conventions used in PHPUnit. --> |
45 | | - <exclude name="Yoast.Files.FileName"/> |
| 44 | + <!-- Exclude some rules which are irrelevant. |
| 45 | + The code in this package is not run in the context of a WordPress plugin. --> |
| 46 | + <exclude name="WordPress.DB"/> |
| 47 | + <exclude name="WordPress.Security"/> |
| 48 | + <exclude name="WordPress.WP"/> |
| 49 | + <exclude name="Yoast.Yoast.JsonEncodeAlternative"/> |
| 50 | + <exclude name="WordPressVIPMinimum.Classes.DeclarationCompatibility"/> |
| 51 | + <exclude name="WordPressVIPMinimum.Hooks.AlwaysReturnInFilter"/> |
| 52 | + <exclude name="WordPressVIPMinimum.Security.EscapingVoidReturnFunctions"/> |
| 53 | + <exclude name="WordPressVIPMinimum.Security.ProperEscapingFunction"/> |
| 54 | + |
| 55 | + <!-- Exclude select "modern PHP" sniffs, which conflict with the minimum supported PHP version of this package. --> |
| 56 | + <exclude name="Modernize.FunctionCalls.Dirname.Nested"/><!-- PHP 7.0+. --> |
| 57 | + <exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/><!-- PHP 7.0+. --> |
| 58 | + <exclude name="PSR12.Properties.ConstantVisibility"/><!-- PHP 7.1+. --> |
| 59 | + <exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/><!-- PHP 7.1+. --> |
| 60 | + <exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/><!-- PHP 7.3+. --> |
| 61 | + <exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/><!-- PHP 7.4+. --> |
| 62 | + <exclude name="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator"/><!-- PHP 7.4+. --> |
46 | 63 |
|
47 | | - <!-- The code in this package is not run in the context of a plugin. --> |
48 | | - <exclude name="WordPress.WP.AlternativeFunctions"/> |
49 | | - <exclude name="Yoast.Yoast.AlternativeFunctions"/> |
50 | 64 | </rule> |
51 | 65 |
|
52 | 66 | <!-- Enforce PSR1 compatible namespaces. --> |
53 | | - <rule ref="PSR1.Classes.ClassDeclaration"/> |
| 67 | + <rule ref="PSR1.Classes.ClassDeclaration"> |
| 68 | + <!-- YoastCS only applies this rule to test files. Overrule it to apply to all files. --> |
| 69 | + <include-pattern>*\.php</include-pattern> |
| 70 | + </rule> |
54 | 71 |
|
55 | 72 |
|
56 | 73 | <!-- |
|
59 | 76 | ############################################################################# |
60 | 77 | --> |
61 | 78 |
|
62 | | - <rule ref="Yoast.NamingConventions.NamespaceName"> |
| 79 | + <rule ref="Yoast.Files.FileName"> |
63 | 80 | <properties> |
64 | | - <property name="prefixes" type="array"> |
65 | | - <element value="Yoast\WPTestUtils"/> |
| 81 | + <property name="psr4_paths" type="array"> |
| 82 | + <element key="Yoast\WPTestUtils\Tests\\" value="tests/"/> |
66 | 83 | </property> |
67 | | - <property name="src_directory" type="array"> |
68 | | - <element value="src"/> |
| 84 | + </properties> |
| 85 | + |
| 86 | + <include-pattern>/tests/*\.php</include-pattern> |
| 87 | + </rule> |
| 88 | + |
| 89 | + <rule ref="Yoast.NamingConventions.NamespaceName"> |
| 90 | + <properties> |
| 91 | + <property name="psr4_paths" type="array"> |
| 92 | + <element key="Yoast\WPTestUtils\\" value="src/"/> |
| 93 | + <element key="Yoast\WPTestUtils\Tests\\" value="tests/"/> |
69 | 94 | </property> |
70 | 95 | </properties> |
71 | 96 | </rule> |
|
78 | 103 |
|
79 | 104 | <rule ref="WordPress.PHP.NoSilencedErrors"> |
80 | 105 | <properties> |
81 | | - <property name="custom_whitelist" type="array"> |
| 106 | + <property name="customAllowedFunctionsList" type="array"> |
82 | 107 | <element value="file_exists"/> |
83 | 108 | </property> |
84 | 109 | </properties> |
|
92 | 117 | ############################################################################# |
93 | 118 | --> |
94 | 119 |
|
95 | | - <!-- Allow filecomments in file which don't contain OO declarations. --> |
96 | | - <rule ref="Yoast.Commenting.FileComment.Unnecessary"> |
97 | | - <exclude-pattern>/src/*/bootstrap*\.php$</exclude-pattern> |
98 | | - </rule> |
99 | | - |
100 | 120 | <!-- Declaring a few WordPress native constants. --> |
101 | 121 | <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound"> |
102 | 122 | <exclude-pattern>/src/BrainMonkey/bootstrap\.php$</exclude-pattern> |
|
116 | 136 | <exclude-pattern>/src/Helpers/*\.php$</exclude-pattern> |
117 | 137 | </rule> |
118 | 138 |
|
119 | | - <!-- Ignore word count for object names in tests. --> |
| 139 | + <!-- TEST CODE --> |
| 140 | + |
| 141 | + <!-- Final classes is irrelevant for test fixtures. --> |
| 142 | + <rule ref="Universal.Classes.RequireFinalClass"> |
| 143 | + <exclude-pattern>/tests/*/Fixtures/*\.php$</exclude-pattern> |
| 144 | + </rule> |
| 145 | + |
| 146 | + <!-- Ignore word count for object names in test fixtures. --> |
120 | 147 | <rule ref="Yoast.NamingConventions.ObjectNameDepth.MaxExceeded"> |
121 | | - <exclude-pattern>/tests/*\.php$</exclude-pattern> |
| 148 | + <exclude-pattern>/tests/*/Fixtures/*\.php$</exclude-pattern> |
122 | 149 | </rule> |
123 | 150 |
|
124 | 151 | <!-- Test fixtures are not the actual tests. --> |
|
0 commit comments