This repository has been archived by the owner on Jan 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ruleset.xml
87 lines (70 loc) · 4.03 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
<?xml version="1.0"?>
<ruleset name="Wikibase">
<!-- This rule set includes all rules from the MediaWiki rule set, see
https://github.com/wikimedia/mediawiki-tools-codesniffer/blob/master/MediaWiki/ruleset.xml
-->
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<!-- Currently cannot replace Wikibase.Namespaces.UnusedUse because it does not understand
/* @var … */ with one asterisk. -->
<exclude name="MediaWiki.Classes.UnusedUseStatement" />
<!-- The function comment sniff is way to rigorous about way to many details that need
exceptions:
* It complains about missing documentation on fully self-explanatory function headers
with strict type hints.
* It complains about missing documentation if there is a proper @see tag.
* It complains about duplicate spaces in "@param <type> $<var>", but removing these
doesn't make the code easier to read.
* It does not understand "@param <type> [$optional,…]. -->
<exclude name="MediaWiki.Commenting.FunctionComment" />
<!-- We disagree with the idea of certain characters making comments "illegal" and blocking
patches from being merged. This behaves especially bad on code examples. -->
<exclude name="MediaWiki.Commenting.IllegalSingleLineComment" />
<!-- Starting a function's body with an empty line can be helpful after a very large header.
The code is not guaranteed to be easier to read if this is disallowed. -->
<exclude name="MediaWiki.WhiteSpace.DisallowEmptyLineFunctions" />
<!-- Even if we encourage to use a space in "function ()", we don't think this sniff should
block patches from being merged. -->
<exclude name="MediaWiki.WhiteSpace.SpaceAfterClosure" />
<!-- Even if we encourage to use spaces in comments, we don't think this sniff should block
patches from being merged. -->
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment" />
</rule>
<!-- NOTE: We purposely decided against additional Generic.CodeAnalysis.… sniffs, because they
all have possible exceptions, and are not meant to block patches from being merged. -->
<!-- Disallows any content outside of <?php … ?> tags. -->
<rule ref="Generic.Files.InlineHTML" />
<rule ref="Generic.Files.LineLength">
<properties>
<!-- The inherited "lineLimit" from the base MediaWiki rule set is 100. -->
<property name="absoluteLineLimit" value="140" />
</properties>
<!-- Exclude auto-generated files from the Translate extension, see magic-export.php. -->
<exclude-pattern>\.i18n\.magic\.php</exclude-pattern>
</rule>
<!-- NOTE: Never add the Generic.Metrics.… sniffs to this generic rule set, because these are
not about "code style", and the exact limits are highly disputable. -->
<rule ref="MediaWiki.NamingConventions.LowerCamelFunctionsName">
<!-- Exclude test methods like "testGivenInvalidInput_methodThrowsException". -->
<exclude-pattern>tests*Test*\.php</exclude-pattern>
</rule>
<!-- Disallows ?>. See http://www.php-fig.org/psr/psr-2/#files -->
<rule ref="PSR2.Files.ClosingTag" />
<!-- NOTE: We can not use the Squiz.Arrays.ArrayBracketSpacing sniff because it conflicts with
the MediaWiki style that encourages to use spaces inside brackets, see
https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript#Whitespace -->
<!-- Makes sure control structures like if ( … ), for ( …; …; … ) etc. properly use spaces. -->
<rule ref="Squiz.ControlStructures.ControlSignature" />
<rule ref="Squiz.Functions.GlobalFunction" />
<!-- NOTE: Do not add the Squiz.Strings.DoubleQuoteUsage sniff. Even if we encourage to prefer
single quotes, we don't think double quotes should block patches from being merged. -->
<!-- Enforces one empty line before and after each method in a class. -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<!-- The sniffs default is two empty lines. -->
<property name="spacing" value="1" />
</properties>
</rule>
<arg name="extensions" value="php" />
<arg name="encoding" value="UTF-8" />
<exclude-pattern type="relative">^extensions/</exclude-pattern>
</ruleset>