-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruleset.xml
More file actions
199 lines (169 loc) · 6.75 KB
/
ruleset.xml
File metadata and controls
199 lines (169 loc) · 6.75 KB
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
199
<?xml version="1.0"?>
<ruleset name="Dude-Coding-Standards">
<description>
Dude Coding Standards (DCS)
https://dev.docs.dude.fi
Combined WordPress*, WordPress-Security and PSR-12 coding standards
with PHP 8.0+ compatibility for Dude projects.
Reference: https://linear.app/dude/issue/DEV-624/dude-coding-standards-10-phpcsxml
</description>
<!-- PHPCS command line arguments arguments -->
<arg value="p" /> <!-- show progress -->
<arg value="s" /> <!-- show sniff codes -->
<arg value="v" /> <!-- verbose output -->
<arg name="extensions" value="php" />
<!-- Exclude common folders -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/dist/*</exclude-pattern>
<exclude-pattern>*/plugin-update-checker/*</exclude-pattern>
<exclude-pattern>*/mu-plugins/mercator/*</exclude-pattern>
<exclude-pattern>*/mu-plugins/bedrock-autoloader*</exclude-pattern>
<exclude-pattern>*/content/db.php</exclude-pattern>
<exclude-pattern>scripts/Roots/*</exclude-pattern>
<exclude-pattern>*/blocks/*.asset.php</exclude-pattern>
<exclude-pattern>*/blocks/*.js</exclude-pattern>
<exclude-pattern>*/blocks/*.css</exclude-pattern>
<!-- Suppress deprecation warnings -->
<config name="ignore_warnings_on_exit" value="1"/>
<config name="ignore_errors_on_exit" value="0"/>
<!--
IMPORTANT: We do NOT include Generic, Squiz, PEAR, PSR*, or Universal rulesets!
WordPress standards already include the necessary rules from these.
Including them again adds hundreds of unwanted rules.
Instead, we disable specific rules inherited from WordPress that don't match Dude style.
-->
<!-- Disable WordPress tab requirements - we use spaces -->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent">
<severity>0</severity>
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<severity>0</severity>
</rule>
<!-- Disallow tabs - we use 2 spaces -->
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<!-- Allow short array syntax [] instead of array() -->
<rule ref="Universal.Arrays.DisallowShortArraySyntax">
<severity>0</severity>
</rule>
<!-- Disable precision alignment warnings (we align code intentionally) -->
<rule ref="Universal.WhiteSpace.PrecisionAlignment">
<severity>0</severity>
</rule>
<!-- Disable all commenting rules -->
<rule ref="Squiz.Commenting">
<severity>0</severity>
</rule>
<rule ref="Generic.Commenting">
<severity>0</severity>
</rule>
<!-- Disable alignment rules (we don't enforce assignment alignment) -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<severity>0</severity>
</rule>
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
<severity>0</severity>
</rule>
<!-- Disable Universal rules we don't want -->
<rule ref="Universal.Classes.RequireFinalClass">
<severity>0</severity>
</rule>
<rule ref="Universal.NamingConventions.NoReservedKeywordParameterNames">
<severity>0</severity>
</rule>
<!-- Enable code complexity checks -->
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="10"/>
<property name="absoluteComplexity" value="12"/>
</properties>
</rule>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="3"/>
<property name="absoluteNestingLevel" value="4"/>
</properties>
</rule>
<!-- Disallow inner functions (functions inside functions) -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Disable Squiz discouraged functions (we manage this separately) -->
<rule ref="Squiz.PHP.DiscouragedFunctions">
<severity>0</severity>
</rule>
<!-- Disable PEAR rules that conflict with Dude style -->
<rule ref="PEAR.Functions.FunctionCallSignature">
<severity>0</severity>
</rule>
<!-- Disable WordPress/Generic parentheses spacing (we have our own style) -->
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing">
<severity>0</severity>
</rule>
<!-- Allow short ternary operator (?:) -->
<rule ref="Universal.Operators.DisallowShortTernary">
<severity>0</severity>
</rule>
<!-- Allow post-increment ($i++ instead of ++$i) -->
<rule ref="Universal.Operators.DisallowStandalonePostIncrementDecrement">
<severity>0</severity>
</rule>
<!-- Don't require space after function keyword -->
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction">
<severity>0</severity>
</rule>
<!-- Allow PHP opening/closing tags on same line as content in templates -->
<rule ref="Squiz.PHP.EmbeddedPhp.ContentAfterOpen">
<severity>0</severity>
</rule>
<rule ref="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd">
<severity>0</severity>
</rule>
<!-- Disable WordPress array indentation (conflicts with our style) -->
<rule ref="WordPress.Arrays.ArrayIndentation">
<severity>0</severity>
</rule>
<!-- Include WordPress standards -->
<rule ref="WordPress">
<!-- Exclude rules under WordPress standards -->
<exclude name="WordPress.Arrays.MultipleStatementAlignment" />
<exclude name="WordPress.Arrays.ArrayIndentation" />
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing" />
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_query" />
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited" />
<exclude name="WordPress.PHP.YodaConditions" />
</rule>
<!-- PHP compatibility checks -->
<rule ref="PHPCompatibility" />
<config name="testVersion" value="8.3" />
<!-- Custom Dude sniffs -->
<rule ref="DCS.PHP.ForbiddenFunctions"/>
<!-- Downgrade to warnings -->
<!--
NoSemicolon: Semicolons in embedded PHP are good practice for:
- Consistency: all PHP statements should visually end with semicolons
- Maintainability: adding another statement won't cause syntax errors
- Habit formation: relying on implicit semicolons can lead to bugs
But we allow it as a warning since the code works either way.
-->
<rule ref="Squiz.PHP.EmbeddedPhp.NoSemicolon">
<type>warning</type>
</rule>
<!-- Encoding and indentation -->
<config name="encoding" value="utf-8" />
<!-- Dude prefers 2 spaces -->
<config name="tab_width" value="2" />
<rule ref="PEAR.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2" />
<property name="exact" value="true" />
<property name="tabIndent" value="false" />
<property name="ignoreIndentationTokens" type="array">
<element value="T_COMMENT"/>
<element value="T_DOC_COMMENT"/>
<element value="T_HEREDOC"/>
<element value="T_NOWDOC"/>
<element value="T_INLINE_HTML"/>
</property>
</properties>
</rule>
</ruleset>