/
ruleset.xml
executable file
路178 lines (151 loc) 路 6.69 KB
/
ruleset.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
<?xml version="1.0"?>
<ruleset name="Required">
<description>required Coding Standards</description>
<!-- Check all PHP files in directory tree by default. -->
<arg name="extensions" value="php"/>
<!-- Show progress and sniff codes in all reports -->
<arg value="ps"/>
<!-- Check up to 20 files simultaneously. -->
<arg name="parallel" value="20"/>
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache"/>
<!-- Adds support for .phpcsignore
https://github.com/squizlabs/PHP_CodeSniffer/issues/1884 -->
<autoload>./bootstrap.php</autoload>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*\.min\.*</exclude-pattern>
<!-- Analysis of problematic variable use. -->
<rule ref="VariableAnalysis"/>
<rule ref="WordPress-Core">
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="WordPress.PHP.DisallowShortTernary"/>
</rule>
<rule ref="WordPress-Docs">
<!-- Documentation is organized with the use of namespaces. -->
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag"/>
</rule>
<rule ref="WordPress-Extra">
<!-- _e() and _ex() are considered safe for internal translations -->
<exclude name="WordPress.Security.EscapeOutput.UnsafePrintingFunction"/>
</rule>
<rule ref="WordPress.Files.FileName">
<properties>
<property name="strict_class_file_names" value="false"/>
</properties>
</rule>
<!-- Allow . in hook names. -->
<rule ref="WordPress.NamingConventions.ValidHookName">
<properties>
<property name="additionalWordDelimiters" value="."/>
</properties>
</rule>
<!-- File Layout: Declare symbols or run code, but not both. -->
<rule ref="PSR1.Files.SideEffects"/>
<!-- Enforces short array syntax. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="WordPress.Security.EscapeOutput">
<properties>
<property name="customAutoEscapedFunctions" type="array">
<!-- i18n functions are considered safe for internal translations. -->
<element value="__"/>
<element value="_x"/>
<element value="_n"/>
<element value="_nx"/>
<element value="number_format_i18n"/>
<element value="date_i18n"/>
<!-- Considered some template functions as safe. -->
<element value="paginate_links"/>
</property>
</properties>
</rule>
<!-- Make sure longer multiple statements are always properly aligned. -->
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
<properties>
<property name="maxColumn" value="200"/>
</properties>
</rule>
<!-- Allow the use of filesystem functions. -->
<rule ref="WordPress.WP.AlternativeFunctions">
<properties>
<property name="exclude" type="array">
<element value="file_get_contents"/>
</property>
</properties>
</rule>
<rule ref="Squiz.PHP.CommentedOutCode">
<properties>
<property name="maxPercentage" value="75"/>
</properties>
</rule>
<!-- Checks that there's no whitespace between a nullability symbol and a typehint. -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Checks whether the nullablity ? symbol is present before each nullable and optional parameter. -->
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<!-- Enforce no space between closing brace and colon of return typehint. -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Enforces using shorthand scalar typehint variants in phpDocs. -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Disallows grouped use declarations. -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Disallows leading backslash in use statement. -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Enforces fully qualified names of classes and interfaces in annotations. -->
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<!-- Checks whether uses at the top of a file are alphabetically sorted. -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Enforces one space after namespace, disallows content between namespace name and semicolon and disallows use of bracketed syntax. -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/>
<!-- Prohibits multiple uses separated by commas. -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Enforces one blank line before and after namespace. -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
<properties>
<property name="linesCountBeforeNamespace" value="1"/>
<property name="linesCountAfterNamespace" value="1"/>
</properties>
</rule>
<!-- Enforces one blank before first use, after last use and none between two different types of use. -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="0"/>
<property name="linesCountAfterLastUse" value="1"/>
</properties>
</rule>
<!-- Prohibits uses from the same namespace. -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- All references to types named Exception or ending with Exception must be referenced via a fully qualified name. -->
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
<!-- Looks for unused imports from other namespaces. -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
<!-- Class names should be referenced via ::class constant when possible. -->
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<!-- Requires use of null coalesce operator (??) when possible. -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
<!-- Reports forbidden annotations. -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@package"/>
<element value="@author"/>
<element value="@created"/>
<element value="@copyright"/>
<element value="@license"/>
<element value="@access"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!--Require the latest version of WordPress. -->
<config name="minimum_supported_wp_version" value="4.9"/>
<!-- Run against the PHPCompatibilityWP ruleset -->
<rule ref="PHPCompatibilityWP"/>
<config name="testVersion" value="7.1-"/>
</ruleset>