-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpcs.xml.dist
More file actions
276 lines (229 loc) · 8.91 KB
/
phpcs.xml.dist
File metadata and controls
276 lines (229 loc) · 8.91 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
<?xml version="1.0"?>
<ruleset name="PressPrimer Quiz">
<description>PHPCS ruleset for PressPrimer Quiz plugin.</description>
<!-- What to scan -->
<file>.</file>
<!-- Exclude paths -->
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/node_modules/*</exclude-pattern>
<exclude-pattern>/assets/js/*.min.js</exclude-pattern>
<exclude-pattern>/assets/css/*.min.css</exclude-pattern>
<exclude-pattern>/build/*</exclude-pattern>
<exclude-pattern>/src/*</exclude-pattern>
<exclude-pattern>/tests/*</exclude-pattern>
<exclude-pattern>composer-setup.php</exclude-pattern>
<exclude-pattern>*.phar</exclude-pattern>
<!-- How to scan -->
<arg value="sp"/> <!-- Show sniff and progress -->
<arg name="basepath" value="."/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="8"/>
<!-- Rules: WordPress Coding Standards -->
<rule ref="WordPress">
<!--
Exclude rules that don't apply to plugins with custom database tables.
These are intentional patterns, not security issues.
-->
<!--
We use custom database tables with $wpdb->prefix, which requires
interpolating table names into SQL strings. This is safe because:
1. Table names are constructed from $wpdb->prefix (trusted)
2. All user input is still passed through prepare() placeholders
-->
<exclude name="WordPress.DB.PreparedSQL.InterpolatedNotPrepared"/>
<exclude name="WordPress.DB.PreparedSQL.NotPrepared"/>
<!--
Direct database queries are necessary for custom tables that don't
use WordPress post/meta APIs. We handle caching at the application level.
-->
<exclude name="WordPress.DB.DirectDatabaseQuery.DirectQuery"/>
<exclude name="WordPress.DB.DirectDatabaseQuery.NoCaching"/>
<!--
Short array syntax [] is allowed in modern PHP (7.4+) and is more readable.
WordPress core now uses this syntax as well.
-->
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found"/>
<!--
We use Yoda conditions where appropriate but don't enforce them everywhere.
-->
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
<!--
Plugin uses custom capabilities (ppq_*) which are registered at runtime.
These are not WordPress core capabilities.
-->
<exclude name="WordPress.WP.Capabilities.Unknown"/>
<!--
WordPress-style class file naming (class-*.php) is used, not PSR-4.
This is standard for WordPress plugins.
-->
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
<!--
Comment formatting - not enforcing period at end of inline comments.
-->
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
<!--
Short ternary (?:) is readable and intentional.
-->
<exclude name="Universal.Operators.DisallowShortTernary.Found"/>
<!--
Slow DB query warnings - meta_query is sometimes necessary.
-->
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_query"/>
<!--
base64_encode is used for safe data encoding, not obfuscation.
-->
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode"/>
<!--
Multiple classes per file is used for List Tables that are tightly coupled.
-->
<exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound"/>
<!--
Unused function parameters are often required for WordPress hooks/filters
that pass multiple arguments even when not all are needed.
-->
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed"/>
<!--
Private/protected properties use underscore prefix by convention in this codebase.
-->
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
<!--
Throw tag documentation is not strictly required.
-->
<exclude name="Squiz.Commenting.FunctionCommentThrowTag.Missing"/>
<!--
Translator comments for i18n - not always required for simple strings.
-->
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/>
<!--
Comment formatting - period at end of param comments not required.
-->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
<!--
Commented out code is sometimes intentional for reference.
-->
<exclude name="Squiz.PHP.CommentedOutCode.Found"/>
<!--
Reserved keywords as parameter names (array, default, class) are sometimes
meaningful and readable in context.
-->
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound"/>
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound"/>
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.classFound"/>
<!--
base64_decode is used for safe data decoding, not obfuscation.
-->
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode"/>
<!--
time() and current_time() are used appropriately in this plugin.
-->
<exclude name="WordPress.DateTime.CurrentTimeTimestamp.Requested"/>
<!--
Scripts in header are sometimes needed for critical functionality.
-->
<exclude name="WordPress.WP.EnqueuedResourceParameters.NotInFooter"/>
<!--
Schema changes are necessary during plugin activation/migration.
-->
<exclude name="WordPress.DB.DirectDatabaseQuery.SchemaChange"/>
<!--
Size functions in loops are sometimes necessary for dynamic arrays.
-->
<exclude name="Squiz.PHP.DisallowSizeFunctionsInLoops.Found"/>
<!--
Silenced errors are occasionally needed for expected failures.
-->
<exclude name="WordPress.PHP.NoSilencedErrors.Discouraged"/>
<!--
For loops with function calls in test - sometimes necessary.
-->
<exclude name="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"/>
<!--
Empty if statements sometimes used intentionally for clarity.
-->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedIf"/>
<!--
Short prefix warnings - ppq/PPQ are intentional and documented.
-->
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.ShortPrefixPassed"/>
<!--
Constants use PPQ_ prefix which is in the allowed list.
-->
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound"/>
<!--
Namespace uses documented prefix.
-->
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound"/>
<!--
Variable names from third-party APIs may not follow snake_case.
-->
<exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase"/>
<exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase"/>
<!--
Unreachable code - sometimes intentional for completeness.
-->
<exclude name="Squiz.PHP.NonExecutableCode.Unreachable"/>
<!--
Prepared SQL placeholders - complex queries may flag false positives.
-->
<exclude name="WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare"/>
<!--
Non-prefixed variable - $wpdb and similar are standard.
-->
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound"/>
<!--
in_array strict mode - not always required for string comparisons.
-->
<exclude name="WordPress.PHP.StrictInArray.MissingTrueStrict"/>
</rule>
<!-- Verify that the text domain is set correctly -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="pressprimer-quiz"/>
</property>
</properties>
</rule>
<!-- Verify that everything is properly prefixed -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="pressprimer_quiz"/>
<element value="ppq"/>
<element value="PressPrimer_Quiz"/>
<element value="PPQ"/>
</property>
</properties>
</rule>
<!-- Allow short prefixes for database tables and internal use -->
<rule ref="WordPress.NamingConventions.ValidHookName">
<properties>
<property name="additionalWordDelimiters" value="-"/>
</properties>
</rule>
<!--
Minimum PHP and WP versions.
These should match the plugin header requirements.
-->
<config name="minimum_wp_version" value="6.4.0"/>
<config name="minimum_supported_php_version" value="7.4.0"/>
<!-- Check for PHP cross-version compatibility -->
<config name="testVersion" value="7.4-"/>
<!--
==========================================================================
WordPress.org Plugin Directory - Additional Rules
==========================================================================
These rules are enforced by the WordPress.org plugin scanner but are not
included in the default WordPress-Core or WordPress-Extra rulesets.
Adding them here ensures we catch issues before submission.
-->
<!-- Heredoc/nowdoc syntax is not allowed by WordPress.org -->
<rule ref="Squiz.PHP.Heredoc"/>
<!--
Console statements in JavaScript should be removed for production.
While PHPCS doesn't check JS, this comment serves as a reminder.
Use the JavaScript linting rules in package.json for this.
-->
</ruleset>