generated from silverstripe/silverstripe-module
-
Notifications
You must be signed in to change notification settings - Fork 4
/
phpcs.xml.dist
119 lines (113 loc) · 8.9 KB
/
phpcs.xml.dist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<file>src</file>
<file>tests</file>
<!-- Show progress and output sniff names on violation, and add colours -->
<arg value="p" />
<arg name="colors" />
<arg value="s" />
<rule ref="PSR2">
<!-- Allow non camel cased method names - some base SS method names are PascalCase or snake_case -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<!-- This rule conflicts with Slevomat standards requiring an empty line before closing brace -->
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody"/>
</rule>
<!-- All "use" statements must be used in the code. -->
<rule ref="./vendor/slevomat/coding-standard/SlevomatCodingStandard/ruleset.xml">
<!-- Comments after code are fine. It's how we disable rules when we need to -->
<exclude name="SlevomatCodingStandard.Commenting.DisallowCommentAfterCode.DisallowedCommentAfterCode"/>
<!-- We're not punishing folks for adding annotations (even if the method is self documenting) -->
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation"/>
<!-- Late Static Binding is used often in SS -->
<exclude name="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Multiline comments is what we use as a standard in SS -->
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment.MultiLinePropertyComment"/>
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment"/>
<!-- Write conditions like Yoda, we do not -->
<exclude name="SlevomatCodingStandard.ControlStructures.RequireYodaComparison.RequiredYodaComparison"/>
<!-- There are two rules which conflict. NewWithoutParentheses and UselessParentheses. One must be disabled -->
<!-- We allow new Class(); rather than new Class;-->
<exclude name="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses"/>
<!-- Do not require fully qualified class names -->
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName"/>
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces.NonFullyQualified"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation.NonFullyQualifiedClassName"/>
<!-- Not something we do in SS -->
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>
<!-- Array type hint syntax is very useful -->
<exclude name="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
<!-- Using mixed type is a way to get around the fact that we often cannot strictly type our methods if we -->
<!-- are extending a base SS method -->
<exclude name="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint"/>
<!-- allow private static -->
<exclude name="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty"/>
<!-- Don't require traversable type hints -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
<!-- Even if you strictly type, there are other reasons to add a DocComment (EG: to add @codeCoverageIgnore -->
<exclude name="SlevomatCodingStandard.TypeHints.UselessConstantTypeHintSniff.UselessDocComment"/>
<!-- Even if you strictly type, there are other reasons to add a DocComment (EG: to add @codeCoverageIgnore -->
<exclude name="SlevomatCodingStandard.Commenting.UselessFunctionDocComment.UselessDocComment"/>
<!-- Sometimes need "useless annotation" to add things like @codeCoverageIgnore -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation"/>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation"/>
<!-- Whitespace above and below the class doesn't do much -->
<exclude name="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces.NoEmptyLineAfterOpeningBrace"/>
<exclude name="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces.NoEmptyLineBeforeClosingBrace"/>
<!-- Inline doc comments are fine -->
<exclude name="SlevomatCodingStandard.PHP.RequireExplicitAssertion.RequiredExplicitAssertion"/>
<!-- Do not require literal separator for long int values -->
<exclude name="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator"/>
<!-- Do not require arrow functions (this feature is actually not supported in our version of PHPUnit) -->
<exclude name="SlevomatCodingStandard.Functions.RequireArrowFunction.RequiredArrowFunction"/>
<!-- Do not require trailing comma in function calls until we're sure we only want PHP 7.4+ support -->
<exclude name="SlevomatCodingStandard.Functions.TrailingCommaInCall.MissingTrailingComma"/>
<!-- Do not require fully qualified exceptions namespaces like SilverStripe\ORM\ValidationException -->
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions.NonFullyQualifiedException"/>
<!-- Do not require function referenced via a fully qualified name -->
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions.NonFullyQualified"/>
<!-- We don't control the order of declaration based on access level -->
<exclude name="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Allow our exceptions to have the word "Exception" in them -->
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
<!-- Allow short ternary operator -->
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator.DisallowedShortTernaryOperator"/>
<!-- You are not making me go \PHP_EOL -->
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified"/>
<!-- We can't declare classes as abstract/final because that would remove the ability for devs to extend our -->
<!-- classes as they see fit -->
<exclude name="SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal"/>
<!-- We do not require trailing commas on multiline methods. Both rules disabled, as we'll allow folks to -->
<!-- add them if they want them, but we don't enforce either way -->
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall.DisallowedTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration.DisallowedTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse.DisallowedTrailingComma"/>
<!-- Length does not determine complexity. We do not care if methods or files are long -->
<exclude name="SlevomatCodingStandard.Functions.FunctionLength.FunctionLength"/>
<exclude name="SlevomatCodingStandard.Files.FunctionLength.FunctionLength"/>
<exclude name="SlevomatCodingStandard.Files.FileLength.FileTooLong"/>
<exclude name="SlevomatCodingStandard.Classes.ClassLength.ClassTooLong"/>
<!-- We'll decide what is complex -->
<exclude name="SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh"/>
<!-- We require property promotion -->
<exclude name="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion.DisallowedConstructorPropertyPromotion"/>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" type="bool" value="true"/>
<property name="ignoredAnnotationNames" type="array" value="@config"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<!-- Set the root namespace for our src dir and phpunit dir. Please change these as required -->
<property name="rootNamespaces" type="array" value="src=>Terraformers\KeysForCache,tests=>Terraformers\KeysForCache\Tests"/>
<property name="ignoredNamespaces" type="array" value="Slevomat\Services"/>
</properties>
</rule>
</ruleset>