Repository navigation
Expand file tree
/
Copy pathphpcs-wordpress.xml
More file actions
315 lines (283 loc) · 13.5 KB
/
Copy pathphpcs-wordpress.xml
File metadata and controls
315 lines (283 loc) · 13.5 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
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="WordPress Plugin Coding Standards">
<description>WordPress coding standards</description>
<!-- Files to check -->
<file>.</file>
<!-- Exclude patterns -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/.private/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/.git/*</exclude-pattern>
<exclude-pattern>*/.github/*</exclude-pattern>
<exclude-pattern>*/build/*</exclude-pattern>
<exclude-pattern>*/dist/*</exclude-pattern>
<exclude-pattern>*/stubs/*</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>
<!-- Use WordPress-Extra coding standards (includes WordPress-Core) -->
<rule ref="WordPress-Extra">
<!-- Allow short array syntax [] instead of array() -->
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Allow longer lines for readability -->
<exclude name="Generic.Files.LineLength"/>
</rule>
<!-- WordPress VIP Go coding standards. -->
<rule ref="WordPress-VIP-Go">
<!-- VIPCS 3 registers JS sniffs that PHPCS 3.13 marks deprecated. -->
<exclude name="WordPressVIPMinimum.JS.DangerouslySetInnerHTML"/>
<exclude name="WordPressVIPMinimum.JS.HTMLExecutingFunctions"/>
<exclude name="WordPressVIPMinimum.JS.InnerHTML"/>
<exclude name="WordPressVIPMinimum.JS.StringConcat"/>
<exclude name="WordPressVIPMinimum.JS.StrippingTags"/>
<exclude name="WordPressVIPMinimum.JS.Window"/>
<!--
WordPress.PHP.NoSilencedErrors (from WordPress-Extra) already checks the @ operator, and
allows it only on functions whose failure the calling code handles. This sniff forbids it
on every function, including those.
-->
<exclude name="Generic.PHP.NoSilencedErrors"/>
</rule>
<!--
WordPress-VIP-Go switches the checks below off, because they do not matter on the VIP
platform. This plugin runs on other hosts as well, so each one gets its default severity back.
-->
<rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound">
<severity>5</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<severity>5</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine">
<severity>5</severity>
</rule>
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable">
<severity>5</severity>
</rule>
<rule ref="WordPress.DB.SlowDBQuery.slow_db_query_meta_key">
<severity>5</severity>
</rule>
<rule ref="WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting">
<severity>5</severity>
</rule>
<rule ref="WordPress.Security.EscapeOutput.ExceptionNotEscaped">
<severity>5</severity>
</rule>
<rule ref="WordPress.Security.ValidatedSanitizedInput.MissingUnslash">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_chgrp">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_chmod">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_chown">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_fclose">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_fputs">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_fwrite">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_is_writable">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_is_writeable">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_mkdir">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_readfile">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_rmdir">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_operations_touch">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.rename_rename">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.strip_tags_strip_tags">
<severity>5</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.unlink_unlink">
<severity>5</severity>
</rule>
<!-- WordPress documentation standards -->
<rule ref="WordPress-Docs"/>
<!-- COMMENTED OUT: These rules enforce spaces instead of tabs, which conflicts with WordPress standards -->
<!-- WordPress standards actually require TABS for indentation, not spaces -->
<!--
<rule ref="Generic.WhiteSpace.DisallowTabIndent">
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="false"/>
</properties>
</rule>
-->
<!-- COMMENTED OUT: Disallow Rule Flagging Space Indents - not needed with tab indentation -->
<!--
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent">
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
</rule>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed">
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"/>
</rule>
-->
<!-- COMMENTED OUT: Disallow inline tabs - WordPress allows tabs for indentation -->
<!--
<rule ref="Universal.WhiteSpace.DisallowInlineTabs">
</rule>
-->
<!-- Additional WordPress-specific spacing rules -->
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing"/>
<rule ref="WordPress.WhiteSpace.OperatorSpacing"/>
<!-- Enforce WordPress indentation standards -->
<rule ref="WordPress.Arrays.ArrayIndentation"/>
<rule ref="WordPress.Arrays.MultipleStatementAlignment"/>
<!-- WordPress function call formatting -->
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="allowMultipleArguments" value="false"/>
</properties>
</rule>
<!-- WordPress class and method formatting -->
<rule ref="PSR2.Classes.ClassDeclaration"/>
<rule ref="PSR2.Methods.MethodDeclaration"/>
<!-- File formatting -->
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\n"/>
</properties>
</rule>
<!-- WordPress security and best practices -->
<rule ref="WordPress.Security"/>
<!-- WordPress internationalization configuration -->
<rule ref="WordPress.WP.I18n">
<properties>
<!-- Set the text domain for internationalization -->
<property name="text_domain" type="array">
<element value="enginescript-site-exporter"/>
</property>
</properties>
</rule>
<!-- Every function, class, constant, global variable and hook that the plugin declares starts with its prefix. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="esse"/>
</property>
</properties>
</rule>
<!-- WordPress naming conventions (snake_case) -->
<rule ref="WordPress.NamingConventions.ValidFunctionName"/>
<rule ref="WordPress.NamingConventions.ValidVariableName"/>
<rule ref="WordPress.NamingConventions.ValidHookName"/>
<!-- WordPress PHP compatibility -->
<rule ref="PHPCompatibilityWP">
<include-pattern>*\.php$</include-pattern>
</rule>
<!-- PHPCSExtra standards for additional code quality checks -->
<rule ref="Modernize"/>
<!-- Allow PHP short array syntax. -->
<rule ref="Universal.Arrays.DisallowShortArraySyntax">
<severity>0</severity>
</rule>
<rule ref="NormalizedArrays">
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
</rule>
<!-- Every EngineScript plugin writes arrays one way: the short syntax. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!--
Checks that Codacy's "WordPress" coding standard also runs, so composer and CI report them first.
Each passes on the plugin's code and fits the WordPress style.
-->
<!-- Leftover TODO comments, executable PHP files, $_REQUEST (it mixes query, form, and cookie
values), and php_sapi_name() where the PHP_SAPI constant does. -->
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.Files.ExecutableFile"/>
<rule ref="Generic.PHP.DisallowRequestSuperglobal"/>
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Layout that the WordPress standards leave open: control structure signatures, multi-line
assignments and chained calls, default values in function signatures, anonymous classes,
class closing braces, boolean operators at the start of continued lines, declare
statements, use statements, the opening tag, member variable spacing, and no closing tag
at the end of a file. -->
<rule ref="PEAR.ControlStructures.ControlSignature"/>
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
<rule ref="PEAR.Functions.ValidDefaultValue"/>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<rule ref="PSR12.Classes.AnonClassDeclaration"/>
<rule ref="PSR12.Classes.ClosingBrace"/>
<rule ref="PSR12.ControlStructures.BooleanOperatorPlacement"/>
<rule ref="PSR12.Files.DeclareStatement"/>
<rule ref="PSR12.Files.ImportStatement"/>
<rule ref="PSR12.Files.OpenTag"/>
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
<rule ref="Zend.Files.ClosingTag"/>
<!-- Slevomat: closures that could be static, unused parameters, variables, and imports, sorted
imports, loose == and != comparisons, a variable assigned only to be returned, and
unpacking that stops PHP from optimizing a call. -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedParameter"/>
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="psr12Compatible" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!--
Codacy's "WordPress" standard also turns on these checks, which this file leaves out because
they contradict the WordPress coding standards or do not apply to WordPress code:
- Generic.ControlStructures.DisallowYodaConditions: WordPress requires Yoda conditions.
- Generic.WhiteSpace.DisallowTabIndent: WordPress indents with tabs.
- PEAR.Classes.ClassDeclaration, PEAR.WhiteSpace.ScopeClosingBrace, and
PSR12.Classes.OpeningBraceSpace: brace placement; WordPress-Core sets its own.
- PEAR.Commenting.FunctionComment: WordPress-Docs has its own function comment rules.
- PEAR.ControlStructures.MultiLineCondition, PEAR.Functions.FunctionDeclaration,
PSR12.ControlStructures.ControlStructureSpacing, Squiz.WhiteSpace.ControlStructureSpacing,
and Squiz.Arrays.ArrayBracketSpacing: WordPress puts spaces inside parentheses and brackets.
- Squiz.Arrays.ArrayDeclaration: WordPress.Arrays sets the array layout.
- Squiz.Commenting.LongConditionClosingComment and Squiz.Commenting.PostStatementComment:
not part of the WordPress style.
- Squiz.ControlStructures.ElseIfDeclaration: asks for "else if"; WordPress uses elseif.
- Squiz.Formatting.OperatorBracket, Squiz.Operators.ComparisonOperatorUsage, and
Squiz.PHP.DisallowInlineIf: not part of the WordPress style, which allows ternaries.
- Squiz.WhiteSpace.FunctionClosingBraceSpace and Squiz.WhiteSpace.FunctionSpacing: blank
line rules WordPress does not follow.
- Squiz.WhiteSpace.OperatorSpacing: WordPress.WhiteSpace.OperatorSpacing applies instead.
- Drupal.Semantics.PregSecurity and Drupal.Semantics.RemoteAddress: Drupal rules.
-->
<!-- Set minimum WordPress version for deprecated function checks -->
<config name="minimum_wp_version" value="7.0"/>
<config name="testVersion" value="8.3-"/>
<!-- Report every message, including those that a standard rates below the default severity of 5. -->
<arg name="severity" value="1"/>
<!-- Show progress -->
<arg value="p"/>
<!-- Show sniff codes in all reports -->
<arg value="s"/>
<!-- Use colors in output -->
<arg name="colors"/>
</ruleset>