]> git.openstreetmap.org Git - nominatim.git/blob - php-lint-rules.xml
PSR2 fixes for /wikidata and /tests-php directories
[nominatim.git] / php-lint-rules.xml
1 <?xml version="1.0"?>
2 <ruleset name="Nominatim Standard">
3
4   <description>Nominatim coding standard</description>
5
6   <!-- based on another standard, you can find it here -->
7   <!-- /usr/share/php/PHP/CodeSniffer/Standards/PSR2/ruleset.xml -->
8   <!-- https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/PSR2/ruleset.xml -->
9   <rule ref="PSR2"/>
10
11
12
13
14   <!-- currently 300 warnings, we set a limit later -->
15   <rule ref="Generic.Files.LineLength">
16     <properties>
17      <property name="lineLimit" value="9999"/>
18      <property name="absoluteLineLimit" value="0"/>
19     </properties>
20   </rule>
21
22
23
24   <!-- **************************************************************
25        DOCUMENTATION
26        ************************************************************** -->
27
28   <rule ref="PEAR.Commenting.FileComment.Missing">
29     <severity>0</severity>
30   </rule>
31   <rule ref="PEAR.Commenting.ClassComment.Missing">
32     <severity>0</severity>
33   </rule>    
34   <rule ref="PEAR.Commenting.FunctionComment.Missing">
35     <severity>0</severity>
36   </rule>
37
38
39
40
41   <!-- **************************************************************
42        COMMENTS
43        ************************************************************** -->
44
45   <!-- We allow comments after statements -->
46   <rule ref="Squiz.Commenting.PostStatementComment.Found">
47     <severity>0</severity>
48   </rule>
49   <!-- ... even without space e.g. //some words -->
50   <rule ref="Squiz.Commenting.InlineComment.NoSpaceBefore">
51     <severity>0</severity>
52   </rule>
53
54   <!-- Comments don't have to start uppercase -->
55   <rule ref="Squiz.Commenting.InlineComment.NotCapital">
56     <severity>0</severity>
57   </rule>
58   <!-- Comments don't have to end with one of .!? -->
59   <rule ref="Squiz.Commenting.InlineComment.InvalidEndChar">
60     <severity>0</severity>
61   </rule>
62
63   <!-- we don't need '} // functionname()' at end of large blocks -->
64   <rule ref="Squiz.Commenting.ClosingDeclarationComment.Missing">
65     <severity>0</severity>
66   </rule>
67   <!-- .. same for conditions -->
68   <rule ref="Squiz.Commenting.LongConditionClosingComment.Missing">
69     <severity>0</severity>
70   </rule>
71
72
73
74
75
76   <!-- **************************************************************
77        INDENTATION, SPACING
78        ************************************************************** -->
79
80   <!-- We don't need 2 blank lines after function -->
81   <rule ref="Squiz.WhiteSpace.FunctionSpacing.After">
82     <severity>0</severity>
83   </rule>
84
85   <!-- Aligned looks nicer, but causes too many warnings currently -->
86   <rule ref="Generic.Formatting.MultipleStatementAlignment.NotSame">
87     <severity>0</severity>
88   </rule>
89
90   <!-- Aligned looks nicer, but causes too many warnings currently -->
91   <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
92     <severity>0</severity>
93   </rule>
94
95
96
97
98
99
100
101   <!-- **************************************************************
102        VARIABLES
103        ************************************************************** -->
104
105   <!-- CONST_this_var is fine, we don't need ConstThisVar -->
106   <rule ref="Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase">
107     <severity>0</severity>
108   </rule>
109
110   <!-- simply disagree with "Each line in an array declaration must end in a comma" -->
111   <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
112     <severity>0</severity>
113   </rule>
114   <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
115     <severity>0</severity>
116   </rule>
117
118   <!-- We allow "$abc = array($aPoint[1], $aPoint[2])" -->
119   <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
120     <severity>0</severity>
121   </rule>
122
123
124
125
126   <!-- **************************************************************
127        CONTROL STRUCTURES
128        ************************************************************** -->
129
130   <!-- we allow "if (a) echo 'b'" without brackets -->
131   <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed">
132     <severity>0</severity>
133   </rule>
134   <rule ref="Generic.ControlStructures.InlineControlStructure.Discouraged">
135     <severity>0</severity>
136   </rule>
137   <rule ref="Squiz.PHP.DisallowInlineIf.Found">
138     <severity>0</severity>
139   </rule>
140
141   <!-- We allow "if (a)". No need for "if (a === TRUE)" -->
142   <rule ref="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue">
143     <severity>0</severity>
144   </rule>
145   <!-- ... same for "if (!a)" -->
146   <rule ref="Squiz.Operators.ComparisonOperatorUsage.NotAllowed">
147     <severity>0</severity>
148   </rule>
149
150   <!-- We allow
151               if (a)
152               {
153   -->
154   <rule ref="PEAR.ControlStructures.MultiLineCondition.NewlineBeforeOpenBrace">
155     <severity>0</severity>
156   </rule>
157   <!-- ... same -->
158   <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose">
159     <severity>0</severity>
160   </rule>
161   <!-- ... same for foreach/while etc -->
162   <rule ref="PEAR.ControlStructures.ControlSignature">
163     <severity>0</severity>
164   </rule>
165   <!-- ... same -->
166   <rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeClose">
167     <severity>0</severity>
168   </rule>
169
170
171 </ruleset>