1
1
<?xml version =" 1.0" ?>
2
- <ruleset name =" Inpsyde" >
2
+ <ruleset name =" Inpsyde Coding Standard " >
3
3
4
- <description >A custom set of code standard rules to check for Inpsyde Codex .</description >
4
+ <description >PHP 7+ coding standards for Inpsyde WordPress projects .</description >
5
5
6
- <!-- Check for cross-version support for PHP 7.0 and higher. -->
6
+ <!--
7
+ PHP 7.0 and higher.
8
+ -->
7
9
<config name =" testVersion" value =" 7.0-" />
8
10
9
- <!-- Allow . in hook names -->
10
- <rule ref =" WordPress.NamingConventions.ValidHookName" >
11
+ <!--
12
+ PSR 2 Code style.
13
+ See http://www.php-fig.org/psr/psr-2/
14
+ -->
15
+ <rule ref =" PSR2" />
16
+
17
+ <!--
18
+ Some sanity in variables.
19
+ See https://github.com/sirbrillig/phpcs-variable-analysis
20
+ -->
21
+ <rule ref =" VariableAnalysis" />
22
+
23
+ <!--
24
+ Neutron standard are quality tools for PHP7 development from Automattic.
25
+ See https://github.com/Automattic/phpcs-neutron-standard
26
+ -->
27
+ <rule ref =" NeutronStandard" >
28
+ <exclude name =" NeutronStandard.Functions.LongFunction" />
29
+ </rule >
30
+
31
+ <!--
32
+ Object calisthenics are about software quality.
33
+ Some rules are too strict for PHP/WP development, so we keep just some.
34
+ See https://github.com/object-calisthenics/phpcs-calisthenics-rules
35
+ -->
36
+ <rule ref =" ObjectCalisthenics.Metrics.MaxNestingLevel" >
11
37
<properties >
12
- <property name =" additionalWordDelimiters" value =" ." />
38
+ <property name =" maxNestingLevel" value =" 2" />
39
+ </properties >
40
+ </rule >
41
+ <rule ref =" ObjectCalisthenics.ControlStructures.NoElse" />
42
+ <rule ref =" ObjectCalisthenics.NamingConventions.ElementNameMinimalLength" />
43
+ <rule ref =" ObjectCalisthenics.Classes.ForbiddenPublicProperty" />
44
+ <rule ref =" ObjectCalisthenics.NamingConventions.NoSetter" />
45
+ <rule ref =" ObjectCalisthenics.Files.FunctionLength" >
46
+ <properties >
47
+ <property name =" maxLength" value =" 50" />
48
+ </properties >
49
+ </rule >
50
+ <rule ref =" ObjectCalisthenics.Metrics.PropertyPerClassLimit" >
51
+ <properties >
52
+ <property name =" maxCount" value =" 10" />
13
53
</properties >
14
54
</rule >
15
55
16
- <!-- Include the WordPress ruleset, with exclusions. -->
17
- <rule ref =" WordPress" >
18
-
19
- <exclude name =" WordPress.PHP.YodaConditions" />
20
-
21
- <!-- Exclude to be able to adhere to PSR-4. -->
22
- <exclude name =" WordPress.Files.FileName" />
23
-
24
- <exclude name =" Generic.WhiteSpace.ScopeIndent.Incorrect" />
25
- <exclude name =" Generic.Commenting.DocComment.MissingShort" />
26
- <exclude name =" Generic.PHP.DisallowShortOpenTag" />
27
-
28
- <exclude name =" Squiz.Commenting.FileComment.MissingPackageTag" />
29
- <exclude name =" Squiz.Commenting.FileComment.Missing" />
30
-
31
- <exclude name =" PEAR.Functions.FunctionCallSignature" />
32
-
33
- <!-- Remove spaces before types check. -->
34
- <exclude name =" Squiz.Commenting.VariableComment.VarIndent" />
35
- <exclude name =" Squiz.Commenting.FunctionComment.SpacingBeforeParamType" />
36
- <exclude name =" Squiz.Commenting.FunctionComment.SpacingBeforeParams" />
37
-
38
- <!-- Exclude Full Stops on inline comment. -->
39
- <exclude name =" Squiz.Commenting.InlineComment.InvalidEndChar" />
40
- <exclude name =" Squiz.Commenting.FunctionComment.MissingParamComment" />
41
-
42
- <!-- Remove empty line not required before block comment -->
43
- <exclude name =" Squiz.Commenting.BlockComment.HasEmptyLineBefore" />
44
- <!-- Remove rule for /** style for each var -->
45
- <exclude name =" Squiz.Commenting.VariableComment.WrongStyle" />
46
- <!-- Exclude to be able to include an encoding cookie. -->
47
- <exclude name =" Squiz.Commenting.FileComment.WrongStyle" />
48
- <exclude name =" Squiz.Commenting.InlineComment.WrongStyle" />
49
-
50
- <!-- Exclude to be able to use variadic arguments. https://github.com/squizlabs/PHP_CodeSniffer/issues/1652 -->
51
- <exclude name =" Squiz.Commenting.FunctionComment.IncorrectTypeHint" />
52
-
53
- <!-- Exclude to be able to use "@noinspection PhpUnusedParameterInspection" annotations. -->
54
- <exclude name =" Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" />
55
56
56
- <exclude name =" WordPress.WhiteSpace.ScopeIndent.Incorrect" />
57
- <exclude name =" WordPress.Arrays.ArrayKeySpacingRestrictions" />
58
- <exclude name =" WordPress.Arrays.ArrayDeclaration.KeyNotAligned" />
59
- <!-- Remove spaces instead of tabs check -->
60
- <exclude name =" WordPress.Arrays.ArrayDeclaration.ValueNotAligned" />
61
- <exclude name =" WordPress.Arrays.ArrayDeclaration.CloseBraceNotAligned" />
57
+ <!-- Load WordPress ruleset, then exclude all of them. Necessary for wpcs 3.0 compat -->
58
+ <rule ref =" WordPress" >
59
+ <exclude name =" WordPress-Core" />
60
+ <exclude name =" WordPress-Docs" />
61
+ <exclude name =" WordPress-Extra" />
62
+ <exclude name =" WordPress-VIP" />
63
+ <exclude name =" WordPress.PHP.DiscouragedPHPFunctions" />
64
+ </rule >
62
65
63
- <!-- Exclude to not be forced to use a space before return type colons. https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/547. -->
64
- <exclude name =" WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterCloseParenthesis" />
66
+ <!--
67
+ Some WordPress specific rules.
68
+ See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
69
+ -->
70
+ <rule ref =" WordPress.VIP.SessionVariableUsage" />
71
+ <rule ref =" WordPress.VIP.SessionFunctionsUsage" />
72
+ <rule ref =" WordPress.VIP.SuperGlobalInputUsage" />
73
+ <rule ref =" WordPress.VIP.ValidatedSanitizedInput" />
74
+ <rule ref =" WordPress.Security.EscapeOutput" />
75
+ <rule ref =" WordPress.Security.NonceVerification" />
76
+ <rule ref =" WordPress.WP.AlternativeFunctions.curl" />
77
+ <rule ref =" WordPress.WP.DiscouragedConstants" />
78
+ <rule ref =" WordPress.WP.I18n" />
79
+ <rule ref =" WordPress.Arrays.CommaAfterArrayItem" />
80
+ <rule ref =" WordPress.PHP.StrictComparisons" />
81
+ <rule ref =" WordPress.PHP.StrictInArray" />
82
+ <rule ref =" WordPress.PHP.POSIXFunctions" />
83
+ <rule ref =" WordPress.PHP.RestrictedPHPFunctions" />
84
+ <rule ref =" WordPress.PHP.DiscouragedPHPFunctions" >
85
+ <properties >
86
+ <property name =" exclude" value =" serialize" />
87
+ <property name =" exclude" value =" urlencode" />
88
+ <property name =" exclude" value =" obfuscation" />
89
+ </properties >
90
+ </rule >
91
+ <rule ref =" WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration" >
92
+ <type >error</type >
93
+ </rule >
94
+ <rule ref =" WordPress.PHP.DevelopmentFunctions" />
95
+ <rule ref =" WordPress.PHP.DevelopmentFunctions.error_log" >
96
+ <type >error</type >
97
+ </rule >
98
+ <rule ref =" WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure" >
99
+ <type >error</type >
100
+ </rule >
65
101
102
+ <!--
103
+ Generic and common sense sanity.
104
+ -->
105
+ <rule ref =" Generic.ControlStructures.InlineControlStructure" />
106
+ <rule ref =" Generic.Files.EndFileNewline" />
107
+ <rule ref =" Generic.Files.ByteOrderMark" />
108
+ <rule ref =" Generic.Files.LineEndings" >
109
+ <properties >
110
+ <property name =" eolChar" value =" \n" />
111
+ </properties >
112
+ </rule >
113
+ <rule ref =" Squiz.PHP.Eval" />
114
+ <rule ref =" Squiz.PHP.Eval.Discouraged" >
115
+ <type >error</type >
66
116
</rule >
67
117
68
- <!-- Adapt to be able to use namespaced hooks in dot notation. -->
69
- <rule ref =" WordPress.NamingConventions.ValidHookName" >
118
+ <!--
119
+ No commented-out code, please. Let version control do its job.
120
+ -->
121
+ <rule ref =" Squiz.PHP.CommentedOutCode" >
70
122
<properties >
71
- <property name =" additionalWordDelimiters " value =" . " />
123
+ <property name =" maxPercentage " value =" 45 " />
72
124
</properties >
73
125
</rule >
74
126
75
- </ruleset >
127
+ </ruleset >
0 commit comments