-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy path.phpcs.xml.dist
More file actions
282 lines (264 loc) · 12.1 KB
/
.phpcs.xml.dist
File metadata and controls
282 lines (264 loc) · 12.1 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
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="edit-flow" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Custom ruleset for Edit Flow plugin.</description>
<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!-- What to scan -->
<file>.</file>
<!-- Ignoring Files and Folders:
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
<exclude-pattern>/node_modules/</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/build/</exclude-pattern>
<!-- Third-party library for screen options, do not modify -->
<exclude-pattern>common/php/screen-options\.php</exclude-pattern>
<!-- How to scan -->
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- Show sniff and progress -->
<arg value="sp"/>
<!-- Strip the file paths down to the relevant bit -->
<arg name="basepath" value="./"/>
<!-- Show results with colors -->
<arg name="colors"/>
<!-- Limit to PHP files -->
<arg name="extensions" value="php"/>
<!-- Enables parallel processing when available for faster results. -->
<arg name="parallel" value="8"/>
<!-- Rules: Check PHP version compatibility - see
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>
<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="7.4-"/>
<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<!-- WordPress-Extra includes WordPress-Core -->
<rule ref="WordPress-Extra"/>
<rule ref="WordPress-Docs"/>
<!-- For help in understanding these custom sniff properties:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<config name="minimum_supported_wp_version" value="6.4"/>
<!-- Rules: WordPress VIP - see
https://github.com/Automattic/VIP-Coding-Standards -->
<rule ref="WordPress-VIP-Go">
<!-- These disallow anonymous functions as action callbacks -->
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
<!-- Allow short array syntax -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />
<!-- Do not enforce 'class-' prefix -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<!-- Allow short ternaries -->
<exclude name="WordPress.PHP.DisallowShortTernary.Found" />
<!-- Generates too many false positives -->
<exclude name="WordPress.WP.CapitalPDangit.Misspelled" />
<!-- We use trigger_error extensively -->
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_trigger_error" />
<!-- Standard WP_CLI_Command is fine for non-VIP-specific plugins -->
<exclude name="WordPressVIPMinimum.Classes.RestrictedExtendClasses.wp_cli" />
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Minimum prefix length is 4 characters - "ef_" is too short -->
<!-- This matches: edit_flow_function(), EditFlow, Edit_Flow_Class -->
<property name="prefixes" type="array">
<element value="edit_flow"/>
<element value="EditFlow"/>
<element value="EDIT_FLOW"/>
</property>
</properties>
</rule>
<!-- Legacy "EF_" prefix for classes is established and cannot be changed -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
<severity>0</severity>
</rule>
<!-- Legacy "ef_" prefix for hooks is established and cannot be changed -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound">
<severity>0</severity>
</rule>
<!-- Legacy "ef_" prefix for functions is established and cannot be changed -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound">
<severity>0</severity>
</rule>
<!-- Legacy "_ef_" prefix for internal variables is established and cannot be changed -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound">
<severity>0</severity>
</rule>
<!-- Legacy "EF_" prefix for constants is established and cannot be changed -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
<severity>0</severity>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="edit-flow"/>
</property>
</properties>
</rule>
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
<properties>
<property name="blank_line_check" value="true"/>
</properties>
</rule>
<!-- Test-specific exclusions -->
<!-- Tests use Automattic\EditFlow\Tests namespace, not plugin prefix -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use camelCase for PHPUnit compatibility and test fixtures -->
<rule ref="WordPress.NamingConventions.ValidVariableName">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Test class/method documentation is not required -->
<rule ref="Squiz.Commenting.ClassComment.Missing">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.Missing">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.VariableComment">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<rule ref="Generic.Commenting.DocComment.MissingShort">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests may need to override global variables for setup -->
<rule ref="WordPress.WP.GlobalVariablesOverride.Prohibited">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use runtime configuration functions -->
<rule ref="WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<rule ref="WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_ini_set">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests don't need security escaping -->
<rule ref="WordPress.Security.EscapeOutput">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests may use underscore-prefixed properties/methods (PHPUnit convention) -->
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests may have unused function parameters (required by PHPUnit signatures) -->
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use flush_rewrite_rules for setup -->
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests may use wp_mail for testing email functionality -->
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.wp_mail_wp_mail">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests may use constant() dynamically -->
<rule ref="WordPressVIPMinimum.Constants.ConstantString.NotCheckingConstantName">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests don't require i18n text domain -->
<rule ref="WordPress.WP.I18n.MissingArgDomain">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Inline comment formatting is relaxed in tests -->
<rule ref="Squiz.Commenting.InlineComment.InvalidEndChar">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests may need visibility on methods but not strict enforcement -->
<rule ref="Squiz.Scope.MethodScope.Missing">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use file_get_contents for fixtures -->
<rule ref="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can output directly -->
<rule ref="WordPress.Security.EscapeOutput.OutputNotEscaped">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests may use switch_to_blog for multisite testing -->
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.switch_to_blog_switch_to_blog">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests don't need nonce verification -->
<rule ref="WordPress.Security.NonceVerification">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests don't need input validation/sanitisation -->
<rule ref="WordPress.Security.ValidatedSanitizedInput">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use ini_set for configuration -->
<rule ref="WordPress.PHP.IniSet">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use direct database queries -->
<rule ref="WordPress.DB.DirectDatabaseQuery">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use custom capabilities -->
<rule ref="WordPress.WP.Capabilities.Unknown">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use file_get_contents for remote data in testing -->
<rule ref="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsRemoteFile">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests don't require param comments -->
<rule ref="Squiz.Commenting.FunctionComment.MissingParamComment">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests don't require @throws tag -->
<rule ref="Squiz.Commenting.FunctionCommentThrowTag.Missing">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Tests can use putenv for configuration -->
<rule ref="WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_putenv">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Allow commented out code in tests (often used for reference/debugging) -->
<rule ref="Squiz.PHP.CommentedOutCode.Found">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Test files use PascalCase naming (PHPUnit convention) -->
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
<!-- Legacy main file uses underscore (WordPress.org plugin slug requirement) -->
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>edit_flow\.php</exclude-pattern>
</rule>
<!-- Third-party screen options library uses class + helper function pattern -->
<rule ref="Universal.Files.SeparateFunctionsFromOO.Mixed">
<exclude-pattern>common/php/screen-options\.php</exclude-pattern>
</rule>
<!-- Main plugin file uses class + global convenience function pattern -->
<rule ref="Universal.Files.SeparateFunctionsFromOO.Mixed">
<exclude-pattern>edit_flow\.php</exclude-pattern>
</rule>
<!-- Third-party screen options library uses non-standard class naming -->
<rule ref="PEAR.NamingConventions.ValidClassName">
<exclude-pattern>common/php/screen-options\.php</exclude-pattern>
</rule>
<!-- Legacy edit_flow class name (backwards compatibility requirement) -->
<rule ref="PEAR.NamingConventions.ValidClassName">
<exclude-pattern>edit_flow\.php</exclude-pattern>
</rule>
<!-- Editorial modules intentionally use date() with local timezone for scheduling/metadata display -->
<rule ref="WordPress.DateTime.RestrictedFunctions.date_date">
<exclude-pattern>modules/calendar/calendar\.php</exclude-pattern>
<exclude-pattern>modules/editorial-metadata/editorial-metadata\.php</exclude-pattern>
<exclude-pattern>modules/notifications/notifications\.php</exclude-pattern>
<exclude-pattern>modules/story-budget/story-budget\.php</exclude-pattern>
</rule>
<!-- Tests can use date() for test data setup -->
<rule ref="WordPress.DateTime.RestrictedFunctions.date_date">
<exclude-pattern>/tests/</exclude-pattern>
</rule>
</ruleset>