phpcs.xml.dist 13 KB

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