-
Notifications
You must be signed in to change notification settings - Fork 2
/
phpcs.xml
165 lines (141 loc) · 7.57 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
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="MultiSafepay`s Wordpress WooCommerce" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>A custom coding standard for MultiSafepay`s Wordpress WooCommerce plugin.</description>
<!-- Exclude folders and files from being checked. -->
<exclude-pattern>./bin/*</exclude-pattern>
<exclude-pattern>./tests/*</exclude-pattern>
<exclude-pattern>./coverage-report/*</exclude-pattern>
<exclude-pattern>./languages/*</exclude-pattern>
<!-- Exclude the Composer Vendor directory. -->
<exclude-pattern>./vendor/*</exclude-pattern>
<!-- Exclude the Node Modules directory. -->
<exclude-pattern>./node_modules/*</exclude-pattern>
<!-- Exclude the build directory. -->
<exclude-pattern>./assets/public/js/multisafepay-blocks/build/*</exclude-pattern>
<!-- Exclude minified Javascript files. -->
<exclude-pattern>*.min.js</exclude-pattern>
<!-- Include the WordPress-Extra standard. -->
<rule ref="WordPress-Extra">
<!-- This is disabled and incompatible with strict_types after opening PHP tags -->
<exclude name="Squiz.Commenting.FileComment.Missing"/>
<!-- Not every @param needs to be commented -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Not every method functions needs to be commented -->
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<!-- At this moment we are not using Wordpress conventions for the classes names -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<!-- At this moment we are not using Wordpress conventions for the files names -->
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
<!-- We dont require and need a dot at the end of each comment -->
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
<!-- We dont require a comment for each @throws comment -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- We dont require each comment ends in a characters that means the end of the line; like a dot. -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
<!-- In some places we use date() function. We want to use TimeZone set in the store and not gmdate() suggestion from PHPCS -->
<exclude name="WordPress.DateTime.RestrictedFunctions.date_date"/>
<!-- Exclude warning if founds a method which does not use a parameter -->
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed"/>
<!-- Exclude warning if founds a method which does not use a parameter in a extended class -->
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass"/>
</rule>
<rule ref="WordPress">
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="false"/>
</properties>
</rule>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<!-- Exclude all gateways and giftcards classes from this rule -->
<rule ref="Squiz.Commenting.ClassComment.Missing">
<exclude-pattern>*/src/PaymentMethods/*</exclude-pattern>
</rule>
<!-- Exclude nonce verification, which, according to documentation, is not required when submit an order -->
<rule ref="WordPress.Security.NonceVerification.Missing">
<exclude-pattern>*/src/PaymentMethods/PaymentMethodsController.php</exclude-pattern>
<exclude-pattern>*/src/PaymentMethods/Base/BasePaymentMethod.php</exclude-pattern>
<exclude-pattern>*/src/Services/OrderService.php</exclude-pattern>
<exclude-pattern>*/src/Services/CustomerService.php</exclude-pattern>
</rule>
<!-- Exclude nonce verification recomendation -->
<rule ref="WordPress.Security.NonceVerification.Recommended">
<exclude-pattern>*/src/Settings/SettingsController.php</exclude-pattern>
</rule>
<!-- Exclude BasePaymentMethod.php length limit -->
<rule ref="ObjectCalisthenics.Files.ClassTraitAndInterfaceLength.ObjectCalisthenics\Sniffs\Files\ClassTraitAndInterfaceLengthSniff">
<exclude-pattern>*/src/PaymentMethods/BasePaymentMethod.php</exclude-pattern>
</rule>
<!-- Exclude multisafepay-google-pay.js -->
<rule ref="PEAR.Functions.FunctionCallSignature.Indent">
<exclude-pattern>*/assets/public/js/multisafepay-google-pay.js</exclude-pattern>
</rule>
<!-- -->
<rule ref="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents">
<exclude-pattern>*/templates/partials/multisafepay-settings-logs-display.php</exclude-pattern>
</rule>
<!-- Let's also check that everything is properly documented. -->
<rule ref="WordPress-Docs"/>
<!-- Add in some extra rules from other standards. -->
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.Commenting.Todo"/>
<!-- Check for PHP cross-version compatibility. -->
<config name="testVersion" value="7.3-"/>
<rule ref="PHPCompatibilityWP"/>
<!-- Minimum Wordpress version supported -->
<config name="minimum_supported_wp_version" value="5.0"/>
<!-- Check text domain for I18n -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="multisafepay"/>
</property>
</properties>
</rule>
<!-- No "else" -->
<rule ref="ObjectCalisthenics.ControlStructures.NoElse"/>
<!-- Only 3 indentation level per function/method -->
<rule ref="ObjectCalisthenics.Metrics.MaxNestingLevel">
<properties>
<property name="maxNestingLevel" value="3"/>
</properties>
<exclude-pattern>*/src/PaymentMethods/Base/BasePaymentMethodBlocks.php</exclude-pattern>
<exclude-pattern>*/src/Services/PaymentMethodService.php</exclude-pattern>
</rule>
<!-- Minimal length for variables names -->
<rule ref="ObjectCalisthenics.NamingConventions.ElementNameMinimalLength">
<properties>
<property name="minLength" value="3"/>
<property name="allowedShortNames" type="array" value=""/>
</properties>
</rule>
<!-- The following ensure small classes -->
<rule ref="ObjectCalisthenics.Files.ClassTraitAndInterfaceLength">
<properties>
<property name="maxLength" value="500"/>
</properties>
<exclude-pattern>*/src/PaymentMethods/Base/BasePaymentMethod.php</exclude-pattern>
<exclude-pattern>*/src/Settings/SystemReport.php</exclude-pattern>
</rule>
<rule ref="ObjectCalisthenics.Files.FunctionLength">
<properties>
<property name="maxLength" value="500"/>
</properties>
</rule>
<rule ref="ObjectCalisthenics.Metrics.PropertyPerClassLimit">
<properties>
<property name="maxCount" value="25"/>
</properties>
</rule>
<rule ref="ObjectCalisthenics.Metrics.MethodPerClassLimit">
<properties>
<property name="maxCount" value="30"/>
</properties>
<exclude-pattern>*/src/PaymentMethods/Base/BasePaymentMethod.php</exclude-pattern>
</rule>
<!-- Report @todo comments -->
<rule ref="Generic.Commenting.Todo.CommentFound"/>
</ruleset>