-
Notifications
You must be signed in to change notification settings - Fork 69
/
phpcs.xml.dist
164 lines (134 loc) · 6.37 KB
/
phpcs.xml.dist
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
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>WooCommerce dev PHP_CodeSniffer ruleset.</description>
<arg value="ps"/>
<arg name="parallel" value="20"/>
<arg name="extensions" value="php"/>
<!-- Exclude paths -->
<exclude-pattern>./dev/*</exclude-pattern>
<exclude-pattern>./dist/*</exclude-pattern>
<exclude-pattern>./release/*</exclude-pattern>
<exclude-pattern>./docker/*</exclude-pattern>
<exclude-pattern>./node_modules/*</exclude-pattern>
<exclude-pattern>./vendor/*</exclude-pattern>
<exclude-pattern>./vendor-dist/*</exclude-pattern>
<exclude-pattern>./lib/*</exclude-pattern>
<exclude-pattern>./bin/*</exclude-pattern>
<!-- Configs -->
<config name="minimum_supported_wp_version" value="6.0" />
<config name="testVersion" value="7.3-" />
<!-- Rules -->
<rule ref="WooCommerce-Core" >
<exclude name="Generic.Commenting.Todo"/>
<!-- These sniffs are superceded by the VariableAnalysis sniffs. -->
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed" />
<!-- This rule is currently generating some false positives, it would be worth retrying after PHPCS upgrades -->
<exclude name="Squiz.Commenting.FunctionCommentThrowTag.WrongNumber"/>
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found"/>
<!-- FIXME: Remove these ignores once https://github.com/Automattic/woocommerce-payments/issues/8434 is closed. -->
<exclude name="WordPress.Security.EscapeOutput.ExceptionNotEscaped" />
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped" />
<exclude name="WordPress.Security.ValidatedSanitizedInput.InputNotValidated" />
<!-- FIXME: Remove these ignores once https://github.com/Automattic/woocommerce-payments/issues/8436 is closed. -->
<exclude name="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable" />
<!-- FIXME: Remove these ignores once https://github.com/Automattic/woocommerce-payments/issues/8437 is clsoed. -->
<exclude name="WooCommerce.Commenting.CommentHooks.MissingHookComment" />
<exclude name="WooCommerce.Commenting.CommentHooks.MissingSinceComment" />
<exclude name="WooCommerce.Commenting.CommentHooks.HookCommentWrongStyle" />
<!-- FIXME: Remove these ignores once https://github.com/Automattic/woocommerce-payments/issues/8438 is closed. -->
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.boolFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.elseFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.classFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.matchFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.returnFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.functionFound" />
</rule>
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
<properties>
<property name="ignoreUnusedRegexp" value="/^_unused_/"/>
</properties>
</rule>
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable">
<exclude-pattern>templates/emails/</exclude-pattern>
<exclude-pattern>includes/in-person-payments/templates/</exclude-pattern>
<exclude-pattern>includes/compat/subscriptions/emails</exclude-pattern>
</rule>
<!-- Disallow long array syntax -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="woocommerce-payments" />
</properties>
</rule>
<rule ref="WordPress.Security">
<exclude-pattern>./tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions">
<exclude-pattern>tests/</exclude-pattern>
<exclude-pattern>.github/</exclude-pattern>
</rule>
<rule ref="WordPress.Security.EscapeOutput">
<properties>
<property name="customEscapingFunctions" type="array" value="WC_Payments_Utils,esc_interpolated_html" />
</properties>
</rule>
<rule ref="PHPCompatibility">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="WordPress.Files.FileName">
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>includes/multi-currency/*</exclude-pattern>
<exclude-pattern>src</exclude-pattern>
</rule>
<rule ref="WordPress.WP.Capabilities">
<properties>
<property name="custom_capabilities" type="array">
<element value="manage_woocommerce" />
<element value="pay_for_order" />
<element value="read_private_shop_orders" />
<element value="edit_shop_subscription_payment_method" />
</property>
</properties>
</rule>
<rule ref="Generic.Commenting">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FunctionComment">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FunctionCommentThrowTag.Missing" />
<rule ref="Universal.Files.SeparateFunctionsFromOO.Mixed">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<!-- We don't need to do nonce checks in unit test code -->
<rule ref="WordPress.Security.NonceVerification.Recommended">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" />
<!-- Custom WCPay rules -->
<rule ref="./dev/phpcs/WCPay/ruleset.xml"/>
<!-- Check the class structure (ordering of methods, properties, etc.) -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
<element value="uses"/>
<element value="constants"/>
<element value="properties"/>
<element value="enum cases"/>
<element value="constructor, static constructors"/>
<element value="abstract methods" />
<element value="all public methods, magic methods"/>
<element value="protected methods"/>
<element value="methods"/>
</property>
</properties>
<include-pattern>src/*</include-pattern>
<exclude-pattern>tests/</exclude-pattern>
</rule>
</ruleset>