forked from AOEpeople/magento-coding-standard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruleset.xml
193 lines (168 loc) · 8.79 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?xml version="1.0"?>
<ruleset name="Ecg">
<description>ECG Coding Standard</description>
<!-- Exclude EcomDev_PHPUnit unit tests -->
<exclude-pattern>*/Test/*</exclude-pattern>
<!-- Exclude setup scripts from code sniffer - remove if you want to be really strict in your upgrade scripts -->
<exclude-pattern>*/data/*/data-</exclude-pattern>
<exclude-pattern>*/sql/*/mysql4-</exclude-pattern>
<exclude-pattern>*/sql/*/install-</exclude-pattern>
<exclude-pattern>*/sql/*/upgrade-</exclude-pattern>
<!-- exclude sub vendor folder -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- The closing ?> tag MUST be omitted from files containing only PHP. -->
<rule ref="Zend.Files.ClosingTag">
<exclude-pattern>*\.(?!phtml$)</exclude-pattern>
</rule>
<!-- Reports errors if the same class or interface name is used in multiple files. -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Related to this - only one Class or Interface Declaration per File -->
<rule ref="Generic.Files.OneClassPerFile"/>
<rule ref="Generic.Files.OneInterfacePerFile"/>
<!-- PHP code MUST use only UTF-8 without BOM. -->
<rule ref="Generic.Files.ByteOrderMark"/>
<!-- PHP files should contain an empty line at the end of the file -->
<rule ref="Generic.Files.EndFileNewline"/>
<!-- Tweak the line length limit -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="200"/>
<property name="absoluteLineLimit" value=""/>
</properties>
</rule>
<!-- Allow only unix file endings (newlines) -->
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\n"/>
</properties>
</rule>
<!-- Show Warnings for Comments of Unready Code, but dont set as error -->
<rule ref="Generic.Commenting.Fixme">
<severity>0</severity>
</rule>
<rule ref="Generic.Commenting.Todo">
<severity>0</severity>
</rule>
<!-- Detects empty statement. -->
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<!-- Detects for-loops that use a function call in the test expression. -->
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<!-- Detects incrementer jumbling ($i,$j,$k...) in for loops. -->
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<!-- Detects If Statements with single true/false values and no condition -->
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<!-- Detects unnecessary final modifiers inside of final classes. -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Detects unnecessary overriden methods that simply call their parent. -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Verifies that inline control statements are not present. -->
<rule ref="Generic.ControlStructures.InlineControlStructure">
<exclude-pattern>*\.(?!phtml$)</exclude-pattern>
</rule>
<!-- Disallow multiple Statements per Line -->
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<!-- PHP code MUST contain space after cast tokens -->
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<!-- PHP functions MUST NOT be too complex and should be refactored if so -->
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
<rule ref="Generic.Metrics.NestingLevel"/>
<!-- PHP constructor MUST be named __construct -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- PHP constants MUST be in upper case -->
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<!-- PHP code MUST NOT contain any character before the opening tag. Exclude Phtml Files. -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag">
<exclude-pattern>*\.(?!phtml$)</exclude-pattern>
</rule>
<!-- PHP code MUST NOT contain any short opening tag like <? instead of proper <?php -->
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<!-- PHP code MUST NOT contain alias functions that are kept in PHP for compatibility with older versions-->
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<!-- The PHP constants true, false, and null MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseConstant"/>
<!-- PHP keywords MUST be in lower case. I.e. const -->
<rule ref="Generic.PHP.LowerCaseKeyword"/>
<!-- PHP code MUST NOT contain silenced errors (@) -->
<rule ref="Generic.PHP.NoSilencedErrors"/>
<!-- Check for Usage of deprecated Function in current PHP Version -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Code MUST use an indent of 4 spaces -->
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
<!-- Code MUST NOT use tabs for indenting. -->
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<!-- Functions variables MUST NOT be passed by references -->
<rule ref="Generic.Functions.CallTimePassByReference"/>
<!-- Braces after function MUST be in newline -->
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
<!-- PHP constants and variables should be defined properly regarding underscores and correct Casing -->
<!-- Note that this excludes phtml files as frontend coding standard tells devs to use use leading underscore -->
<!-- PHP code MUST contain properly declared classes and functions -->
<rule ref="PEAR.Classes.ClassDeclaration"/>
<!-- PHP classes/interfaces MUST use start with a capital letter and must use the _ as separator -->
<rule ref="PEAR.NamingConventions.ValidClassName"/>
<!-- PHP code MUST NOT contain perl-style comments -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Correct Formatting of Control Signatures -->
<rule ref="PEAR.ControlStructures.ControlSignature"/>
<!-- Correct Formatting of Function Calls -->
<rule ref="PEAR.Functions.FunctionCallSignature"/>
<!-- Checks Function Parameters Declaration for Default Values -->
<rule ref="PEAR.Functions.ValidDefaultValue"/>
<!-- Checks Indentation of Object Method Chaining -->
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<!-- Checks correct Position of Closing Braces in Classes, Functions, Control Signatures... Exclude Phtml Files. -->
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace">
<exclude-pattern>*\.(?!phtml$)</exclude-pattern>
</rule>
<!-- Check Function Comments for correct Format -->
<rule ref="PEAR.Commenting.FunctionComment"/>
<!-- File Comments are not widely used in the Magento Community, but we want a Class Comment Block -->
<exclude name="PEAR.Commenting.FileComment"/>
<rule ref="Ecg.Commenting.ClassComment"/>
<!-- PHP code MUST NOT contain functions outside of classes -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Tests that the asterisks in a doc comment align correctly -->
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<!-- Checks Usage of Increment/Decrement Operators, i.e. $a -= 1; -->
<rule ref="Squiz.Operators.IncrementDecrementUsage"/>
<!-- Checks syntactical Usage of Logical Operators in Conditions -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Correct Scope Declaration of Variables inside Classes -->
<rule ref="Squiz.Scope.MemberVarScope"/>
<!-- Correct Scope Declaration of Methods inside Classes -->
<rule ref="Squiz.Scope.MethodScope"/>
<!-- Correct Usage of this in Static Members -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Correct Usage of echo and Formatting of strings to be echoed -->
<rule ref="Squiz.Strings.EchoedStrings">
<exclude-pattern>*\.(?!phtml$)</exclude-pattern>
</rule>
<!-- Checks Spacing around Logical Operators in Conditions -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- There MUST NOT be trailing whitespace at the end of non-blank lines. -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
<severity>0</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile">
<severity>0</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<severity>0</severity>
</rule>
<!-- Show Warnings on Discouraged Functions like error_log, print_r and var_dump -->
<rule ref="Squiz.PHP.DiscouragedFunctions">
<severity>0</severity>
</rule>
<!-- Eval is Evil -->
<rule ref="Squiz.PHP.Eval"/>
<!-- Dont use $GLOBALS -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Checks for Code that will never be Executed by bad Design -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
</ruleset>