Skip to content

Commit c9580aa

Browse files
Update codesniffer ruleset
1 parent 652ddb0 commit c9580aa

2 files changed

Lines changed: 40 additions & 34 deletions

File tree

$rn"

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"MISSING: $sonar =

src/Standards/Totara/ruleset.xml

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
</properties>
2828
</rule>
2929

30-
<!-- PHP code MUST use only UTF-8 without BOM. -->
31-
<rule ref="Generic.Files.ByteOrderMark"/>
32-
3330
<!-- The closing ?> tag MUST be omitted from files containing only PHP. -->
3431
<rule ref="PSR2.Files.ClosingTag"/>
3532

@@ -68,8 +65,6 @@
6865
<rule ref="Generic.Classes.OpeningBraceSameLine"/>
6966
<rule ref="Totara.NamingConventions.ValidClassName"/>
7067

71-
<!-- Removed in PHPCS 4: Squiz.CSS.* class brace spacing sniffs. -->
72-
7368
<!-- When instantiating a new class, parenthesis MUST always be present even when there are no arguments passed to the constructor. -->
7469
<rule ref="PSR12.Classes.ClassInstantiation"/>
7570

@@ -87,7 +82,43 @@
8782

8883
<!-- 4.4 Methods/Functions -->
8984

90-
<!-- TODO Add spacing rules for function calls and declarations -->
85+
<!-- Spacing rules for function calls and declarations -->
86+
87+
<!-- No space between function name and opening parenthesis in calls -->
88+
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
89+
90+
<!-- Space after comma in function arguments -->
91+
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
92+
<properties>
93+
<property name="equalsSpacing" value="1"/>
94+
</properties>
95+
</rule>
96+
97+
<!-- No space before semicolons -->
98+
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
99+
100+
<!-- No space around cast operators -->
101+
<rule ref="Generic.Formatting.SpaceAfterCast"/>
102+
103+
<!-- No space between function name and opening parenthesis -->
104+
<rule ref="Squiz.Functions.FunctionDeclaration"/>
105+
106+
<!-- Space before/after function declaration -->
107+
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
108+
<properties>
109+
<property name="spacing" value="1"/>
110+
<property name="spacingBeforeFirst" value="0"/>
111+
<property name="spacingAfterLast" value="0"/>
112+
</properties>
113+
</rule>
114+
115+
<!-- Correct spacing around operator in default parameter value -->
116+
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeEquals">
117+
<severity>0</severity>
118+
</rule>
119+
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceAfterEquals">
120+
<severity>0</severity>
121+
</rule>
91122

92123
<!-- Visibility MUST be declared on all methods. -->
93124
<rule ref="Squiz.Scope.MethodScope"/>
@@ -197,91 +228,65 @@
197228
<property name="absoluteNestingLevel" value="10"/>
198229
</properties>
199230
</rule>
200-
<rule ref="Generic.Metrics.CyclomaticComplexity">
201-
<!-- php:S3776 Cognitive/cyclomatic complexity -->
202-
<properties>
203-
<property name="complexity" value="15"/>
204-
<property name="absoluteComplexity" value="30"/>
205-
</properties>
206-
</rule>
207231

208-
<!-- SonarQube rule coverage (php:S1068, php:S1172) -->
209232
<!-- Unused parameters -->
210233
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
211234

212-
<!-- SonarQube rule coverage (php:S1116) -->
213235
<!-- Empty PHP statements (;;) -->
214236
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
215237

216-
<!-- SonarQube rule coverage (php:S1186, php:S905) -->
217238
<!-- Empty catch/if/else bodies -->
218239
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
219240

220-
<!-- SonarQube rule coverage (php:S1121) -->
221241
<!-- Assignment in condition -->
222242
<rule ref="Generic.CodeAnalysis.AssignmentInCondition"/>
223243

224-
<!-- SonarQube rule coverage (php:S1145) -->
225244
<!-- if (true) / if (false) unconditional -->
226245
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
227246

228-
<!-- SonarQube rule coverage (php:S1185) -->
229247
<!-- Useless overriding methods that just call parent -->
230248
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
231249

232-
<!-- SonarQube rule coverage (php:S1110) -->
233250
<!-- Unnecessary parentheses -->
234251
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing"/>
235252

236-
<!-- SonarQube rule coverage (php:S1134) -->
237253
<!-- FIXME comments -->
238254
<rule ref="Generic.Commenting.Fixme"/>
239255

240-
<!-- SonarQube rule coverage (php:S1135) -->
241256
<!-- TODO comments -->
242257
<rule ref="Generic.Commenting.Todo"/>
243258

244-
<!-- SonarQube rule coverage (php:S125) -->
245259
<!-- Commented-out code -->
246260
<rule ref="Squiz.PHP.CommentedOutCode">
247261
<properties>
248262
<property name="maxPercentage" value="35"/>
249263
</properties>
250264
</rule>
251265

252-
<!-- SonarQube rule coverage (php:S1763, php:S881) -->
253266
<!-- Dead/non-executable code after return/throw/etc -->
254267
<rule ref="Squiz.PHP.NonExecutableCode"/>
255268

256-
<!-- SonarQube rule coverage (php:S139) -->
257269
<!-- Inline comments after statements -->
258270
<rule ref="Squiz.Commenting.PostStatementComment"/>
259271

260-
<!-- SonarQube rule coverage (php:S1788) -->
261272
<!-- Default parameter values must not follow non-default params -->
262273
<rule ref="PEAR.Functions.ValidDefaultValue"/>
263274

264-
<!-- SonarQube rule coverage (php:S907) -->
265275
<!-- Discourage goto -->
266276
<rule ref="Generic.PHP.DiscourageGoto"/>
267277

268-
<!-- SonarQube rule coverage (php:S2068) -->
269-
<!-- No hardcoded credentials / passwords in code -->
278+
<!-- Forbidden/dangerous functions (e.g. eval, var_dump, sizeof → configure as needed) -->
270279
<rule ref="Generic.PHP.ForbiddenFunctions"/>
271280

272-
<!-- SonarQube rule coverage (php:S1192) -->
273281
<!-- Unnecessary string concatenation -->
274282
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
275283

276-
<!-- SonarQube rule coverage (php:S1301) -->
277-
<!-- Single-case switch statements -->
284+
<!-- Jumbled loop incrementers (e.g. same variable in nested for-loops) -->
278285
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
279286

280-
<!-- SonarQube rule coverage (php:S1155, php:S3699) -->
281287
<!-- Duplicate class names -->
282288
<rule ref="Generic.Classes.DuplicateClassName"/>
283289

284-
<!-- SonarQube rule coverage (php:S2612) -->
285290
<!-- No silenced errors (@) -->
286291
<rule ref="Generic.PHP.NoSilencedErrors"/>
287292

0 commit comments

Comments
 (0)