-
Notifications
You must be signed in to change notification settings - Fork 4
/
phpcs.xml
198 lines (177 loc) · 8.16 KB
/
phpcs.xml
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
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>Apply WordPress Coding Standards to all files</description>
<!-- Only scan PHP files. -->
<arg name="extensions" value="php"/>
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache"/>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Check up to 20 files simultaneously. -->
<arg name="parallel" value="20"/>
<!-- Show sniff codes in all reports. -->
<arg value="ps"/>
<file>.</file>
<rule ref="WordPress-Core"/>
<rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
<!-- These rules are being set as warnings instead of errors, so we can error check the entire codebase. -->
<rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
<type>warning</type>
</rule>
<rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared">
<type>warning</type>
</rule>
<rule ref="WordPress.DB.PreparedSQL.NotPrepared">
<type>warning</type>
</rule>
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<type>warning</type>
</rule>
<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="customPropertiesWhitelist" type="array">
<!-- From database structure queries. -->
<element value="Collation"/>
<element value="Column_name"/>
<element value="Default"/>
<element value="Extra"/>
<element value="Field"/>
<element value="Index_type"/>
<element value="Key"/>
<element value="Key_name"/>
<element value="Msg_text"/>
<element value="Non_unique"/>
<element value="Null"/>
<element value="Sub_part"/>
<element value="Type"/>
<!-- From plugin/theme data. -->
<element value="authorAndUri"/>
<element value="Name"/>
<element value="Version"/>
<!-- From the result of wp_xmlrpc_server::wp_getPageList(). -->
<element value="dateCreated"/>
<!-- From DOMDocument. -->
<element value="childNodes"/>
<element value="formatOutput"/>
<element value="nodeName"/>
<element value="nodeType"/>
<element value="parentNode"/>
<element value="preserveWhiteSpace"/>
<element value="textContent"/>
<!-- From PHPMailer. -->
<element value="AltBody"/>
<element value="Body"/>
<element value="CharSet"/>
<element value="ContentType"/>
<element value="Encoding"/>
<element value="Hostname"/>
<element value="mailHeader"/>
<element value="MIMEBody"/>
<element value="MIMEHeader"/>
<element value="Sender"/>
<element value="Subject"/>
<!-- From PHPUnit_Util_Getopt. -->
<element value="longOptions"/>
<!-- From POP3. -->
<element value="ERROR"/>
<!-- From ZipArchive. -->
<element value="numFiles"/>
</property>
</properties>
</rule>
<!-- Directories and third party library exclusions. -->
<exclude-pattern>/node_modules/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/tests/phpunit/includes/phpunit7/MockObject/*</exclude-pattern>
<exclude-pattern>/tests/phpunit/includes/speed-trap-listener\.php</exclude-pattern>
<!-- Test data and fixtures. -->
<exclude-pattern>/tests/phpunit/build*</exclude-pattern>
<exclude-pattern>/tests/phpunit/data/*</exclude-pattern>
<!-- Translator comments aren't needed in unit tests. -->
<rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
<exclude-pattern>/tests/*</exclude-pattern>
</rule>
<!-- Exclude checking of line endings when reporting errors, but fix them when running phpcbf.
Git and SVN manage these pretty well cross-platform as "native".
Whitelist configuration files. -->
<rule ref="Generic.Files.LineEndings">
<exclude-pattern>/wp-config\.php</exclude-pattern>
<exclude-pattern>/wp-config-sample\.php</exclude-pattern>
<exclude phpcs-only="true" name="Generic.Files.LineEndings"/>
</rule>
<!-- Whitelist test classes for select sniffs. -->
<rule ref="WordPress.Files.FileName">
<properties>
<property name="custom_test_class_whitelist" type="array">
<!-- Test case parent classes. -->
<element value="WP_UnitTestCase"/>
<element value="WP_Ajax_UnitTestCase"/>
<element value="WP_Canonical_UnitTestCase"/>
<element value="WP_Test_REST_TestCase"/>
<element value="WP_Test_REST_Controller_Testcase"/>
<element value="WP_Test_REST_Post_Type_Controller_Testcase"/>
<element value="WP_XMLRPC_UnitTestCase"/>
<element value="WP_Filesystem_UnitTestCase"/>
<element value="WP_Image_UnitTestCase"/>
<element value="WP_HTTP_UnitTestCase"/>
<element value="WP_Tests_Image_Resize_UnitTestCase"/>
<element value="WP_Import_UnitTestCase"/>
<element value="Tests_Query_Conditionals"/>
<element value="WP_Test_XML_TestCase"/>
<!-- Mock classes. -->
<element value="Spy_REST_Server"/>
<element value="WP_REST_Test_Controller"/>
<element value="WP_Image_Editor_Mock"/>
<element value="WP_Filesystem_MockFS"/>
<element value="MockPHPMailer"/>
<element value="MockAction"/>
<element value="WP_Object_Cache"/>
<!-- PHPUnit helpers. -->
<element value="TracTickets"/>
<element value="WP_PHPUnit_Util_Getopt"/>
<element value="PHPUnit_Util_Test"/>
<element value="WPProfiler"/>
<element value="SpeedTrapListener"/>
<element value="PHPUnit_Framework_Exception"/>
</property>
</properties>
</rule>
<rule ref="WordPress.PHP.NoSilencedErrors">
<properties>
<property name="custom_whitelist" type="array">
<element value="ssh2_connect"/>
<element value="ssh2_auth_password"/>
<element value="ssh2_auth_pubkey_file"/>
<element value="ftp_ssl_connect"/>
<element value="ftp_connect"/>
<element value="ftp_get_option"/>
<element value="ftp_set_option"/>
<element value="disk_free_space"/>
<element value="getimagesize"/>
<element value="iptcparse"/>
<element value="exif_read_data"/>
<element value="gzinflate"/>
<element value="gzuncompress"/>
<element value="gzdecode"/>
</property>
</properties>
</rule>
<!-- Enforce no parenthesis for language constructs, and only one space immediately after.
Including this rule is temporary until it is moved from the WordPress-Extra ruleset to
the WordPress-Core ruleset upstream.
-->
<rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
<type>warning</type>
</rule>
<rule ref="PEAR.Files.IncludingFile.UseRequire">
<type>warning</type>
</rule>
<rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
<type>warning</type>
</rule>
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Assignments in while conditions are a valid method of looping over iterables. -->
<rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
<exclude-pattern>*</exclude-pattern>
</rule>
</ruleset>