1 <?xml version="1.0" encoding="UTF-8"?>
2 <ruleset name="drupal_core">
3 <description>Default PHP CodeSniffer configuration for Drupal core.</description>
5 <arg name="extensions" value="inc,install,module,php,profile,test,theme"/>
7 <!--Exclude third party code.-->
8 <exclude-pattern>./assets/vendor/*</exclude-pattern>
10 <!--Exclude test files that are intentionally empty, or intentionally violate coding standards.-->
11 <exclude-pattern>./modules/system/tests/fixtures/HtaccessTest</exclude-pattern>
13 <!-- Exclude third-party code maintained within core that does not follow our standards. -->
14 <!-- @todo This rule may be removed when https://www.drupal.org/node/1848264 is resolved. -->
15 <exclude-pattern>./core/lib/Drupal/Component/Diff/</exclude-pattern>
17 <!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
18 <!-- Drupal sniffs -->
19 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Array/DisallowLongArraySyntaxSniff.php"/>
20 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/ClassCreateInstanceSniff.php"/>
21 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php"/>
22 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php"/>
23 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/InterfaceNameSniff.php"/>
24 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/UnusedUseStatementSniff.php"/>
25 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.php"/>
26 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php"/>
27 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php"/>
28 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php">
29 <exclude name="Drupal.Commenting.ClassComment.Missing"/>
31 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php">
32 <!-- Sniff for these errors: SpacingAfterTagGroup, WrongEnd, SpacingBetween,
33 ContentAfterOpen, SpacingBeforeShort, TagValueIndent, ShortStartSpace,
35 <exclude name="Drupal.Commenting.DocComment.LongNotCapital"/>
36 <!-- ParamNotFirst still not decided for PHPUnit-based tests.
37 @see https://www.drupal.org/node/2253915 -->
38 <exclude name="Drupal.Commenting.DocComment.ParamNotFirst"/>
39 <exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/>
40 <exclude name="Drupal.Commenting.DocComment.LongFullStop"/>
41 <exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
42 <exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
43 <!-- TagsNotGrouped and ParamGroup have false-positives.
44 @see https://www.drupal.org/node/2060925 -->
45 <exclude name="Drupal.Commenting.DocComment.TagsNotGrouped"/>
46 <exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
47 <exclude name="Drupal.Commenting.DocComment.ShortSingleLine"/>
48 <exclude name="Drupal.Commenting.DocComment.TagGroupSpacing"/>
49 <exclude name="Drupal.Commenting.DocComment.MissingShort"/>
51 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php"/>
52 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php"/>
53 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php">
54 <exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
55 <exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/>
56 <exclude name="Drupal.Commenting.FunctionComment.InvalidTypeHint"/>
57 <exclude name="Drupal.Commenting.FunctionComment.Missing"/>
58 <exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
59 <exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
60 <exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
61 <exclude name="Drupal.Commenting.FunctionComment.MissingReturnType"/>
62 <exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>
63 <exclude name="Drupal.Commenting.FunctionComment.ParamMissingDefinition"/>
64 <exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
66 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php">
67 <!-- Sniff for: NoSpaceBefore -->
68 <exclude name="Drupal.Commenting.InlineComment.DocBlock"/>
69 <exclude name="Drupal.Commenting.InlineComment.InvalidEndChar"/>
70 <exclude name="Drupal.Commenting.InlineComment.NotCapital"/>
71 <exclude name="Drupal.Commenting.InlineComment.SpacingAfter"/>
72 <exclude name="Drupal.Commenting.InlineComment.SpacingBefore"/>
73 <exclude name="Drupal.Commenting.InlineComment.WrongStyle"/>
75 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php"/>
76 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php"/>
77 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php"/>
78 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php"/>
79 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php"/>
80 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php"/>
81 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php"/>
82 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php"/>
83 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php"/>
84 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Functions/FunctionDeclarationSniff.php"/>
85 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php"/>
86 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php"/>
87 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php"/>
88 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php"/>
89 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Methods/MethodDeclarationSniff.php">
90 <!-- Silence method name underscore warning which is covered already in
91 Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps. -->
92 <exclude name="Drupal.Methods.MethodDeclaration.Underscore"/>
94 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php">
95 <!-- Sniff for: LowerStart -->
96 <exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/>
98 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php"/>
99 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php"/>
100 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php"/>
101 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php">
102 <exclude name="Drupal.Semantics.FunctionT.NotLiteralString"/>
103 <exclude name="Drupal.Semantics.FunctionT.ConcatString"/>
105 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php"/>
106 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php"/>
107 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php"/>
108 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php"/>
109 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php"/>
110 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php"/>
111 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php"/>
112 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php"/>
113 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/NamespaceSniff.php"/>
114 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php"/>
115 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php"/>
116 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php"/>
117 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php"/>
118 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/OperatorSpacingSniff.php"/>
119 <rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php"/>
121 <!-- Drupal Practice sniffs -->
122 <rule ref="../vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php"/>
124 <!-- Generic sniffs -->
125 <rule ref="Generic.Files.ByteOrderMark"/>
126 <rule ref="Generic.Files.LineEndings"/>
127 <rule ref="Generic.Formatting.SpaceAfterCast"/>
128 <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
129 <rule ref="Generic.NamingConventions.ConstructorName"/>
130 <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
131 <rule ref="Generic.PHP.DeprecatedFunctions"/>
132 <rule ref="Generic.PHP.DisallowShortOpenTag"/>
133 <rule ref="Generic.PHP.LowerCaseKeyword" />
134 <rule ref="Generic.PHP.UpperCaseConstant"/>
135 <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
137 <!-- MySource sniffs -->
138 <rule ref="MySource.Debug.DebugCode"/>
141 <rule ref="PEAR.Files.IncludingFile"/>
142 <!-- Disable some error messages that we do not want. -->
143 <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
144 <severity>0</severity>
146 <rule ref="PEAR.Files.IncludingFile.UseInclude">
147 <severity>0</severity>
149 <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
150 <severity>0</severity>
152 <rule ref="PEAR.Files.IncludingFile.UseRequire">
153 <severity>0</severity>
155 <rule ref="PEAR.Functions.ValidDefaultValue"/>
157 <!-- PSR-2 sniffs -->
158 <rule ref="PSR2.Classes.PropertyDeclaration">
159 <exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
162 <!-- Squiz sniffs -->
163 <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
164 <rule ref="Squiz.Arrays.ArrayDeclaration">
165 <exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
166 <exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
168 <!-- Disable some error messages that we do not want. -->
169 <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
170 <severity>0</severity>
172 <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
173 <severity>0</severity>
175 <rule ref="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline">
176 <severity>0</severity>
178 <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
179 <severity>0</severity>
181 <rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
182 <severity>0</severity>
184 <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
185 <severity>0</severity>
187 <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
188 <severity>0</severity>
190 <rule ref="Squiz.Arrays.ArrayDeclaration.NotLowerCase">
191 <severity>0</severity>
193 <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
194 <severity>0</severity>
196 <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
197 <severity>0</severity>
199 <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
200 <severity>0</severity>
202 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
203 <!-- Disable some error messages that we already cover. -->
204 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
205 <severity>0</severity>
207 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen">
208 <severity>0</severity>
210 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose">
211 <severity>0</severity>
213 <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
214 <!-- Disable some error messages that we already cover. -->
215 <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
216 <severity>0</severity>
218 <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
219 <severity>0</severity>
221 <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
222 <rule ref="Squiz.Strings.ConcatenationSpacing">
224 <property name="spacing" value="1"/>
225 <property name="ignoreNewlines" value="true"/>
230 <rule ref="Zend.Files.ClosingTag"/>