]> git.openstreetmap.org Git - nominatim.git/blob - phpcs.xml
Merge pull request #977 from lonvia/fix-byteswap-check
[nominatim.git] / phpcs.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   <exclude-pattern>./lib/template/*html*</exclude-pattern>
12   <exclude-pattern>./lib/template/includes/</exclude-pattern>
13   <exclude-pattern>./module/</exclude-pattern>
14   <exclude-pattern>./website/css</exclude-pattern>
15   <exclude-pattern>./website/js</exclude-pattern>
16
17   <rule ref="Generic.Files.LineLength">
18     <properties>
19      <property name="lineLimit" value="194"/>
20      <property name="absoluteLineLimit" value="194"/>
21     </properties>
22   </rule>
23
24
25   <!-- "A file should declare new symbols (classes, functions, constants, etc.) and cause no
26     other side effects, or it should execute logic with side effects, but should not do both."
27     ... we have too many script and includes to be able to enforce that.
28      -->
29   <rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
30     <severity>0</severity>
31   </rule>
32
33
34
35   <!-- eval, system, etc -->
36   <rule ref="Generic.PHP.ForbiddenFunctions">
37     <properties>
38       <property name="forbiddenFunctions" type="array" value="sizeof=>count,delete=>unset,print=>echo,create_function=>null,eval=>null"/>
39     </properties>
40   </rule>
41
42   <!-- **************************************************************
43        DOCUMENTATION
44        ************************************************************** -->
45
46   <rule ref="PEAR.Commenting.FunctionComment.Missing">
47     <severity>0</severity>
48   </rule>
49
50
51
52
53   <!-- **************************************************************
54        COMMENTS
55        ************************************************************** -->
56
57   <!-- any comments in the lines before function() are better than forcing
58        a PHPdoc style right now -->
59   <rule ref="PEAR.Commenting.FunctionComment.WrongStyle">
60     <severity>0</severity>
61   </rule>
62
63   <!-- We allow comments after statements -->
64   <rule ref="Squiz.Commenting.PostStatementComment.Found">
65     <severity>0</severity>
66   </rule>
67   <!-- ... even without space e.g. //some words -->
68   <rule ref="Squiz.Commenting.InlineComment.NoSpaceBefore">
69     <severity>0</severity>
70   </rule>
71   <!-- blank lines after inline comments are fine -->
72   <rule ref="Squiz.Commenting.InlineComment.SpacingAfter">
73     <severity>0</severity>
74   </rule>
75
76   <!-- Comments don't have to start uppercase -->
77   <rule ref="Squiz.Commenting.InlineComment.NotCapital">
78     <severity>0</severity>
79   </rule>
80   <!-- Comments don't have to end with one of .!? -->
81   <rule ref="Squiz.Commenting.InlineComment.InvalidEndChar">
82     <severity>0</severity>
83   </rule>
84   <!-- Empty comments are fine -->
85   <rule ref="Squiz.Commenting.InlineComment.Empty">
86     <severity>0</severity>
87   </rule>
88
89
90
91
92   <!-- **************************************************************
93        INDENTATION, SPACING
94        ************************************************************** -->
95
96   <!-- Aligned looks nicer, but causes too many warnings currently -->
97   <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
98     <severity>0</severity>
99   </rule>
100
101
102
103
104
105
106
107   <!-- **************************************************************
108        VARIABLES
109        ************************************************************** -->
110
111   <!-- CONST_this_var is fine, we don't need ConstThisVar -->
112   <rule ref="Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase">
113     <severity>0</severity>
114   </rule>
115
116   <!-- simply disagree with "Each line in an array declaration must end in a comma" -->
117   <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
118     <severity>0</severity>
119   </rule>
120   <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
121     <severity>0</severity>
122   </rule>
123
124   <!-- We allow "$abc = array($aPoint[1], $aPoint[2])" -->
125   <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
126     <severity>0</severity>
127   </rule>
128
129   <!-- array() instead of [] for initialisation -->
130   <rule ref="Generic.Arrays.DisallowShortArraySyntax.Found" />
131
132
133
134
135   <!-- **************************************************************
136        STRING QUOTING
137        ************************************************************** -->
138
139   <!-- Prefer single quoted strings -->
140   <rule ref="Squiz.Strings.DoubleQuoteUsage" />
141
142   <!-- We allow variabled inside double-quoted strings "abc $somevar" -->
143   <rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
144     <severity>0</severity>
145   </rule>
146
147
148
149
150
151   <!-- **************************************************************
152        CONTROL STRUCTURES
153        ************************************************************** -->
154
155   <!-- we allow "if (a) echo 'b'" without brackets -->
156   <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed">
157     <severity>0</severity>
158   </rule>
159
160   <!-- We allow "if (a)". No need for "if (a === TRUE)" -->
161   <rule ref="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue">
162     <severity>0</severity>
163   </rule>
164   <!-- ... same for "if (!a)" -->
165   <rule ref="Squiz.Operators.ComparisonOperatorUsage.NotAllowed">
166     <severity>0</severity>
167   </rule>
168
169
170
171 </ruleset>