forked from google/site-kit-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpcs.xml
100 lines (90 loc) · 3.97 KB
/
phpcs.xml
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
<?xml version="1.0"?>
<ruleset name="Site Kit by Google Project Rules">
<rule ref="WordPress-Docs">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress-Extra">
<!-- Ignore WordPress core file naming conventions since Site Kit uses PSR-4 -->
<exclude name="WordPress.Files.FileName"/>
<!-- Site Kit doesn't use base64 encoding functions to "obfuscate code" -->
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode"/>
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode"/>
<!-- Allow short ternary -->
<exclude name="WordPress.PHP.DisallowShortTernary" />
<!-- Prevent this from showing up as a warning on every run. See WordPress/WordPress-Coding-Standards#1425 -->
<exclude name="WordPress.WP.TimezoneChange.DeprecatedSniff"/>
</rule>
<!-- Use correct textdomain -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="google-site-kit"/>
<!-- Use default text domain when relying on WP core strings. -->
<element value="default"/>
</property>
</properties>
</rule>
<!-- Include only WordPress-VIP-Go rules but not the ruleset since it makes WPCS less strict -->
<rule ref="WordPressVIPMinimum.Functions">
<!-- Allow user meta since for Site Kit there is no alternative -->
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_add_user_meta"/>
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_delete_user_meta"/>
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_get_user_meta"/>
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_update_user_meta"/>
</rule>
<rule ref="WordPressVIPMinimum.Performance"/>
<rule ref="WordPressVIPMinimum.Files">
<exclude name="WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant"/>
<exclude name="WordPressVIPMinimum.Files.IncludingFile.UsingVariable"/>
</rule>
<rule ref="WordPressVIPMinimum.UserExperience"/>
<rule ref="WordPressVIPMinimum.Security"/>
<rule ref="VariableAnalysis">
<!-- This sniff is severely broken, flaggin e.g. $this as undefined variable -->
<exclude name="VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable"/>
<!-- This sniff flags unused exception variables which cannot be avoided -->
<exclude name="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable"/>
</rule>
<!-- Show details about violated sniffs -->
<arg value="s"/>
<!-- Iterate over all PHP files by default -->
<arg name="extensions" value="php"/>
<file>.</file>
<!-- Test-specific exclusions -->
<rule ref="WordPress.DB.DirectDatabaseQuery">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.DB.SlowDBQuery">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.NamingConventions">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Security.EscapeOutput">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Security.NonceVerification">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Security.ValidatedSanitizedInput">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.GlobalVariablesOverride">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!-- Third-party and generated code -->
<exclude-pattern>includes/Core/Assets/Manifest.php</exclude-pattern>
<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>third-party/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Check for cross-version support for PHP 5.6 and higher. -->
<config name="testVersion" value="5.6-"/>
<config name="minimum_supported_wp_version" value="4.7"/>
<rule ref="PHPCompatibilityWP" />
</ruleset>