-
Notifications
You must be signed in to change notification settings - Fork 21
/
phpcs.xml.dist
129 lines (109 loc) · 4.52 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
120
121
122
123
124
125
126
127
128
129
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for Plugins">
<description>Generally-applicable sniffs for WordPress plugins</description>
<!-- Set the minimum WP version -->
<config name="minimum_supported_wp_version" value="5.3"/>
<rule ref="WordPress">
<!-- We don't require conforming to WP file naming -->
<exclude name="WordPress.Files.FileName"/>
<!-- These comments are unnecessary -->
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<exclude name="Squiz.Commenting.FileComment"/>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
<exclude name="Squiz.Commenting.LongConditionClosingComment"/>
<!-- No thanks -->
<exclude name="PSR12.Files.FileHeader.IncorrectOrder"/>
<exclude name="Universal.Operators.DisallowShortTernary"/>
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
<!-- Exceptions can be escaped before outputting not when thrown -->
<exclude name="WordPress.Security.EscapeOutput.ExceptionNotEscaped"/>
<!-- These overrides are useful for code hinting -->
<exclude name="Generic.CodeAnalysis.UselessOverridingMethod.Found"/>
<!-- We do direct DB queries for our custom tables, and we have custom caching. -->
<exclude name="WordPress.DB.DirectDatabaseQuery.DirectQuery"/>
<exclude name="WordPress.DB.DirectDatabaseQuery.NoCaching"/>
<!-- We like short array syntax -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
<!-- Multiple throws tags are fine -->
<exclude name="Squiz.Commenting.FunctionCommentThrowTag.WrongNumber"/>
</rule>
<!-- Include some other sniffs we want to enforce. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.VersionControl.GitMergeConflict"/>
<rule ref="Generic.WhiteSpace.SpreadOperatorSpacingAfter"/>
<rule ref="PSR12.Classes.AnonClassDeclaration"/>
<rule ref="PSR12.Functions.NullableTypeDeclaration"/>
<rule ref="PSR12.Functions.ReturnTypeDeclaration"/>
<rule ref="PSR12.Properties.ConstantVisibility"/>
<rule ref="Squiz.Classes">
<exclude name="Squiz.Classes.ClassDeclaration.OpenBraceNewLine"/>
<exclude name="Squiz.Classes.ClassDeclaration.CloseBraceSameLine"/>
</rule>
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Set the appropriate text domain. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="google-listings-and-ads"/>
</properties>
</rule>
<!-- Add manage_woocommerce to accepted user capabilities -->
<rule ref="WordPress.WP.Capabilities">
<properties>
<property name="custom_capabilities" type="array">
<element value="manage_woocommerce"/>
</property>
</properties>
</rule>
<!-- We allow the use of / in hooks -->
<rule ref="WordPress.NamingConventions.ValidHookName">
<properties>
<property name="additionalWordDelimiters" value="/"/>
</properties>
</rule>
<!-- We don't use these functions for purposes of obfuscation -->
<rule ref="WordPress.PHP.DiscouragedPHPFunctions">
<properties>
<property name="exclude" type="array">
<element value="obfuscation"/>
</property>
</properties>
</rule>
<!-- We'd rather use native functions -->
<rule ref="WordPress.WP.AlternativeFunctions">
<properties>
<property name="exclude" type="array">
<element value="json_encode"/>
<element value="rand"/>
</property>
</properties>
</rule>
<!-- We're judicious in our usage of meta queries -->
<rule ref="WordPress.DB.SlowDBQuery">
<properties>
<property name="exclude" type="array">
<element value="slow_db_query"/>
</property>
</properties>
</rule>
<!-- We utilize views, and almost never work on global scope -->
<!-- See: https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#global-wp-variable-override-check-in-the-global-namespace -->
<rule ref="WordPress.WP.GlobalVariablesOverride">
<properties>
<property name="treat_files_as_scoped" value="true"/>
</properties>
</rule>
<!-- Check the main PHP file and everything in src/ -->
<arg name="extensions" value="php"/>
<file>./src</file>
<file>./bin</file>
<file>./views</file>
<file>./google-listings-and-ads.php</file>
<!-- Show progress and sniff codes in all reports -->
<arg value="ps"/>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>./tests/*</exclude-pattern>
<exclude-pattern>./js/*</exclude-pattern>
</ruleset>