Repository navigation
Expand file tree
/
Copy pathphpcs.xml.dist
More file actions
133 lines (109 loc) · 4.81 KB
/
Copy pathphpcs.xml.dist
File metadata and controls
133 lines (109 loc) · 4.81 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
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WP_AIUT project" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>A custom set of rules to check for the WP AI Rate Limiter project</description>
<!-- Include all PHP files in the project. -->
<file>.</file>
<!-- Exclude the Composer Vendor directory. -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Exclude the Node Modules directory. -->
<exclude-pattern>*/node_modules/*</exclude-pattern>
<!-- Exclude the built assets directory. -->
<exclude-pattern>*/build/*</exclude-pattern>
<!--
Exclude the PHPUnit test suite. Test files intentionally diverge from the
plugin's production conventions: PHPUnit discovers test classes by the
*-test.php filename pattern (not WordPress's class-*.php), and concise test
docblocks are by design. Tests are still linted (php -l) and type-checked at
their own level via the suite run.
-->
<exclude-pattern>*/tests/*</exclude-pattern>
<!-- Exclude Javascript & CSS files. -->
<exclude-pattern>*.js</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="."/>
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>
<!--
Warnings are advisory; only errors should fail CI. The few remaining warnings
are documented false positives (reserved-keyword param names like $class, and
dynamic hook names that ARE prefixed via class constants). This keeps them
visible in the report without breaking the build on an error-free codebase.
-->
<config name="ignore_warnings_on_exit" value="1"/>
<!--
#############################################################################
SET UP THE RULESETS
#############################################################################
-->
<!-- Include the WordPress-Extra standard. -->
<rule ref="WordPress-Extra"/>
<!-- Let's also check that everything is properly documented. -->
<rule ref="WordPress-Docs"/>
<!-- Add in some extra rules from other standards. -->
<rule ref="Generic.Commenting.Todo"/>
<!-- Check for PHP cross-version compatibility (PHP 7.4 and up). -->
<config name="testVersion" value="7.4-"/>
<rule ref="PHPCompatibilityWP">
<include-pattern>*\.php</include-pattern>
</rule>
<!--
#############################################################################
SNIFF SPECIFIC CONFIGURATION
#############################################################################
-->
<!-- Minimum WordPress version: the AI Client ships in core 7.0. -->
<config name="minimum_wp_version" value="7.0"/>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="wp-aiut"/>
</property>
</properties>
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="WP_AIUT"/>
<element value="wp_aiut"/>
<element value="aiut"/>
</property>
</properties>
</rule>
<rule ref="WordPress">
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
<exclude name="WordPress.PHP.YodaConditions"/>
</rule>
<exclude name="PEAR.Files.IncludingFile.UseRequire"/>
<!-- Enforce short arrays. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!--
The data-layer classes operate exclusively on the plugin's own custom tables.
Table names are trusted, $wpdb->prefix-derived identifiers (never user input)
that cannot be parameterised in SQL, and the per-row counter upserts/reads are
by design not object-cached. Scope the unavoidable custom-table DB sniffs to
these files so genuine issues elsewhere are not masked.
-->
<rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared">
<exclude-pattern>*/src/Data/*</exclude-pattern>
<exclude-pattern>*/src/Accounting/*</exclude-pattern>
<exclude-pattern>*/src/Admin/class-rest-controller.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.DirectDatabaseQuery.DirectQuery">
<exclude-pattern>*/src/Data/*</exclude-pattern>
<exclude-pattern>*/src/Accounting/*</exclude-pattern>
<exclude-pattern>*/src/Admin/class-rest-controller.php</exclude-pattern>
<exclude-pattern>*/uninstall.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.DirectDatabaseQuery.NoCaching">
<exclude-pattern>*/src/Data/*</exclude-pattern>
<exclude-pattern>*/src/Accounting/*</exclude-pattern>
<exclude-pattern>*/src/Admin/class-rest-controller.php</exclude-pattern>
<exclude-pattern>*/uninstall.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.DirectDatabaseQuery.SchemaChange">
<exclude-pattern>*/src/Data/class-schema.php</exclude-pattern>
<exclude-pattern>*/uninstall.php</exclude-pattern>
</rule>
</ruleset>