-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathruleset-test.php
More file actions
337 lines (332 loc) · 11.3 KB
/
ruleset-test.php
File metadata and controls
337 lines (332 loc) · 11.3 KB
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
<?php
/**
* Ruleset test for the WordPress-VIP-Go ruleset
*
* The expected errors, warnings, and messages listed here, should match what is expected to be reported
* when ruleset-test.inc is run against PHP_CodeSniffer and the WordPress-VIP-Go standard.
*
* To run the test, see ../bin/ruleset-tests.
*
* @package VIPCS\WordPressVIPMinimum
*/
namespace WordPressVIPMinimum;
// Expected values.
$expected = [
'errors' => [
50 => 1,
53 => 1,
56 => 1,
72 => 1,
83 => 1,
165 => 1,
180 => 1,
181 => 1,
187 => 1,
188 => 1,
252 => 1,
255 => 1,
256 => 1,
258 => 1,
259 => 1,
318 => 1,
329 => 1,
334 => 1,
337 => 1,
341 => 1,
342 => 1,
346 => 1,
350 => 1,
351 => 1,
352 => 1,
353 => 1,
354 => 1,
355 => 1,
357 => 1,
358 => 1,
359 => 1,
360 => 1,
362 => 1,
363 => 1,
364 => 1,
365 => 1,
366 => 1,
367 => 1,
368 => 1,
369 => 1,
370 => 1,
371 => 1,
372 => 1,
373 => 1,
374 => 1,
375 => 1,
376 => 1,
377 => 1,
378 => 1,
379 => 1,
380 => 1,
381 => 1,
382 => 1,
383 => 1,
384 => 1,
385 => 1,
386 => 1,
387 => 1,
388 => 1,
389 => 1,
390 => 1,
409 => 1,
410 => 1,
411 => 1,
412 => 1,
413 => 1,
414 => 1,
415 => 1,
431 => 1,
441 => 1,
462 => 1,
466 => 1,
468 => 1,
472 => 1,
474 => 1,
480 => 1,
486 => 1,
494 => 1,
507 => 1,
511 => 1,
512 => 1,
513 => 1,
514 => 1,
515 => 1,
516 => 1,
517 => 1,
518 => 1,
519 => 1,
520 => 1,
521 => 1,
525 => 1,
527 => 1,
545 => 1,
560 => 1,
564 => 1,
565 => 1,
566 => 1,
567 => 1,
572 => 1,
574 => 1,
],
'warnings' => [
7 => 1,
10 => 1,
14 => 1,
17 => 1,
20 => 1,
23 => 1,
26 => 1,
29 => 1,
32 => 1,
35 => 1,
38 => 1,
41 => 1,
44 => 1,
47 => 1,
63 => 1,
66 => 1,
83 => 1,
85 => 1,
90 => 1,
94 => 1,
95 => 1,
99 => 1,
102 => 1,
103 => 1,
104 => 1,
106 => 1,
108 => 1,
109 => 1,
112 => 1,
118 => 1,
119 => 1,
123 => 1,
127 => 1,
128 => 1,
129 => 1,
130 => 1,
131 => 1,
139 => 1,
142 => 1,
146 => 1,
150 => 1,
154 => 1,
157 => 1,
161 => 1,
169 => 1,
174 => 1,
175 => 1,
176 => 1,
177 => 1,
191 => 1,
192 => 1,
195 => 1,
196 => 1,
199 => 1,
200 => 1,
201 => 1,
204 => 1,
205 => 1,
206 => 1,
207 => 1,
208 => 1,
212 => 1,
221 => 1,
223 => 1,
225 => 1,
228 => 1,
229 => 1,
230 => 1,
235 => 1,
236 => 1,
237 => 1,
245 => 1,
246 => 1,
247 => 1,
265 => 1,
269 => 1,
273 => 1,
322 => 1,
332 => 1,
392 => 1,
394 => 1,
395 => 1,
398 => 1,
399 => 1,
400 => 1,
401 => 1,
402 => 1,
403 => 1,
404 => 1,
405 => 1,
406 => 1,
407 => 1,
408 => 1,
416 => 1,
417 => 1,
418 => 1,
419 => 1,
421 => 1,
423 => 1,
424 => 1,
425 => 1,
428 => 1,
448 => 1,
453 => 1,
454 => 1,
455 => 1,
456 => 1,
502 => 1,
503 => 1,
530 => 1,
533 => 1,
540 => 1,
550 => 1,
556 => 1,
579 => 1,
589 => 1,
],
'messages' => [
7 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as file_put_contents(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
10 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as flock(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
14 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as fputcsv(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
17 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as fputs(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
20 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as fwrite(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
23 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as ftruncate(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
26 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as is_writable(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
29 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as is_writeable(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
32 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as link(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
35 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as rename(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
38 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as symlink(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
41 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as tempnam(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
44 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as touch(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
47 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as unlink(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
50 => [
'Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.',
],
53 => [
'Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.',
],
56 => [
'Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.',
],
63 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as fopen(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
66 => [
'file_get_contents() is uncached. If the function is being used to fetch a remote file (e.g. a URL starting with https://), please use wpcom_vip_file_get_contents() to ensure the results are cached. For more details, please see: https://docs.wpvip.com/technical-references/code-quality-and-best-practices/retrieving-remote-data/',
],
90 => [
'Having more than 100 posts returned per page may lead to severe performance problems.',
],
94 => [
'Having more than 100 posts returned per page may lead to severe performance problems.',
],
95 => [
'Having more than 100 posts returned per page may lead to severe performance problems.',
],
123 => [
'attachment_url_to_postid() is uncached, please use wpcom_vip_attachment_url_to_postid() instead.',
],
139 => [
'get_children() is uncached and performs a no limit query. Please use get_posts or WP_Query instead. Please see: https://docs.wpvip.com/technical-references/caching/uncached-functions/',
],
150 => [
'url_to_postid() is uncached, please use wpcom_vip_url_to_postid() instead.',
],
191 => [
'Scripts should be registered/enqueued via `wp_enqueue_script`. This can improve the site\'s performance due to script concatenation.',
],
192 => [
'Scripts should be registered/enqueued via `wp_enqueue_script`. This can improve the site\'s performance due to script concatenation.',
],
195 => [
'Stylesheets should be registered/enqueued via `wp_enqueue_style`. This can improve the site\'s performance due to styles concatenation.',
],
196 => [
'Stylesheets should be registered/enqueued via `wp_enqueue_style`. This can improve the site\'s performance due to styles concatenation.',
],
],
];
require __DIR__ . '/../tests/RulesetTest.php';
// Run the tests!
$test = new RulesetTest( 'WordPress-VIP-Go', $expected );
if ( $test->passes() ) {
printf( 'All WordPress-VIP-Go tests passed!' . PHP_EOL );
exit( 0 );
}
exit( 1 );