1 <?xml version="1.0" encoding="UTF-8"?>
2 <ruleset name="drupal_core">
3 <description>Default PHP CodeSniffer configuration for Drupal core.</description>
5 <file>scripts/drupal.sh</file>
6 <file>scripts/password-hash.sh</file>
7 <file>scripts/rebuild_token_calculator.sh</file>
8 <file>scripts/run-tests.sh</file>
9 <file>scripts/update-countries.sh</file>
10 <arg name="extensions" value="inc,install,module,php,profile,test,theme,yml"/>
12 <!--Exclude third party code.-->
13 <exclude-pattern>./assets/vendor/*</exclude-pattern>
14 <!--Exclude folders used by common frontend tools. These folders match the file_scan_ignore_directories setting in default.settings.php-->
15 <exclude-pattern>*/node_modules/*</exclude-pattern>
16 <exclude-pattern>*/bower_components/*</exclude-pattern>
18 <!--Exclude test files that are intentionally empty, or intentionally violate coding standards.-->
19 <exclude-pattern>./modules/system/tests/fixtures/HtaccessTest</exclude-pattern>
21 <!-- Exclude third-party code maintained within core that does not follow our standards. -->
22 <!-- @todo This rule may be removed when https://www.drupal.org/node/1848264 is resolved. -->
23 <exclude-pattern>./core/lib/Drupal/Component/Diff/</exclude-pattern>
25 <!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
26 <!-- Drupal sniffs -->
27 <rule ref="Drupal.Array.Array">
28 <!-- Sniff for these errors: CommaLastItem -->
29 <exclude name="Drupal.Array.Array.ArrayClosingIndentation"/>
30 <exclude name="Drupal.Array.Array.ArrayIndentation"/>
31 <exclude name="Drupal.Array.Array.LongLineDeclaration"/>
33 <rule ref="Drupal.Classes.ClassCreateInstance"/>
34 <rule ref="Drupal.Classes.ClassDeclaration"/>
35 <rule ref="Drupal.Classes.FullyQualifiedNamespace"/>
36 <rule ref="Drupal.Classes.InterfaceName"/>
37 <rule ref="Drupal.Classes.UnusedUseStatement"/>
38 <rule ref="Drupal.Classes.UseLeadingBackslash"/>
39 <rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/>
40 <rule ref="Drupal.CSS.ColourDefinition"/>
41 <rule ref="Drupal.Commenting.ClassComment">
42 <exclude name="Drupal.Commenting.ClassComment.Missing"/>
44 <rule ref="Drupal.Commenting.DataTypeNamespace"/>
45 <rule ref="Drupal.Commenting.DocComment">
46 <!-- Sniff for these errors: SpacingAfterTagGroup, WrongEnd, SpacingBetween,
47 ContentAfterOpen, SpacingBeforeShort, TagValueIndent, ShortStartSpace,
48 SpacingAfter, LongNotCapital -->
49 <!-- ParamNotFirst still not decided for PHPUnit-based tests.
50 @see https://www.drupal.org/node/2253915 -->
51 <exclude name="Drupal.Commenting.DocComment.ParamNotFirst"/>
52 <exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/>
53 <exclude name="Drupal.Commenting.DocComment.LongFullStop"/>
54 <exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
55 <exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
56 <!-- TagsNotGrouped and ParamGroup have false-positives.
57 @see https://www.drupal.org/node/2060925 -->
58 <exclude name="Drupal.Commenting.DocComment.TagsNotGrouped"/>
59 <exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
60 <exclude name="Drupal.Commenting.DocComment.ShortSingleLine"/>
61 <exclude name="Drupal.Commenting.DocComment.TagGroupSpacing"/>
62 <exclude name="Drupal.Commenting.DocComment.MissingShort"/>
64 <rule ref="Drupal.Commenting.DocCommentStar"/>
65 <rule ref="Drupal.Commenting.FileComment"/>
66 <rule ref="Drupal.Commenting.FunctionComment">
67 <exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
68 <exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/>
69 <exclude name="Drupal.Commenting.FunctionComment.InvalidTypeHint"/>
70 <exclude name="Drupal.Commenting.FunctionComment.Missing"/>
71 <exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
72 <exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
73 <exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
74 <exclude name="Drupal.Commenting.FunctionComment.MissingReturnType"/>
75 <exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>
76 <exclude name="Drupal.Commenting.FunctionComment.ParamMissingDefinition"/>
77 <exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
79 <rule ref="Drupal.Commenting.VariableComment">
80 <!-- Sniff for: DuplicateVar, EmptyVar, InlineVariableName -->
81 <exclude name="Drupal.Commenting.VariableComment.IncorrectVarType"/>
82 <exclude name="Drupal.Commenting.VariableComment.MissingVar"/>
83 <exclude name="Drupal.Commenting.VariableComment.VarOrder"/>
84 <exclude name="Drupal.Commenting.VariableComment.WrongStyle"/>
86 <rule ref="Drupal.Commenting.InlineComment">
87 <!-- Sniff for: NoSpaceBefore, WrongStyle -->
88 <exclude name="Drupal.Commenting.InlineComment.DocBlock"/>
89 <exclude name="Drupal.Commenting.InlineComment.InvalidEndChar"/>
90 <exclude name="Drupal.Commenting.InlineComment.NotCapital"/>
91 <exclude name="Drupal.Commenting.InlineComment.SpacingAfter"/>
92 <exclude name="Drupal.Commenting.InlineComment.SpacingBefore"/>
94 <rule ref="Drupal.Commenting.PostStatementComment"/>
95 <rule ref="Drupal.ControlStructures.ElseIf"/>
96 <rule ref="Drupal.ControlStructures.ControlSignature"/>
97 <rule ref="Drupal.ControlStructures.InlineControlStructure"/>
98 <rule ref="Drupal.Files.EndFileNewline"/>
99 <rule ref="Drupal.Files.FileEncoding"/>
100 <rule ref="Drupal.Files.TxtFileLineLength"/>
101 <rule ref="Drupal.Formatting.MultiLineAssignment"/>
102 <rule ref="Drupal.Formatting.MultipleStatementAlignment"/>
103 <rule ref="Drupal.Formatting.SpaceInlineIf"/>
104 <rule ref="Drupal.Formatting.SpaceUnaryOperator"/>
105 <rule ref="Drupal.Functions.DiscouragedFunctions"/>
106 <rule ref="Drupal.Functions.FunctionDeclaration"/>
107 <rule ref="Drupal.InfoFiles.AutoAddedKeys"/>
108 <rule ref="Drupal.InfoFiles.ClassFiles"/>
109 <rule ref="Drupal.InfoFiles.DuplicateEntry"/>
110 <rule ref="Drupal.InfoFiles.Required"/>
111 <rule ref="Drupal.Methods.MethodDeclaration">
112 <!-- Silence method name underscore warning which is covered already in
113 Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps. -->
114 <exclude name="Drupal.Methods.MethodDeclaration.Underscore"/>
116 <rule ref="Drupal.NamingConventions.ValidVariableName">
117 <!-- Sniff for: LowerStart -->
118 <exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/>
120 <rule ref="Drupal.Scope.MethodScope"/>
121 <rule ref="Drupal.Semantics.EmptyInstall"/>
122 <rule ref="Drupal.Semantics.FunctionAlias"/>
123 <rule ref="Drupal.Semantics.FunctionT">
124 <exclude name="Drupal.Semantics.FunctionT.NotLiteralString"/>
125 <exclude name="Drupal.Semantics.FunctionT.ConcatString"/>
127 <rule ref="Drupal.Semantics.FunctionWatchdog"/>
128 <rule ref="Drupal.Semantics.InstallHooks"/>
129 <rule ref="Drupal.Semantics.LStringTranslatable"/>
130 <rule ref="Drupal.Semantics.PregSecurity"/>
131 <rule ref="Drupal.Semantics.TInHookMenu"/>
132 <rule ref="Drupal.Semantics.TInHookSchema"/>
133 <rule ref="Drupal.WhiteSpace.CloseBracketSpacing"/>
134 <rule ref="Drupal.WhiteSpace.Comma"/>
135 <rule ref="Drupal.WhiteSpace.EmptyLines"/>
136 <rule ref="Drupal.WhiteSpace.Namespace"/>
137 <rule ref="Drupal.WhiteSpace.ObjectOperatorIndent"/>
138 <rule ref="Drupal.WhiteSpace.ObjectOperatorSpacing"/>
139 <rule ref="Drupal.WhiteSpace.OpenBracketSpacing"/>
140 <rule ref="Drupal.WhiteSpace.OpenTagNewline"/>
141 <rule ref="Drupal.WhiteSpace.OperatorSpacing"/>
142 <rule ref="Drupal.WhiteSpace.ScopeClosingBrace"/>
143 <rule ref="Drupal.WhiteSpace.ScopeIndent"/>
145 <!-- Drupal Practice sniffs -->
146 <rule ref="DrupalPractice.Commenting.ExpectedException"/>
148 <!-- Generic sniffs -->
149 <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
150 <rule ref="Generic.Files.ByteOrderMark"/>
151 <rule ref="Generic.Files.LineEndings"/>
152 <rule ref="Generic.Formatting.SpaceAfterCast"/>
153 <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
154 <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
156 <property name="checkClosures" value="true"/>
159 <rule ref="Generic.NamingConventions.ConstructorName"/>
160 <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
161 <rule ref="Generic.PHP.DeprecatedFunctions"/>
162 <rule ref="Generic.PHP.DisallowShortOpenTag"/>
163 <rule ref="Generic.PHP.LowerCaseKeyword"/>
164 <rule ref="Generic.PHP.UpperCaseConstant"/>
165 <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
167 <!-- Internal sniffs -->
168 <rule ref="Internal.NoCodeFound">
169 <!-- No PHP code in *.yml -->
170 <exclude-pattern>*.yml</exclude-pattern>
173 <!-- MySource sniffs -->
174 <rule ref="MySource.Debug.DebugCode"/>
177 <rule ref="PEAR.Files.IncludingFile"/>
178 <!-- Disable some error messages that we do not want. -->
179 <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
180 <severity>0</severity>
182 <rule ref="PEAR.Files.IncludingFile.UseInclude">
183 <severity>0</severity>
185 <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
186 <severity>0</severity>
188 <rule ref="PEAR.Files.IncludingFile.UseRequire">
189 <severity>0</severity>
191 <rule ref="PEAR.Functions.ValidDefaultValue"/>
194 <rule ref="PEAR.Functions.FunctionCallSignature"/>
195 <!-- The sniffs inside PEAR.Functions.FunctionCallSignature silenced below are
196 also silenced in Drupal CS' ruleset.xml. The code below is a 1-on-1 copy
198 <!-- Disable some error messages that we already cover. -->
199 <rule ref="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket">
200 <severity>0</severity>
202 <rule ref="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket">
203 <severity>0</severity>
205 <!-- Disable some error messages that we do not want. -->
206 <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
207 <severity>0</severity>
209 <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
210 <severity>0</severity>
212 <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
213 <severity>0</severity>
215 <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
216 <severity>0</severity>
219 <!-- PSR-2 sniffs -->
220 <rule ref="PSR2.Classes.PropertyDeclaration">
221 <exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
223 <rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
224 <rule ref="PSR2.Namespaces.UseDeclaration">
225 <exclude name="PSR2.Namespaces.UseDeclaration.UseAfterNamespace"/>
228 <!-- Squiz sniffs -->
229 <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
230 <rule ref="Squiz.Arrays.ArrayDeclaration">
231 <exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
232 <exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
234 <!-- Disable some error messages that we do not want. -->
235 <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
236 <severity>0</severity>
238 <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
239 <severity>0</severity>
241 <rule ref="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline">
242 <severity>0</severity>
244 <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
245 <severity>0</severity>
247 <rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
248 <severity>0</severity>
250 <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
251 <severity>0</severity>
253 <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
254 <severity>0</severity>
256 <rule ref="Squiz.Arrays.ArrayDeclaration.NotLowerCase">
257 <severity>0</severity>
259 <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
260 <severity>0</severity>
262 <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
263 <severity>0</severity>
265 <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
266 <severity>0</severity>
268 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
269 <!-- Disable some error messages that we already cover. -->
270 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
271 <severity>0</severity>
273 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen">
274 <severity>0</severity>
276 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose">
277 <severity>0</severity>
279 <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
280 <!-- Disable some error messages that we already cover. -->
281 <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
282 <severity>0</severity>
284 <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
285 <severity>0</severity>
287 <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
288 <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
289 <severity>0</severity>
291 <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace">
292 <severity>0</severity>
294 <!-- Standard yet to be finalized on this (https://www.drupal.org/node/1539712). -->
295 <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing">
296 <severity>0</severity>
298 <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.Indent">
299 <severity>0</severity>
301 <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine">
302 <severity>0</severity>
304 <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
306 <property name="equalsSpacing" value="1"/>
309 <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeArg">
310 <severity>0</severity>
312 <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
313 <rule ref="Squiz.Strings.ConcatenationSpacing">
315 <property name="spacing" value="1"/>
316 <property name="ignoreNewlines" value="true"/>
319 <rule ref="Squiz.WhiteSpace.FunctionSpacing">
321 <property name="spacing" value="1"/>
324 <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
325 <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
326 <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
329 <rule ref="Zend.Files.ClosingTag"/>