forked from ryan-was/wpseo-news
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.phpcs.xml.dist
187 lines (153 loc) · 6.58 KB
/
.phpcs.xml.dist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="Yoast SEO: News"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Yoast SEO: News rules for PHP_CodeSniffer</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->
<file>.</file>
<!-- Exclude YoastSEO when installed using the Composer installers. -->
<exclude-pattern>/wp-content/plugins/</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 simultaneously. -->
<arg name="parallel" value="8"/>
<!-- Cache the results between runs. -->
<arg name="cache" value="./.cache/phpcs.cache"/>
<!--
#############################################################################
USE THE YoastCS RULESET
#############################################################################
-->
<rule ref="Yoast">
<properties>
<!-- Set the custom test class whitelist for all sniffs which use it in one go.
Ref: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#custom-unit-test-classes
-->
<property name="custom_test_class_whitelist" type="array">
<element value="WPSEO_News_UnitTestCase"/>
</property>
<!-- Provide the plugin specific prefixes for all naming related sniffs. -->
<property name="prefixes" type="array">
<element value="Yoast\WP\News"/>
<element value="yoast_news"/>
</property>
</properties>
</rule>
<!--
#############################################################################
SNIFF SPECIFIC CONFIGURATION
#############################################################################
-->
<rule ref="Yoast.NamingConventions.NamespaceName">
<properties>
<!-- Indicate which directories should be treated as project root directories for
path-to-namespace translations. -->
<property name="src_directory" type="array">
<element value="config"/>
</property>
</properties>
</rule>
<!-- Verify that all gettext calls use the correct text domain. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="wordpress-seo-news"/>
</property>
</properties>
</rule>
<rule ref="Yoast.Files.FileName">
<properties>
<!-- Don't trigger on the main file as renaming it would deactivate the plugin.
Also leave the main WPSEO_News class and associated test files alone as
after removing the prefix, there would be nothing left. -->
<property name="excluded_files_strict_check" type="array">
<element value="wpseo-news.php"/>
<element value="classes/wpseo-news.php"/>
<element value="integration-tests/wpseo-news-test.php"/>
<element value="integration-tests/doubles/wpseo-news-double.php"/>
</property>
<!-- Remove the following prefixes from the names of object structures. -->
<property name="oo_prefixes" type="array">
<element value="wpseo_news"/>
<element value="yoast_wpseo_news"/>
<element value="yoast_news"/>
</property>
</properties>
</rule>
<rule ref="Yoast.Files.TestDoubles">
<properties>
<property name="doubles_path" type="array">
<element value="/tests/doubles"/>
<element value="/integration-tests/doubles"/>
</property>
</properties>
</rule>
<!--
#############################################################################
SELECTIVE EXCLUSIONS
Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
#############################################################################
-->
<!-- Composer scripts are not WordPress and have console output. -->
<rule ref="WordPress.Security.EscapeOutput.OutputNotEscaped">
<exclude-pattern>/config/composer/*</exclude-pattern>
</rule>
<!-- Composer scripts are allowed to call system functions. -->
<rule ref="WordPress.PHP.DiscouragedPHPFunctions">
<exclude-pattern>/config/composer/*</exclude-pattern>
</rule>
<!-- Allow for the double/mock classes to override methods just to change the visibility. -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod.Found">
<exclude-pattern>/tests/doubles/*-double\.php$</exclude-pattern>
<exclude-pattern>/integration-tests/doubles/*-double\.php$</exclude-pattern>
</rule>
<!-- Allow for select unit test files to use less secure code. -->
<rule ref="WordPress.Security">
<exclude-pattern>/integration-tests/bootstrap\.php$</exclude-pattern>
<exclude-pattern>/integration-tests/framework/unittestcase\.php$</exclude-pattern>
</rule>
<!-- For documentation of the double/mock classes, please refer to the _real_ classes. -->
<rule ref="Generic.Commenting.DocComment.MissingShort">
<exclude-pattern>/tests/doubles/*-double\.php$</exclude-pattern>
<exclude-pattern>/integration-tests/doubles/*-double\.php$</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag">
<exclude-pattern>/tests/doubles/*-double\.php$</exclude-pattern>
<exclude-pattern>/integration-tests/doubles/*-double\.php$</exclude-pattern>
</rule>
<!-- Valid usage: For testing purposes, some non-prefixed globals are being created. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<exclude-pattern>/tests/bootstrap\.php$</exclude-pattern>
<exclude-pattern>/integration-tests/bootstrap\.php$</exclude-pattern>
</rule>
<!--
#############################################################################
TEMPORARY ADJUSTMENTS
Adjustments which should be removed once the associated issue has been resolved.
#############################################################################
-->
<!-- Until all prefixes are fixed, some exceptions are allowed to the PrefixAllGlobals sniff. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Provide the prefixes to look for. -->
<property name="prefixes" type="array" extend="true">
<element value="wpseo_news"/>
<element value="yoast_wpseo_news"/>
</property>
</properties>
</rule>
<!-- Usage of non-cached direct database query. Should be reviewed.
Ticket: https://github.com/Yoast/wpseo-news/issues/585 -->
<rule ref="WordPress.DB.DirectDatabaseQuery">
<exclude-pattern>/classes/sitemap\.php$</exclude-pattern>
</rule>
</ruleset>