phpcs.xml.dist 14.7 KB
Newer Older
1 2 3 4
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="drupal_core">
  <description>Default PHP CodeSniffer configuration for Drupal core.</description>
  <file>.</file>
5 6 7 8 9
  <file>scripts/drupal.sh</file>
  <file>scripts/password-hash.sh</file>
  <file>scripts/rebuild_token_calculator.sh</file>
  <file>scripts/run-tests.sh</file>
  <file>scripts/update-countries.sh</file>
10
  <arg name="extensions" value="inc,install,module,php,profile,test,theme,yml"/>
11 12 13

  <!--Exclude third party code.-->
  <exclude-pattern>./assets/vendor/*</exclude-pattern>
14 15 16
  <!--Exclude folders used by common frontend tools. These folders match the file_scan_ignore_directories setting in default.settings.php-->
  <exclude-pattern>*/node_modules/*</exclude-pattern>
  <exclude-pattern>*/bower_components/*</exclude-pattern>
17 18 19 20

  <!--Exclude test files that are intentionally empty, or intentionally violate coding standards.-->
  <exclude-pattern>./modules/system/tests/fixtures/HtaccessTest</exclude-pattern>

21 22 23 24
  <!-- Exclude third-party code maintained within core that does not follow our standards. -->
  <!-- @todo This rule may be removed when https://www.drupal.org/node/1848264 is resolved. -->
  <exclude-pattern>./core/lib/Drupal/Component/Diff/</exclude-pattern>

25 26
  <!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
  <!-- Drupal sniffs -->
27
  <rule ref="Drupal.Arrays.Array">
28
    <!-- Sniff for these errors: CommaLastItem -->
29 30 31
    <exclude name="Drupal.Arrays.Array.ArrayClosingIndentation"/>
    <exclude name="Drupal.Arrays.Array.ArrayIndentation"/>
    <exclude name="Drupal.Arrays.Array.LongLineDeclaration"/>
32
  </rule>
33 34
  <rule ref="Drupal.Classes.ClassCreateInstance"/>
  <rule ref="Drupal.Classes.ClassDeclaration"/>
35
  <rule ref="Drupal.Classes.ClassFileName"/>
36 37 38 39 40 41 42
  <rule ref="Drupal.Classes.FullyQualifiedNamespace"/>
  <rule ref="Drupal.Classes.InterfaceName"/>
  <rule ref="Drupal.Classes.UnusedUseStatement"/>
  <rule ref="Drupal.Classes.UseLeadingBackslash"/>
  <rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/>
  <rule ref="Drupal.CSS.ColourDefinition"/>
  <rule ref="Drupal.Commenting.ClassComment">
43 44
    <exclude name="Drupal.Commenting.ClassComment.Missing"/>
  </rule>
45
  <rule ref="Drupal.Commenting.DataTypeNamespace"/>
46
  <rule ref="Drupal.Commenting.Deprecated"/>
47
  <rule ref="Drupal.Commenting.DocComment">
48
    <!-- Sniff for these errors: SpacingAfterTagGroup, WrongEnd, SpacingBetween,
49
      ContentAfterOpen, SpacingBeforeShort, TagValueIndent, ShortStartSpace,
50
      SpacingAfter, LongNotCapital -->
51 52
    <!-- ParamNotFirst still not decided for PHPUnit-based tests.
      @see https://www.drupal.org/node/2253915 -->
53 54 55 56 57
    <exclude name="Drupal.Commenting.DocComment.ParamNotFirst"/>
    <exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/>
    <exclude name="Drupal.Commenting.DocComment.LongFullStop"/>
    <exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
    <exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
58 59
    <!-- TagsNotGrouped and ParamGroup have false-positives.
      @see https://www.drupal.org/node/2060925 -->
60
    <exclude name="Drupal.Commenting.DocComment.TagsNotGrouped"/>
61
    <exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
62 63 64 65
    <exclude name="Drupal.Commenting.DocComment.ShortSingleLine"/>
    <exclude name="Drupal.Commenting.DocComment.TagGroupSpacing"/>
    <exclude name="Drupal.Commenting.DocComment.MissingShort"/>
  </rule>
66 67 68
  <rule ref="Drupal.Commenting.DocCommentStar"/>
  <rule ref="Drupal.Commenting.FileComment"/>
  <rule ref="Drupal.Commenting.FunctionComment">
69 70 71 72 73 74 75 76 77
    <exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
    <exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/>
    <exclude name="Drupal.Commenting.FunctionComment.InvalidTypeHint"/>
    <exclude name="Drupal.Commenting.FunctionComment.Missing"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingReturnType"/>
    <exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>
78
    <exclude name="Drupal.Commenting.FunctionComment.ParamMissingDefinition"/>
79 80
    <exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
  </rule>
81
  <rule ref="Drupal.Commenting.GenderNeutralComment" />
82
  <rule ref="Drupal.Commenting.VariableComment">
83
    <!-- Sniff for: DuplicateVar, EmptyVar, InlineVariableName -->
84
    <exclude name="Drupal.Commenting.VariableComment.IncorrectVarType"/>
85
    <exclude name="Drupal.Commenting.VariableComment.Missing"/>
86 87 88 89
    <exclude name="Drupal.Commenting.VariableComment.MissingVar"/>
    <exclude name="Drupal.Commenting.VariableComment.VarOrder"/>
    <exclude name="Drupal.Commenting.VariableComment.WrongStyle"/>
  </rule>
90
  <rule ref="Drupal.Commenting.InlineComment">
91
    <!-- Sniff for: NoSpaceBefore, WrongStyle -->
92 93 94 95 96 97
    <exclude name="Drupal.Commenting.InlineComment.DocBlock"/>
    <exclude name="Drupal.Commenting.InlineComment.InvalidEndChar"/>
    <exclude name="Drupal.Commenting.InlineComment.NotCapital"/>
    <exclude name="Drupal.Commenting.InlineComment.SpacingAfter"/>
    <exclude name="Drupal.Commenting.InlineComment.SpacingBefore"/>
  </rule>
98 99 100 101 102 103 104 105
  <rule ref="Drupal.Commenting.PostStatementComment"/>
  <rule ref="Drupal.ControlStructures.ElseIf"/>
  <rule ref="Drupal.ControlStructures.ControlSignature"/>
  <rule ref="Drupal.ControlStructures.InlineControlStructure"/>
  <rule ref="Drupal.Files.EndFileNewline"/>
  <rule ref="Drupal.Files.FileEncoding"/>
  <rule ref="Drupal.Files.TxtFileLineLength"/>
  <rule ref="Drupal.Formatting.MultiLineAssignment"/>
106
  <rule ref="Drupal.Formatting.MultipleStatementAlignment"/>
107 108 109 110 111 112 113 114 115
  <rule ref="Drupal.Formatting.SpaceInlineIf"/>
  <rule ref="Drupal.Formatting.SpaceUnaryOperator"/>
  <rule ref="Drupal.Functions.DiscouragedFunctions"/>
  <rule ref="Drupal.Functions.FunctionDeclaration"/>
  <rule ref="Drupal.InfoFiles.AutoAddedKeys"/>
  <rule ref="Drupal.InfoFiles.ClassFiles"/>
  <rule ref="Drupal.InfoFiles.DuplicateEntry"/>
  <rule ref="Drupal.InfoFiles.Required"/>
  <rule ref="Drupal.Methods.MethodDeclaration">
116 117 118 119
    <!-- Silence method name underscore warning which is covered already in
      Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps. -->
    <exclude name="Drupal.Methods.MethodDeclaration.Underscore"/>
  </rule>
120
  <rule ref="Drupal.NamingConventions.ValidVariableName">
catch's avatar
catch committed
121 122 123
    <!-- Sniff for: LowerStart -->
    <exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/>
  </rule>
124 125 126 127
  <rule ref="Drupal.Scope.MethodScope"/>
  <rule ref="Drupal.Semantics.EmptyInstall"/>
  <rule ref="Drupal.Semantics.FunctionAlias"/>
  <rule ref="Drupal.Semantics.FunctionT">
128 129 130
    <exclude name="Drupal.Semantics.FunctionT.NotLiteralString"/>
    <exclude name="Drupal.Semantics.FunctionT.ConcatString"/>
  </rule>
131 132 133 134 135 136
  <rule ref="Drupal.Semantics.FunctionWatchdog"/>
  <rule ref="Drupal.Semantics.InstallHooks"/>
  <rule ref="Drupal.Semantics.LStringTranslatable"/>
  <rule ref="Drupal.Semantics.PregSecurity"/>
  <rule ref="Drupal.Semantics.TInHookMenu"/>
  <rule ref="Drupal.Semantics.TInHookSchema"/>
137
  <rule ref="Drupal.Strings.UnnecessaryStringConcat"/>
138 139 140 141 142 143 144 145 146 147
  <rule ref="Drupal.WhiteSpace.CloseBracketSpacing"/>
  <rule ref="Drupal.WhiteSpace.Comma"/>
  <rule ref="Drupal.WhiteSpace.EmptyLines"/>
  <rule ref="Drupal.WhiteSpace.Namespace"/>
  <rule ref="Drupal.WhiteSpace.ObjectOperatorIndent"/>
  <rule ref="Drupal.WhiteSpace.ObjectOperatorSpacing"/>
  <rule ref="Drupal.WhiteSpace.OpenBracketSpacing"/>
  <rule ref="Drupal.WhiteSpace.OpenTagNewline"/>
  <rule ref="Drupal.WhiteSpace.ScopeClosingBrace"/>
  <rule ref="Drupal.WhiteSpace.ScopeIndent"/>
148

149
  <!-- Drupal Practice sniffs -->
150
  <rule ref="DrupalPractice.Commenting.ExpectedException"/>
151
  <rule ref="DrupalPractice.General.ExceptionT"/>
152

153
  <!-- Generic sniffs -->
154
  <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
155
  <rule ref="Generic.CodeAnalysis.EmptyPHPStatement" />
156
  <rule ref="Generic.Files.ByteOrderMark"/>
157
  <rule ref="Generic.Files.LineEndings"/>
158
  <rule ref="Generic.Formatting.SpaceAfterCast"/>
159
  <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
160 161 162 163 164
  <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
    <properties>
      <property name="checkClosures" value="true"/>
    </properties>
  </rule>
165
  <rule ref="Generic.NamingConventions.ConstructorName"/>
166 167 168
  <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
  <rule ref="Generic.PHP.DeprecatedFunctions"/>
  <rule ref="Generic.PHP.DisallowShortOpenTag"/>
169
  <rule ref="Generic.PHP.LowerCaseKeyword"/>
170
  <rule ref="Generic.PHP.UpperCaseConstant"/>
171
  <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
172

173 174
  <!-- Internal sniffs -->
  <rule ref="Internal.NoCodeFound">
175 176
    <!-- No PHP code in *.yml -->
    <exclude-pattern>*.yml</exclude-pattern>
177 178
  </rule>

179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
  <!-- MySource sniffs -->
  <rule ref="MySource.Debug.DebugCode"/>

  <!-- PEAR sniffs -->
  <rule ref="PEAR.Files.IncludingFile"/>
  <!-- Disable some error messages that we do not want. -->
  <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseInclude">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseRequire">
    <severity>0</severity>
  </rule>
197
  <rule ref="PEAR.Functions.ValidDefaultValue"/>
198

199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
  <!-- PEAR sniffs -->
  <rule ref="PEAR.Functions.FunctionCallSignature"/>
  <!-- The sniffs inside PEAR.Functions.FunctionCallSignature silenced below are
    also silenced in Drupal CS' ruleset.xml. The code below is a 1-on-1 copy
    from that file. -->
  <!-- Disable some error messages that we already cover. -->
  <rule ref="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket">
    <severity>0</severity>
  </rule>
  <!-- Disable some error messages that we do not want. -->
  <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
    <severity>0</severity>
  </rule>
215 216 217
  <rule ref="PEAR.Functions.FunctionCallSignature.OpeningIndent">
    <severity>0</severity>
  </rule>
218 219 220 221 222 223 224 225 226 227
  <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
    <severity>0</severity>
  </rule>

alexpott's avatar
alexpott committed
228 229 230 231
  <!-- PSR-2 sniffs -->
  <rule ref="PSR2.Classes.PropertyDeclaration">
    <exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
  </rule>
232
  <rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
233 234 235
  <rule ref="PSR2.Namespaces.UseDeclaration">
    <exclude name="PSR2.Namespaces.UseDeclaration.UseAfterNamespace"/>
  </rule>
alexpott's avatar
alexpott committed
236

237
  <!-- Squiz sniffs -->
238
  <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
  <rule ref="Squiz.Arrays.ArrayDeclaration">
    <exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
    <exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
  </rule>
  <!-- Disable some error messages that we do not want. -->
  <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.NotLowerCase">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
    <severity>0</severity>
  </rule>
277
  <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
278 279 280 281 282 283 284 285 286 287
  <!-- Disable some error messages that we already cover. -->
  <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose">
    <severity>0</severity>
  </rule>
288 289 290 291 292 293 294 295
  <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
  <!-- Disable some error messages that we already cover. -->
  <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
    <severity>0</severity>
  </rule>
296
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace">
    <severity>0</severity>
  </rule>
  <!-- Standard yet to be finalized on this (https://www.drupal.org/node/1539712). -->
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.Indent">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine">
    <severity>0</severity>
  </rule>
313 314 315 316 317 318 319 320
  <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
    <properties>
      <property name="equalsSpacing" value="1"/>
    </properties>
  </rule>
  <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeArg">
    <severity>0</severity>
  </rule>
321
  <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
322 323 324 325 326
  <rule ref="Squiz.Strings.ConcatenationSpacing">
    <properties>
      <property name="spacing" value="1"/>
      <property name="ignoreNewlines" value="true"/>
    </properties>
327
  </rule>
328 329 330 331 332
  <rule ref="Squiz.WhiteSpace.FunctionSpacing">
    <properties>
      <property name="spacing" value="1"/>
    </properties>
  </rule>
333
  <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
334 335 336 337 338
  <rule ref="Squiz.WhiteSpace.OperatorSpacing">
    <properties>
      <property name="ignoreNewlines" value="true"/>
    </properties>
  </rule>
339
  <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
340
  <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
341 342 343

  <!-- Zend sniffs -->
  <rule ref="Zend.Files.ClosingTag"/>
344

345
</ruleset>