Skip to content

Commit 8d03780

Browse files
angelakuznetsovacodyfinegan
authored andcommitted
Update codesniffer ruleset
1 parent fa72a11 commit 8d03780

1 file changed

Lines changed: 39 additions & 31 deletions

File tree

src/Standards/Totara/ruleset.xml

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
<rule ref="Generic.Classes.OpeningBraceSameLine"/>
6969
<rule ref="Totara.NamingConventions.ValidClassName"/>
7070

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

@@ -87,7 +85,43 @@
8785

8886
<!-- 4.4 Methods/Functions -->
8987

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

92126
<!-- Visibility MUST be declared on all methods. -->
93127
<rule ref="Squiz.Scope.MethodScope"/>
@@ -197,91 +231,65 @@
197231
<property name="absoluteNestingLevel" value="10"/>
198232
</properties>
199233
</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>
207234

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

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

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

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

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

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

232-
<!-- SonarQube rule coverage (php:S1110) -->
233253
<!-- Unnecessary parentheses -->
234254
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing"/>
235255

236-
<!-- SonarQube rule coverage (php:S1134) -->
237256
<!-- FIXME comments -->
238257
<rule ref="Generic.Commenting.Fixme"/>
239258

240-
<!-- SonarQube rule coverage (php:S1135) -->
241259
<!-- TODO comments -->
242260
<rule ref="Generic.Commenting.Todo"/>
243261

244-
<!-- SonarQube rule coverage (php:S125) -->
245262
<!-- Commented-out code -->
246263
<rule ref="Squiz.PHP.CommentedOutCode">
247264
<properties>
248265
<property name="maxPercentage" value="35"/>
249266
</properties>
250267
</rule>
251268

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

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

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

264-
<!-- SonarQube rule coverage (php:S907) -->
265278
<!-- Discourage goto -->
266279
<rule ref="Generic.PHP.DiscourageGoto"/>
267280

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

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

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

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

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

0 commit comments

Comments
 (0)