phpcs.xml.dist 5.61 KB
Newer Older
1 2 3 4
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="drupal_core">
  <description>Default PHP CodeSniffer configuration for Drupal core.</description>
  <file>.</file>
5
  <arg name="extensions" value="inc,install,module,php,profile,test,theme"/>
6 7 8 9 10 11 12

  <!--Exclude third party code.-->
  <exclude-pattern>./assets/vendor/*</exclude-pattern>

  <!--Exclude test files that are intentionally empty, or intentionally violate coding standards.-->
  <exclude-pattern>./modules/system/tests/fixtures/HtaccessTest</exclude-pattern>

13 14
  <!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
  <!-- Drupal sniffs -->
15
  <rule ref="Drupal.Classes.ClassCreateInstance"/>
16
  <rule ref="Drupal.Classes.ClassDeclaration"/>
17
  <rule ref="Drupal.Classes.FullyQualifiedNamespace"/>
18
  <rule ref="Drupal.Classes.UnusedUseStatement"/>
19 20
  <rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/>
  <rule ref="Drupal.CSS.ColourDefinition"/>
21 22 23
  <rule ref="Drupal.Commenting.ClassComment">
    <exclude name="Drupal.Commenting.ClassComment.Missing"/>
  </rule>
24 25
  <rule ref="Drupal.Commenting.DocComment">
    <!-- Sniff for these errors: SpacingAfterTagGroup, WrongEnd, SpacingBetween,
26 27
      ContentAfterOpen, SpacingBeforeShort, TagValueIndent, ShortStartSpace,
      SpacingAfter -->
28
    <exclude name="Drupal.Commenting.DocComment.LongNotCapital"/>
29 30
    <!-- ParamNotFirst still not decided for PHPUnit-based tests.
      @see https://www.drupal.org/node/2253915 -->
31 32 33 34 35
    <exclude name="Drupal.Commenting.DocComment.ParamNotFirst"/>
    <exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/>
    <exclude name="Drupal.Commenting.DocComment.LongFullStop"/>
    <exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
    <exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
36 37
    <!-- TagsNotGrouped and ParamGroup have false-positives.
      @see https://www.drupal.org/node/2060925 -->
38
    <exclude name="Drupal.Commenting.DocComment.TagsNotGrouped"/>
39
    <exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
40 41 42 43
    <exclude name="Drupal.Commenting.DocComment.ShortSingleLine"/>
    <exclude name="Drupal.Commenting.DocComment.TagGroupSpacing"/>
    <exclude name="Drupal.Commenting.DocComment.MissingShort"/>
  </rule>
44 45
  <rule ref="Drupal.Commenting.DocCommentStar"/>
  <rule ref="Drupal.Commenting.FileComment"/>
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
  <rule ref="Drupal.Commenting.FunctionComment">
    <exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
    <exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/>
    <exclude name="Drupal.Commenting.FunctionComment.InvalidReturnNotVoid"/>
    <exclude name="Drupal.Commenting.FunctionComment.InvalidTypeHint"/>
    <exclude name="Drupal.Commenting.FunctionComment.Missing"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingFile"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingParamName"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
    <exclude name="Drupal.Commenting.FunctionComment.MissingReturnType"/>
    <exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>
    <exclude name="Drupal.Commenting.FunctionComment.ParamCommentNotCapital"/>
    <exclude name="Drupal.Commenting.FunctionComment.ParamNameNoMatch"/>
    <exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
  </rule>
63
  <rule ref="Drupal.ControlStructures.ElseIf"/>
64
  <rule ref="Drupal.ControlStructures.ControlSignature"/>
65
  <rule ref="Drupal.Files.EndFileNewline"/>
66
  <rule ref="Drupal.Files.TxtFileLineLength"/>
67
  <rule ref="Drupal.Formatting.SpaceInlineIf"/>
68
  <rule ref="Drupal.Formatting.SpaceUnaryOperator"/>
69
  <rule ref="Drupal.Functions.DiscouragedFunctions"/>
70 71
  <rule ref="Drupal.Functions.FunctionDeclaration.SpaceAfter"/>
  <rule ref="Drupal.Functions.FunctionDeclaration.SpaceBeforeParenthesis"/>
72 73 74 75 76
  <rule ref="Drupal.InfoFiles.AutoAddedKeys"/>
  <rule ref="Drupal.InfoFiles.ClassFiles"/>
  <rule ref="Drupal.InfoFiles.DuplicateEntry"/>
  <rule ref="Drupal.InfoFiles.Required"/>
  <rule ref="Drupal.Semantics.EmptyInstall"/>
77 78 79 80 81
  <rule ref="Drupal.Semantics.FunctionT">
    <exclude name="Drupal.Semantics.FunctionT.BackslashSingleQuote"/>
    <exclude name="Drupal.Semantics.FunctionT.NotLiteralString"/>
    <exclude name="Drupal.Semantics.FunctionT.ConcatString"/>
  </rule>
82 83 84 85 86 87 88 89
  <rule ref="Drupal.Semantics.FunctionWatchdog"/>
  <rule ref="Drupal.Semantics.InstallHooks"/>
  <rule ref="Drupal.Semantics.LStringTranslatable"/>
  <rule ref="Drupal.Semantics.PregSecurity"/>
  <rule ref="Drupal.Semantics.TInHookMenu"/>
  <rule ref="Drupal.Semantics.TInHookSchema"/>
  <rule ref="Drupal.WhiteSpace.Comma"/>
  <rule ref="Drupal.WhiteSpace.ObjectOperatorIndent"/>
90
  <rule ref="Drupal.WhiteSpace.ObjectOperatorSpacing"/>
91
  <rule ref="Drupal.WhiteSpace.OperatorSpacing"/>
92 93 94

  <!-- Generic sniffs -->
  <rule ref="Generic.Files.LineEndings"/>
95
  <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
96 97 98
  <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
  <rule ref="Generic.PHP.DeprecatedFunctions"/>
  <rule ref="Generic.PHP.DisallowShortOpenTag"/>
99
  <rule ref="Generic.PHP.UpperCaseConstant"/>
100 101
  <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>

102 103 104 105 106
  <!-- PSR-2 sniffs -->
  <rule ref="PSR2.Classes.PropertyDeclaration">
    <exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
  </rule>

107 108 109 110 111 112 113 114
  <!-- Squiz sniffs -->
  <rule ref="Squiz.Strings.ConcatenationSpacing">
    <properties>
      <property name="spacing" value="1"/>
      <property name="ignoreNewlines" value="true"/>
    </properties>
 </rule>

115
</ruleset>