forked from humanmade/coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruleset.xml
More file actions
140 lines (106 loc) · 4.79 KB
/
ruleset.xml
File metadata and controls
140 lines (106 loc) · 4.79 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?xml version="1.0"?>
<ruleset name="HM">
<description>Sniffs for the coding standards of the WP-API plugin</description>
<!-- vendor/humanmade/coding-standards, -->
<config name="installed_paths" value="vendor/wp-coding-standards/wpcs,vendor/fig-r/psr2r-sniffer" />
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>
<autoload>./bootstrap.php</autoload>
<!-- Include everything in the VIP standard... -->
<rule ref="WordPress-VIP">
<!-- ...Except for VIP-specific things -->
<exclude name="WordPress.VIP.FileSystemWritesDisallow" />
<exclude name="WordPress.VIP.RestrictedFunctions" />
<exclude name="WordPress.VIP.RestrictedVariables" />
<exclude name="WordPress.VIP.SuperGlobalInputUsage" />
<exclude name="WordPress.VIP.ValidatedSanitizedInput" />
<exclude name="WordPress.VIP.DirectDatabaseQuery" />
<exclude name="WordPress.XSS.EscapeOutput" />
<exclude name="WordPress.VIP.AdminBarRemoval" />
<!-- Allow with or without semicolons -->
<exclude name="Squiz.PHP.EmbeddedPhp.NoSemicolon" />
<!-- Exclude other conflicting rules -->
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_trigger_error" />
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
<!--
OK, real talk right now. Yoda conditions are ridiculous.
The fundamental problem that Yoda conditions attempts to solve is:
the equality operator is very close to the assignment operator.
It's easy to mess up and accidentally assign to the variable you're
trying to check.
Here's the thing though. Yoda conditions just don't read correctly
in the code flow. They require you to change the way you think
about the control flow.
Rather than forcing every conditional to be backwards, why not ban
assignment from conditionals? You never really *need* to assign in
a conditional.
So, here's where I stand: no to Yoda conditions. Yes to banning
assignment in conditionals.
-->
<exclude name="WordPress.PHP.YodaConditions" />
</rule>
<!-- Allow the use of filesystem functions -->
<rule ref="WordPress.WP.AlternativeFunctions">
<properties>
<property name="exclude" value="file_get_contents,file_system_read" />
</properties>
</rule>
<!-- Allow . in hook names -->
<rule ref="WordPress.NamingConventions.ValidHookName">
<properties>
<property name="additionalWordDelimiters" value="."/>
</properties>
</rule>
<!-- Prefer alignment over line length -->
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
<properties>
<property name="maxColumn" value="1000"/>
</properties>
</rule>
<!--
HM Rules / HM RULEZZZZ
http://engineering.hmn.md/style/php/
-->
<!-- File Layout: Declare symbols or run code, but not both. -->
<rule ref="PSR1.Files.SideEffects" />
<!-- File Layout: Classes in own file. -->
<!-- Handled in Classes/OnlyClassInFileSniff -->
<!-- Also handled in PSR1.Classes.ClassDeclaration below. -->
<!-- File Layout: Order: `namespace`, `use`, `const`, code -->
<!-- Handled in Layout/OrderSniff -->
<!-- File Naming: `name/space/` -->
<!-- Handled in Files/NamespaceDirectoryNameSniff -->
<!-- File Naming: `class-classname.php` -->
<!-- Handled in Files/ClassNameFileSniff -->
<!-- File Naming: `namespace.php` -->
<!-- Handled in Files/FunctionFileNameSniff -->
<!-- File Naming: `plugin.php` or `functions.php` -->
<!-- Namespacing: Required for classes -->
<rule ref="PSR1.Classes.ClassDeclaration" />
<!-- Namespacing: Required for functions -->
<!-- Handled in Functions/NamespacedFunctionsSniff -->
<rule ref="PSR2.Namespaces.NamespaceDeclaration" />
<!-- Namespacing: `use` statements -->
<rule ref="PSR2.Namespaces.UseDeclaration">
<exclude name="PSR2.Namespaces.UseDeclaration.MultipleDeclarations" />
</rule>
<rule ref="PSR2R.Namespaces.UnusedUseStatement" />
<rule ref="PSR2R.Namespaces.UseInAlphabeticalOrder" />
<!-- Namespacing: No backslash with `use` -->
<!-- Handled in Namespaces/NoLeadingSlashOnUseSniff -->
<!-- Yoda Conditions: Ban inline assignment in control structures. See note above. -->
<rule ref="PSR2R.ControlStructures.NoInlineAssignment" />
<!-- Anonymous Functions: Spaces after `function` and `use` -->
<!-- Handled in Squiz.Functions.MultiLineFunctionDeclaration -->
<!-- Array Creation: Short Syntax -->
<!-- Handled in Arrays/ForceShortArraysSniff -->
<!-- TEMPLATE RULES / TEMPLATES RULE -->
<!-- Namespacing: No namespace -->
<!-- Inline Statements: Single statement on same line -->
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<!-- Inline Statements: No semicolons -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
</ruleset>