phpcs.xml.dist 14 KB

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