phpcs.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ruleset name="search_api">
  3. <description>Default PHP CodeSniffer configuration for the Search API module.</description>
  4. <file>.</file>
  5. <arg name="extensions" value="inc,install,module,php,profile,test,theme"/>
  6. <!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
  7. <!-- Drupal sniffs -->
  8. <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
  9. <rule ref="Drupal.Classes.ClassCreateInstance"/>
  10. <rule ref="Drupal.Classes.ClassDeclaration"/>
  11. <rule ref="Drupal.Classes.FullyQualifiedNamespace"/>
  12. <rule ref="Drupal.Classes.InterfaceName"/>
  13. <rule ref="Drupal.Classes.UnusedUseStatement"/>
  14. <rule ref="Drupal.Classes.UseLeadingBackslash"/>
  15. <rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/>
  16. <rule ref="Drupal.CSS.ColourDefinition"/>
  17. <rule ref="Drupal.Commenting.ClassComment"/>
  18. <rule ref="Drupal.Commenting.DataTypeNamespace" />
  19. <rule ref="Drupal.Commenting.DocComment"/>
  20. <rule ref="Drupal.Commenting.DocCommentStar"/>
  21. <rule ref="Drupal.Commenting.FileComment"/>
  22. <rule ref="Drupal.Commenting.FunctionComment"/>
  23. <rule ref="Drupal.Commenting.InlineComment">
  24. <!-- This is impractical when commenting code out. -->
  25. <exclude name="Drupal.Commenting.InlineComment.InvalidEndChar" />
  26. <!-- We (rarely) use comments as "headings" for multiple functions. -->
  27. <exclude name="Drupal.Commenting.InlineComment.SpacingAfter" />
  28. <!--
  29. This disallows indentation in comments, even though it can sometimes be
  30. helpful for structured explanations.
  31. @see \Drupal\search_api\Plugin\search_api\processor\ContentAccess::addNodeAccess()
  32. -->
  33. <exclude name="Drupal.Commenting.InlineComment.SpacingBefore" />
  34. </rule>
  35. <rule ref="Drupal.Commenting.VariableComment">
  36. <!-- This finds false positives when @code is used. -->
  37. <exclude name="Drupal.Commenting.VariableComment.VarOrder"/>
  38. </rule>
  39. <rule ref="Drupal.Commenting.PostStatementComment"/>
  40. <rule ref="Drupal.ControlStructures.ElseIf"/>
  41. <rule ref="Drupal.ControlStructures.ControlSignature"/>
  42. <rule ref="Drupal.ControlStructures.InlineControlStructure"/>
  43. <rule ref="Drupal.Files.EndFileNewline"/>
  44. <rule ref="Drupal.Files.FileEncoding"/>
  45. <rule ref="Drupal.Files.TxtFileLineLength"/>
  46. <rule ref="Drupal.Formatting.MultiLineAssignment"/>
  47. <rule ref="Drupal.Formatting.SpaceInlineIf"/>
  48. <rule ref="Drupal.Formatting.SpaceUnaryOperator"/>
  49. <rule ref="Drupal.Functions.DiscouragedFunctions"/>
  50. <rule ref="Drupal.Functions.FunctionDeclaration"/>
  51. <rule ref="Drupal.InfoFiles.AutoAddedKeys"/>
  52. <rule ref="Drupal.InfoFiles.ClassFiles"/>
  53. <rule ref="Drupal.InfoFiles.DuplicateEntry"/>
  54. <rule ref="Drupal.InfoFiles.Required"/>
  55. <rule ref="Drupal.Methods.MethodDeclaration"/>
  56. <rule ref="Drupal.NamingConventions.ValidVariableName">
  57. <!-- This interferes with the stored entity properties. -->
  58. <exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/>
  59. </rule>
  60. <rule ref="Drupal.Scope.MethodScope"/>
  61. <rule ref="Drupal.Semantics.EmptyInstall"/>
  62. <rule ref="Drupal.Semantics.FunctionAlias"/>
  63. <rule ref="Drupal.Semantics.FunctionT"/>
  64. <rule ref="Drupal.Semantics.FunctionWatchdog"/>
  65. <rule ref="Drupal.Semantics.InstallHooks"/>
  66. <rule ref="Drupal.Semantics.LStringTranslatable"/>
  67. <rule ref="Drupal.Semantics.PregSecurity"/>
  68. <rule ref="Drupal.Semantics.TInHookMenu"/>
  69. <rule ref="Drupal.Semantics.TInHookSchema"/>
  70. <rule ref="Drupal.WhiteSpace.CloseBracketSpacing"/>
  71. <rule ref="Drupal.WhiteSpace.Comma"/>
  72. <rule ref="Drupal.WhiteSpace.EmptyLines"/>
  73. <rule ref="Drupal.WhiteSpace.Namespace"/>
  74. <rule ref="Drupal.WhiteSpace.ObjectOperatorIndent"/>
  75. <rule ref="Drupal.WhiteSpace.ObjectOperatorSpacing"/>
  76. <rule ref="Drupal.WhiteSpace.OpenBracketSpacing"/>
  77. <rule ref="Drupal.WhiteSpace.OpenTagNewline"/>
  78. <rule ref="Drupal.WhiteSpace.OperatorSpacing"/>
  79. <rule ref="Drupal.WhiteSpace.ScopeClosingBrace"/>
  80. <rule ref="Drupal.WhiteSpace.ScopeIndent"/>
  81. <!-- Drupal Practice sniffs -->
  82. <rule ref="DrupalPractice.Commenting.ExpectedException"/>
  83. <!-- Generic sniffs -->
  84. <rule ref="Generic.Files.ByteOrderMark"/>
  85. <rule ref="Generic.Files.LineEndings"/>
  86. <rule ref="Generic.Formatting.SpaceAfterCast"/>
  87. <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
  88. <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
  89. <properties>
  90. <property name="checkClosures" value="true"/>
  91. </properties>
  92. </rule>
  93. <rule ref="Generic.NamingConventions.ConstructorName"/>
  94. <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
  95. <rule ref="Generic.PHP.DeprecatedFunctions"/>
  96. <rule ref="Generic.PHP.DisallowShortOpenTag"/>
  97. <rule ref="Generic.PHP.LowerCaseKeyword"/>
  98. <rule ref="Generic.PHP.UpperCaseConstant"/>
  99. <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
  100. <!-- MySource sniffs -->
  101. <rule ref="MySource.Debug.DebugCode"/>
  102. <!-- PEAR sniffs -->
  103. <rule ref="PEAR.Files.IncludingFile"/>
  104. <!-- Disable some error messages that we do not want. -->
  105. <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
  106. <severity>0</severity>
  107. </rule>
  108. <rule ref="PEAR.Files.IncludingFile.UseInclude">
  109. <severity>0</severity>
  110. </rule>
  111. <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
  112. <severity>0</severity>
  113. </rule>
  114. <rule ref="PEAR.Files.IncludingFile.UseRequire">
  115. <severity>0</severity>
  116. </rule>
  117. <rule ref="PEAR.Functions.ValidDefaultValue"/>
  118. <!-- PEAR sniffs -->
  119. <rule ref="PEAR.Functions.FunctionCallSignature"/>
  120. <!-- The sniffs inside PEAR.Functions.FunctionCallSignature silenced below are
  121. also silenced in Drupal CS' ruleset.xml. The code below is a 1-on-1 copy
  122. from that file. -->
  123. <!-- Disable some error messages that we already cover. -->
  124. <rule ref="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket">
  125. <severity>0</severity>
  126. </rule>
  127. <rule ref="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket">
  128. <severity>0</severity>
  129. </rule>
  130. <!-- Disable some error messages that we do not want. -->
  131. <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
  132. <severity>0</severity>
  133. </rule>
  134. <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
  135. <severity>0</severity>
  136. </rule>
  137. <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
  138. <severity>0</severity>
  139. </rule>
  140. <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
  141. <severity>0</severity>
  142. </rule>
  143. <!-- PSR-2 sniffs -->
  144. <rule ref="PSR2.Classes.PropertyDeclaration"/>
  145. <rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
  146. <rule ref="PSR2.Namespaces.UseDeclaration"/>
  147. <!-- Squiz sniffs -->
  148. <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
  149. <rule ref="Squiz.Arrays.ArrayDeclaration">
  150. <exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
  151. <exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
  152. </rule>
  153. <!-- Disable some error messages that we do not want. -->
  154. <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
  155. <severity>0</severity>
  156. </rule>
  157. <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
  158. <severity>0</severity>
  159. </rule>
  160. <rule ref="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline">
  161. <severity>0</severity>
  162. </rule>
  163. <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
  164. <severity>0</severity>
  165. </rule>
  166. <rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
  167. <severity>0</severity>
  168. </rule>
  169. <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
  170. <severity>0</severity>
  171. </rule>
  172. <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
  173. <severity>0</severity>
  174. </rule>
  175. <rule ref="Squiz.Arrays.ArrayDeclaration.NotLowerCase">
  176. <severity>0</severity>
  177. </rule>
  178. <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
  179. <severity>0</severity>
  180. </rule>
  181. <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
  182. <severity>0</severity>
  183. </rule>
  184. <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
  185. <severity>0</severity>
  186. </rule>
  187. <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
  188. <!-- Disable some error messages that we already cover. -->
  189. <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
  190. <severity>0</severity>
  191. </rule>
  192. <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen">
  193. <severity>0</severity>
  194. </rule>
  195. <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose">
  196. <severity>0</severity>
  197. </rule>
  198. <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
  199. <!-- Disable some error messages that we already cover. -->
  200. <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
  201. <severity>0</severity>
  202. </rule>
  203. <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
  204. <severity>0</severity>
  205. </rule>
  206. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
  207. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
  208. <severity>0</severity>
  209. </rule>
  210. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace">
  211. <severity>0</severity>
  212. </rule>
  213. <!-- Standard yet to be finalized on this (https://www.drupal.org/node/1539712). -->
  214. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing">
  215. <severity>0</severity>
  216. </rule>
  217. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.Indent">
  218. <severity>0</severity>
  219. </rule>
  220. <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine">
  221. <severity>0</severity>
  222. </rule>
  223. <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
  224. <properties>
  225. <property name="equalsSpacing" value="1"/>
  226. </properties>
  227. </rule>
  228. <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeArg">
  229. <severity>0</severity>
  230. </rule>
  231. <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
  232. <rule ref="Squiz.Strings.ConcatenationSpacing">
  233. <properties>
  234. <property name="spacing" value="1"/>
  235. <property name="ignoreNewlines" value="true"/>
  236. </properties>
  237. </rule>
  238. <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
  239. <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
  240. <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
  241. <!-- Zend sniffs -->
  242. <rule ref="Zend.Files.ClosingTag"/>
  243. </ruleset>