-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathphpcs.xml
149 lines (125 loc) · 6.03 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
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>A custom set of code standard rules to check for WordPress code.</description>
<!-- How to scan -->
<arg value="sp"/><!-- Show sniff and progress -->
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->
<arg name="extensions" value="php"/>
<arg name="parallel" value="10"/><!-- Enables parallel processing when available for faster results. -->
<arg name="cache" value=".phpcs.cache"/>
<!-- Check for cross-version support for PHP 7.2 and higher. -->
<config name="testVersion" value="7.2-"/>
<!-- Minimum WP version to check for usage of deprecated functions, classes and function parameters -->
<config name="minimum_supported_wp_version" value="5.4.1"/>
<!-- Rules: -->
<rule ref="PHPCompatibilityWP"/>
<!-- What to scan -->
<file>wp-content/mu-plugins/</file>
<file>wp-content/plugins/</file>
<file>wp-content/themes/</file>
<!-- Exclude "Third-party Themes" -->
<!-- <exclude-pattern>wp-content/themes/twentytwenty/</exclude-pattern> -->
<!-- Exclude "Third-party Plugins" -->
<!-- <exclude-pattern>wp-content/plugins/advanced-custom-fields-pro/</exclude-pattern> -->
<!-- Exclude common files -->
<exclude-pattern>*/\.idea/*</exclude-pattern>
<exclude-pattern>*/\.github/*</exclude-pattern>
<exclude-pattern>*/\.idea/*</exclude-pattern>
<exclude-pattern>*/\.make/*</exclude-pattern>
<exclude-pattern>*/\.wordpress-org/*</exclude-pattern>
<exclude-pattern>*/assets/*</exclude-pattern>
<exclude-pattern>*/languages/*</exclude-pattern>
<exclude-pattern>*/lib/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/src/js/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*\.js</exclude-pattern>
<exclude-pattern>*\.mo</exclude-pattern>
<exclude-pattern>*\.po</exclude-pattern>
<exclude-pattern>*\.twig</exclude-pattern>
<exclude-pattern>*\.css</exclude-pattern>
<exclude-pattern>*\.scss</exclude-pattern>
<exclude-pattern>wp-content/uploads/</exclude-pattern>
<rule ref="WordPress">
<!-- Allow short ternary syntax and short arrays and short open tag -->
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
<exclude name="WordPress.PHP.DisallowShortTernary.Found" />
<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<!-- Disable dot of end string docblock -->
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<exclude name="WordPress.PHP.YodaConditions" />
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
</rule>
<!-- Disable comments blocks -->
<rule ref="WordPress-Docs">
<exclude name="Squiz.Commenting.FileComment.Missing" />
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType" />
<exclude name="Squiz.Commenting.VariableComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" />
</rule>
<!-- Allow symbol `/` in hook names. -->
<rule ref="WordPress.NamingConventions.ValidHookName">
<properties>
<property name="additionalWordDelimiters" value="/" />
</properties>
</rule>
<!-- Allow for underscores in theme template file names -->
<rule ref="WordPress.Files.FileName">
<properties>
<property name="is_theme" value="true" />
</properties>
</rule>
<!--<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="3"/>
<property name="absoluteComplexity" value="5"/>
</properties>
</rule>-->
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="absoluteNestingLevel" value="4"/>
</properties>
</rule>
<!-- Disallow long array syntax. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"/>
<!-- Prohibit Yoda Conditions expressions -->
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
<!-- Namespacing required for classes. -->
<!-- <rule ref="PSR1.Classes.ClassDeclaration" /> -->
<!-- Namespacing required for functions. -->
<!-- <rule ref="PSR2.Namespaces.NamespaceDeclaration" /> -->
<!-- Forbidden functions -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="delete" value="unset"/>
<element key="print" value="echo"/>
<element key="create_function" value="null"/>
<element key="sizeof" value="count"/>
<!-- <element key="var_dump" value="null"/> duplicate of WP rule-->
<element key="print_r" value="null"/>
<element key="eval" value="null"/>
<element key="compact" value="null"/>
</property>
</properties>
</rule>
<!-- AutoEscaped functions -->
<rule ref="WordPress.Security.EscapeOutput">
<properties>
<property name="customAutoEscapedFunctions" type="array">
<element value="rd_render_attributes" />
<element value="rd_get_picture_html" />
</property>
</properties>
</rule>
<!-- Fix errors "No PHP code was found" in GitHub action. These errors show on GitHub actions. It can happen in case you run PHPCS into Docker container -->
<rule ref="Internal.NoCodeFound">
<severity>0</severity>
</rule>
</ruleset>