phpcs.xml.dist 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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. <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"/>
  11. <!--Exclude third party code.-->
  12. <exclude-pattern>./assets/vendor/*</exclude-pattern>
  13. <!--Exclude test files that are intentionally empty, or intentionally violate coding standards.-->
  14. <exclude-pattern>./modules/system/tests/fixtures/HtaccessTest</exclude-pattern>
  15. <!-- Exclude third-party code maintained within core that does not follow our standards. -->
  16. <!-- @todo This rule may be removed when https://www.drupal.org/node/1848264 is resolved. -->
  17. <exclude-pattern>./core/lib/Drupal/Component/Diff/</exclude-pattern>
  18. <!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
  19. <!-- Drupal sniffs -->
  20. <rule ref="Drupal.Classes.ClassCreateInstance"/>
  21. <rule ref="Drupal.Classes.ClassDeclaration"/>
  22. <rule ref="Drupal.Classes.FullyQualifiedNamespace"/>
  23. <rule ref="Drupal.Classes.InterfaceName"/>
  24. <rule ref="Drupal.Classes.UnusedUseStatement"/>
  25. <rule ref="Drupal.Classes.UseLeadingBackslash"/>
  26. <rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/>
  27. <rule ref="Drupal.CSS.ColourDefinition"/>
  28. <rule ref="Drupal.Commenting.ClassComment">
  29. <exclude name="Drupal.Commenting.ClassComment.Missing"/>
  30. </rule>
  31. <rule ref="Drupal.Commenting.DataTypeNamespace"/>
  32. <rule ref="Drupal.Commenting.DocComment">
  33. <!-- Sniff for these errors: SpacingAfterTagGroup, WrongEnd, SpacingBetween,
  34. ContentAfterOpen, SpacingBeforeShort, TagValueIndent, ShortStartSpace,
  35. SpacingAfter -->
  36. <exclude name="Drupal.Commenting.DocComment.LongNotCapital"/>
  37. <!-- ParamNotFirst still not decided for PHPUnit-based tests.
  38. @see https://www.drupal.org/node/2253915 -->
  39. <exclude name="Drupal.Commenting.DocComment.ParamNotFirst"/>
  40. <exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/>
  41. <exclude name="Drupal.Commenting.DocComment.LongFullStop"/>
  42. <exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
  43. <exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
  44. <!-- TagsNotGrouped and ParamGroup have false-positives.
  45. @see https://www.drupal.org/node/2060925 -->
  46. <exclude name="Drupal.Commenting.DocComment.TagsNotGrouped"/>
  47. <exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
  48. <exclude name="Drupal.Commenting.DocComment.ShortSingleLine"/>
  49. <exclude name="Drupal.Commenting.DocComment.TagGroupSpacing"/>
  50. <exclude name="Drupal.Commenting.DocComment.MissingShort"/>
  51. </rule>
  52. <rule ref="Drupal.Commenting.DocCommentStar"/>
  53. <rule ref="Drupal.Commenting.FileComment"/>
  54. <rule ref="Drupal.Commenting.FunctionComment">
  55. <exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
  56. <exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/>
  57. <exclude name="Drupal.Commenting.FunctionComment.InvalidTypeHint"/>
  58. <exclude name="Drupal.Commenting.FunctionComment.Missing"/>
  59. <exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
  60. <exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
  61. <exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
  62. <exclude name="Drupal.Commenting.FunctionComment.MissingReturnType"/>
  63. <exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>
  64. <exclude name="Drupal.Commenting.FunctionComment.ParamMissingDefinition"/>
  65. <exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
  66. </rule>
  67. <rule ref="Drupal.Commenting.VariableComment">
  68. <!-- Sniff for: DuplicateVar, EmptyVar, InlineVariableName -->
  69. <exclude name="Drupal.Commenting.VariableComment.IncorrectVarType"/>
  70. <exclude name="Drupal.Commenting.VariableComment.MissingVar"/>
  71. <exclude name="Drupal.Commenting.VariableComment.VarOrder"/>
  72. <exclude name="Drupal.Commenting.VariableComment.WrongStyle"/>
  73. </rule>
  74. <rule ref="Drupal.Commenting.InlineComment">
  75. <!-- Sniff for: NoSpaceBefore, WrongStyle -->
  76. <exclude name="Drupal.Commenting.InlineComment.DocBlock"/>
  77. <exclude name="Drupal.Commenting.InlineComment.InvalidEndChar"/>
  78. <exclude name="Drupal.Commenting.InlineComment.NotCapital"/>
  79. <exclude name="Drupal.Commenting.InlineComment.SpacingAfter"/>
  80. <exclude name="Drupal.Commenting.InlineComment.SpacingBefore"/>
  81. </rule>
  82. <rule ref="Drupal.Commenting.PostStatementComment"/>
  83. <rule ref="Drupal.ControlStructures.ElseIf"/>
  84. <rule ref="Drupal.ControlStructures.ControlSignature"/>
  85. <rule ref="Drupal.ControlStructures.InlineControlStructure"/>
  86. <rule ref="Drupal.Files.EndFileNewline"/>
  87. <rule ref="Drupal.Files.FileEncoding"/>
  88. <rule ref="Drupal.Files.TxtFileLineLength"/>
  89. <rule ref="Drupal.Formatting.MultiLineAssignment"/>
  90. <rule ref="Drupal.Formatting.SpaceInlineIf"/>
  91. <rule ref="Drupal.Formatting.SpaceUnaryOperator"/>
  92. <rule ref="Drupal.Functions.DiscouragedFunctions"/>
  93. <rule ref="Drupal.Functions.FunctionDeclaration"/>
  94. <rule ref="Drupal.InfoFiles.AutoAddedKeys"/>
  95. <rule ref="Drupal.InfoFiles.ClassFiles"/>
  96. <rule ref="Drupal.InfoFiles.DuplicateEntry"/>
  97. <rule ref="Drupal.InfoFiles.Required"/>
  98. <rule ref="Drupal.Methods.MethodDeclaration">
  99. <!-- Silence method name underscore warning which is covered already in
  100. Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps. -->
  101. <exclude name="Drupal.Methods.MethodDeclaration.Underscore"/>
  102. </rule>
  103. <rule ref="Drupal.NamingConventions.ValidVariableName">
  104. <!-- Sniff for: LowerStart -->
  105. <exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/>
  106. </rule>
  107. <rule ref="Drupal.Scope.MethodScope"/>
  108. <rule ref="Drupal.Semantics.EmptyInstall"/>
  109. <rule ref="Drupal.Semantics.FunctionAlias"/>
  110. <rule ref="Drupal.Semantics.FunctionT">
  111. <exclude name="Drupal.Semantics.FunctionT.NotLiteralString"/>
  112. <exclude name="Drupal.Semantics.FunctionT.ConcatString"/>
  113. </rule>
  114. <rule ref="Drupal.Semantics.FunctionWatchdog"/>
  115. <rule ref="Drupal.Semantics.InstallHooks"/>
  116. <rule ref="Drupal.Semantics.LStringTranslatable"/>
  117. <rule ref="Drupal.Semantics.PregSecurity"/>
  118. <rule ref="Drupal.Semantics.TInHookMenu"/>
  119. <rule ref="Drupal.Semantics.TInHookSchema"/>
  120. <rule ref="Drupal.WhiteSpace.CloseBracketSpacing"/>
  121. <rule ref="Drupal.WhiteSpace.Comma"/>
  122. <rule ref="Drupal.WhiteSpace.EmptyLines"/>
  123. <rule ref="Drupal.WhiteSpace.Namespace"/>
  124. <rule ref="Drupal.WhiteSpace.ObjectOperatorIndent"/>
  125. <rule ref="Drupal.WhiteSpace.ObjectOperatorSpacing"/>
  126. <rule ref="Drupal.WhiteSpace.OpenBracketSpacing"/>
  127. <rule ref="Drupal.WhiteSpace.OpenTagNewline"/>
  128. <rule ref="Drupal.WhiteSpace.OperatorSpacing"/>
  129. <rule ref="Drupal.WhiteSpace.ScopeClosingBrace"/>
  130. <rule ref="Drupal.WhiteSpace.ScopeIndent"/>
  131. <!-- Drupal Practice sniffs -->
  132. <rule ref="DrupalPractice.Commenting.ExpectedException"/>
  133. <!-- Generic sniffs -->
  134. <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
  135. <rule ref="Generic.Files.ByteOrderMark"/>
  136. <rule ref="Generic.Files.LineEndings"/>
  137. <rule ref="Generic.Formatting.SpaceAfterCast"/>
  138. <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
  139. <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
  140. <properties>
  141. <property name="checkClosures" value="true"/>
  142. </properties>
  143. </rule>
  144. <rule ref="Generic.NamingConventions.ConstructorName"/>
  145. <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
  146. <rule ref="Generic.PHP.DeprecatedFunctions"/>
  147. <rule ref="Generic.PHP.DisallowShortOpenTag"/>
  148. <rule ref="Generic.PHP.LowerCaseKeyword"/>
  149. <rule ref="Generic.PHP.UpperCaseConstant"/>
  150. <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
  151. <!-- MySource sniffs -->
  152. <rule ref="MySource.Debug.DebugCode"/>
  153. <!-- PEAR sniffs -->
  154. <rule ref="PEAR.Files.IncludingFile"/>
  155. <!-- Disable some error messages that we do not want. -->
  156. <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
  157. <severity>0</severity>
  158. </rule>
  159. <rule ref="PEAR.Files.IncludingFile.UseInclude">
  160. <severity>0</severity>
  161. </rule>
  162. <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
  163. <severity>0</severity>
  164. </rule>
  165. <rule ref="PEAR.Files.IncludingFile.UseRequire">
  166. <severity>0</severity>
  167. </rule>
  168. <rule ref="PEAR.Functions.ValidDefaultValue"/>
  169. <!-- PEAR sniffs -->
  170. <rule ref="PEAR.Functions.FunctionCallSignature"/>
  171. <!-- The sniffs inside PEAR.Functions.FunctionCallSignature silenced below are
  172. also silenced in Drupal CS' ruleset.xml. The code below is a 1-on-1 copy
  173. from that file. -->
  174. <!-- Disable some error messages that we already cover. -->
  175. <rule ref="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket">
  176. <severity>0</severity>
  177. </rule>
  178. <rule ref="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket">
  179. <severity>0</severity>
  180. </rule>
  181. <!-- Disable some error messages that we do not want. -->
  182. <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
  183. <severity>0</severity>
  184. </rule>
  185. <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
  186. <severity>0</severity>
  187. </rule>
  188. <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
  189. <severity>0</severity>
  190. </rule>
  191. <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
  192. <severity>0</severity>
  193. </rule>
  194. <!-- PSR-2 sniffs -->
  195. <rule ref="PSR2.Classes.PropertyDeclaration">
  196. <exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
  197. </rule>
  198. <rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
  199. <rule ref="PSR2.Namespaces.UseDeclaration">
  200. <exclude name="PSR2.Namespaces.UseDeclaration.UseAfterNamespace"/>
  201. </rule>
  202. <!-- Squiz sniffs -->
  203. <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
  204. <rule ref="Squiz.Arrays.ArrayDeclaration">
  205. <exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
  206. <exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
  207. </rule>
  208. <!-- Disable some error messages that we do not want. -->
  209. <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
  210. <severity>0</severity>
  211. </rule>
  212. <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
  213. <severity>0</severity>
  214. </rule>
  215. <rule ref="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline">
  216. <severity>0</severity>
  217. </rule>
  218. <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
  219. <severity>0</severity>
  220. </rule>
  221. <rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
  222. <severity>0</severity>
  223. </rule>
  224. <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
  225. <severity>0</severity>
  226. </rule>
  227. <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
  228. <severity>0</severity>
  229. </rule>
  230. <rule ref="Squiz.Arrays.ArrayDeclaration.NotLowerCase">
  231. <severity>0</severity>
  232. </rule>
  233. <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
  234. <severity>0</severity>
  235. </rule>
  236. <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
  237. <severity>0</severity>
  238. </rule>
  239. <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
  240. <severity>0</severity>
  241. </rule>
  242. <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
  243. <!-- Disable some error messages that we already cover. -->
  244. <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
  245. <severity>0</severity>
  246. </rule>
  247. <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen">
  248. <severity>0</severity>
  249. </rule>
  250. <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose">
  251. <severity>0</severity>
  252. </rule>
  253. <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
  254. <!-- Disable some error messages that we already cover. -->
  255. <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
  256. <severity>0</severity>
  257. </rule>
  258. <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
  259. <severity>0</severity>
  260. </rule>
  261. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
  262. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
  263. <severity>0</severity>
  264. </rule>
  265. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace">
  266. <severity>0</severity>
  267. </rule>
  268. <!-- Standard yet to be finalized on this (https://www.drupal.org/node/1539712). -->
  269. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing">
  270. <severity>0</severity>
  271. </rule>
  272. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.Indent">
  273. <severity>0</severity>
  274. </rule>
  275. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine">
  276. <severity>0</severity>
  277. </rule>
  278. <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
  279. <properties>
  280. <property name="equalsSpacing" value="1"/>
  281. </properties>
  282. </rule>
  283. <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeArg">
  284. <severity>0</severity>
  285. </rule>
  286. <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
  287. <rule ref="Squiz.Strings.ConcatenationSpacing">
  288. <properties>
  289. <property name="spacing" value="1"/>
  290. <property name="ignoreNewlines" value="true"/>
  291. </properties>
  292. </rule>
  293. <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
  294. <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
  295. <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
  296. <!-- Zend sniffs -->
  297. <rule ref="Zend.Files.ClosingTag"/>
  298. </ruleset>