forked from ClassicPress/ClassicPress
-
Notifications
You must be signed in to change notification settings - Fork 1
/
phpcs.xml.dist
348 lines (307 loc) · 14.7 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<?xml version="1.0"?>
<ruleset name="ClassicPress Coding Standards">
<description>Apply WordPress Coding Standards to all Core files</description>
<!-- Only scan PHP files. -->
<arg name="extensions" value="php"/>
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache"/>
<!-- Set the memory limit to 256M.
For most standard PHP configurations, this means the memory limit will temporarily be raised.
Ref: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#specifying-phpini-settings
-->
<ini name="memory_limit" value="256M"/>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Check up to 20 files simultaneously. -->
<arg name="parallel" value="20"/>
<!-- Show sniff codes in all reports. -->
<arg value="ps"/>
<file>./src/</file>
<rule ref="WordPress-Core"/>
<rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
<!-- These rules are being set as warnings instead of errors, so we can error check the entire codebase. -->
<rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
<type>warning</type>
</rule>
<rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared">
<type>warning</type>
</rule>
<rule ref="WordPress.DB.PreparedSQL.NotPrepared">
<type>warning</type>
</rule>
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<type>warning</type>
</rule>
<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="customPropertiesWhitelist" type="array">
<!-- From database structure queries. -->
<element value="Collation"/>
<element value="Column_name"/>
<element value="Default"/>
<element value="Extra"/>
<element value="Field"/>
<element value="Index_type"/>
<element value="Key"/>
<element value="Key_name"/>
<element value="Msg_text"/>
<element value="Non_unique"/>
<element value="Null"/>
<element value="Sub_part"/>
<element value="Type"/>
<!-- From plugin/theme data. -->
<element value="authorAndUri"/>
<element value="Name"/>
<element value="Version"/>
<!-- From the result of wp_xmlrpc_server::wp_getPageList(). -->
<element value="dateCreated"/>
<!-- From DOMDocument. -->
<element value="childNodes"/>
<element value="formatOutput"/>
<element value="nodeName"/>
<element value="nodeType"/>
<element value="parentNode"/>
<element value="preserveWhiteSpace"/>
<element value="textContent"/>
<!-- From PHPMailer. -->
<element value="AltBody"/>
<element value="Body"/>
<element value="CharSet"/>
<element value="ContentType"/>
<element value="Encoding"/>
<element value="Hostname"/>
<element value="mailHeader"/>
<element value="MIMEBody"/>
<element value="MIMEHeader"/>
<element value="Sender"/>
<element value="Subject"/>
<!-- From PHPUnit_Util_Getopt. -->
<element value="longOptions"/>
<!-- From POP3. -->
<element value="ERROR"/>
<!-- From ZipArchive. -->
<element value="numFiles"/>
</property>
</properties>
</rule>
<!-- Exclude the build folder in the current directory, as Travis puts the checkout in a build directory. -->
<exclude-pattern type="relative">^build/*</exclude-pattern>
<!-- Directories and third party library exclusions. -->
<exclude-pattern>/node_modules/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/src/wp-admin/includes/class-ftp*</exclude-pattern>
<exclude-pattern>/src/wp-admin/includes/class-pclzip\.php</exclude-pattern>
<exclude-pattern>/src/wp-admin/includes/deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-admin/includes/ms-deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/atomlib\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-IXR\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-json\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-phpass\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-pop3\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-requests\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-simplepie\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-block-parser\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/ms-deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/pluggable-deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/rss\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/assets/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/blocks/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/ID3/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/IXR/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/js/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/PHPMailer/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/random_compat/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/Requests/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/SimplePie/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/sodium_compat/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/Text/*</exclude-pattern>
<exclude-pattern>/tests/phpunit/includes/phpunit7/MockObject/*</exclude-pattern>
<exclude-pattern>/tests/phpunit/includes/speed-trap-listener\.php</exclude-pattern>
<!-- Test data and fixtures. -->
<exclude-pattern>/tests/phpunit/build*</exclude-pattern>
<exclude-pattern>/tests/phpunit/data/*</exclude-pattern>
<exclude-pattern>/tools/*</exclude-pattern>
<!-- Drop-in plugins. -->
<exclude-pattern>/src/wp-content/advanced-cache\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/blog-deleted\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/blog-inactive\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/blog-suspended\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/db-error\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/db\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/fatal-error-handler\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/install\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/maintenance\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/object-cache\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/php-error\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/sunrise\.php</exclude-pattern>
<!-- Must-Use plugins. -->
<exclude-pattern>/src/wp-content/mu-plugins/*</exclude-pattern>
<!-- Plugins. -->
<exclude-pattern>/src/wp-content/plugins/*</exclude-pattern>
<!-- Themes except the twenty* themes. -->
<exclude-pattern>/src/wp-content/themes/(?!twenty)*</exclude-pattern>
<!-- Whitelist the WP DB Class and related tests for usage of direct database access functions. -->
<rule ref="WordPress.DB.RestrictedFunctions">
<exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/db/charset\.php</exclude-pattern>
</rule>
<!-- Whitelist the WP DB related tests for issues with prepared SQL placeholders
(as the handling of those are being tested). -->
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare">
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder">
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnescapedLiteral">
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.PreparedSQL.NotPrepared">
<exclude-pattern>/tests/phpunit/tests/admin/includesSchema\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/multisite/site\.php</exclude-pattern>
</rule>
<!-- Whitelist the I18n functions file from issues identified by the I18n sniff
(such as calling the low-level translate() function). -->
<rule ref="WordPress.WP.I18n">
<exclude-pattern>/src/wp-includes/l10n\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/l10n\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/l10n/loadTextdomainJustInTime\.php</exclude-pattern>
</rule>
<!-- Translator comments aren't needed in unit tests. -->
<rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
<exclude-pattern>/tests/*</exclude-pattern>
</rule>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing">
<exclude-pattern>/wp-config\.php</exclude-pattern>
<exclude-pattern>/wp-config-sample\.php</exclude-pattern>
<exclude-pattern>/wp-tests-config\.php</exclude-pattern>
<exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern>
</rule>
<!-- Exclude checking of line endings when reporting errors, but fix them when running phpcbf.
Git and SVN manage these pretty well cross-platform as "native".
Whitelist configuration files. -->
<rule ref="Generic.Files.LineEndings">
<exclude-pattern>/wp-config\.php</exclude-pattern>
<exclude-pattern>/wp-config-sample\.php</exclude-pattern>
<exclude phpcs-only="true" name="Generic.Files.LineEndings"/>
</rule>
<!-- WPCS1620: template.php isn't a template tag file. -->
<rule ref="WordPress.Files.FileName.InvalidTemplateTagFileName">
<exclude-pattern>/src/wp-includes/template\.php</exclude-pattern>
</rule>
<!-- WPCS1621: These files are expected to use _ instead of -. -->
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>/src/_index\.php</exclude-pattern>
<exclude-pattern>/src/wp-admin/_index\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentythirteen/taxonomy-post_format\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentyfourteen/taxonomy-post_format\.php</exclude-pattern>
</rule>
<!-- Whitelist test classes for select sniffs. -->
<rule ref="WordPress.Files.FileName">
<properties>
<property name="custom_test_class_whitelist" type="array">
<!-- Test case parent classes. -->
<element value="WP_UnitTestCase"/>
<element value="WP_Ajax_UnitTestCase"/>
<element value="WP_Canonical_UnitTestCase"/>
<element value="WP_Test_REST_TestCase"/>
<element value="WP_Test_REST_Controller_Testcase"/>
<element value="WP_Test_REST_Post_Type_Controller_Testcase"/>
<element value="WP_XMLRPC_UnitTestCase"/>
<element value="WP_Filesystem_UnitTestCase"/>
<element value="WP_Image_UnitTestCase"/>
<element value="WP_HTTP_UnitTestCase"/>
<element value="WP_Tests_Image_Resize_UnitTestCase"/>
<element value="WP_Import_UnitTestCase"/>
<element value="Tests_Query_Conditionals"/>
<element value="WP_Test_XML_TestCase"/>
<!-- Mock classes. -->
<element value="Spy_REST_Server"/>
<element value="WP_REST_Test_Controller"/>
<element value="WP_Image_Editor_Mock"/>
<element value="WP_Filesystem_MockFS"/>
<element value="MockPHPMailer"/>
<element value="MockAction"/>
<element value="WP_Object_Cache"/>
<!-- PHPUnit helpers. -->
<element value="TracTickets"/>
<element value="WP_PHPUnit_Util_Getopt"/>
<element value="PHPUnit_Util_Test"/>
<element value="WPProfiler"/>
<element value="SpeedTrapListener"/>
<element value="PHPUnit_Framework_Exception"/>
</property>
</properties>
</rule>
<rule ref="WordPress.PHP.NoSilencedErrors">
<properties>
<property name="custom_whitelist" type="array">
<element value="ssh2_connect"/>
<element value="ssh2_auth_password"/>
<element value="ssh2_auth_pubkey_file"/>
<element value="ftp_ssl_connect"/>
<element value="ftp_connect"/>
<element value="ftp_get_option"/>
<element value="ftp_set_option"/>
<element value="disk_free_space"/>
<element value="getimagesize"/>
<element value="iptcparse"/>
<element value="exif_read_data"/>
<element value="gzinflate"/>
<element value="gzuncompress"/>
<element value="gzdecode"/>
</property>
</properties>
</rule>
<!-- Enforce no parenthesis for language constructs, and only one space immediately after.
Including this rule is temporary until it is moved from the WordPress-Extra ruleset to
the WordPress-Core ruleset upstream.
-->
<rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
<type>warning</type>
</rule>
<rule ref="PEAR.Files.IncludingFile.UseRequire">
<type>warning</type>
</rule>
<rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
<type>warning</type>
</rule>
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Assignments in while conditions are a valid method of looping over iterables. -->
<rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
<exclude-pattern>*</exclude-pattern>
</rule>
<!-- Exclude the unit tests from select sniffs. -->
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
</rule>
<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
<exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
</rule>
<!-- Exclude some old classes that can't be renamed, as it would break back compat. -->
<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
<exclude-pattern>/src/wp-admin/includes/class-wp-filesystem-ftpsockets\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-oembed\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-oembed-controller\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-xmlrpc-server\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-text-diff-renderer-inline\.php</exclude-pattern>
</rule>
<rule ref="PEAR.NamingConventions.ValidClassName.StartWithCapital">
<exclude-pattern>/src/wp-admin/includes/class-wp-list-table-compat\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-editor\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-xmlrpc-server\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-dependency\.php</exclude-pattern>
</rule>
<!-- Exclude some incorrectly named files that won't be renamed. -->
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>/src/wp-admin/includes/class-wp-list-table-compat\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-dependency\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-editor\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentyeleven/inc/widgets\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentyfourteen/inc/widgets\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentyfourteen/inc/featured-content\.php</exclude-pattern>
</rule>
</ruleset>