phpcs.xml.dist 15 KB

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