-
Notifications
You must be signed in to change notification settings - Fork 35
/
.phpcs.xml.dist
167 lines (136 loc) · 5.82 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="Duplicate Post"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Duplicate Post rules for PHP_CodeSniffer</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->
<file>.</file>
<!-- Only check PHP files. -->
<arg name="extensions" value="php"/>
<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps"/>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>
<!-- Cache the results between runs. -->
<arg name="cache" value="./.cache/phpcs.cache"/>
<!--
#############################################################################
USE THE YoastCS RULESET
#############################################################################
-->
<rule ref="Yoast">
<properties>
<!-- Set the custom test class list for all sniffs which use it in one go.
Ref: https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#custom-unit-test-classes
-->
<property name="custom_test_classes" type="array">
<element value="Yoast\WP\Duplicate_Post\Tests\Unit\TestCase"/>
</property>
<!-- Provide the plugin specific prefixes for all naming related sniffs. -->
<property name="prefixes" type="array">
<element value="Yoast\WP\Duplicate_Post"/>
<element value="duplicate_post"/>
<element value="dp_"/>
</property>
<property name="psr4_paths" type="array">
<element key="Yoast\WP\Duplicate_Post\Tests\\" value="tests/"/>
</property>
</properties>
<!-- This plugin is not dependent on YoastSEO, so the replacement function will not be available. -->
<exclude name="Yoast.Yoast.JsonEncodeAlternative"/>
</rule>
<!-- Enforce PSR1 compatible namespaces. -->
<rule ref="PSR1.Classes.ClassDeclaration">
<!-- YoastCS only applies this rule to test files. Overrule it to apply to all files. -->
<include-pattern>*\.php</include-pattern>
</rule>
<!--
#############################################################################
SNIFF SPECIFIC CONFIGURATION
#############################################################################
-->
<!-- Verify that all gettext calls use the correct text domain. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="duplicate-post"/>
<element value="default"/>
</property>
</properties>
</rule>
<rule ref="Yoast.NamingConventions.NamespaceName">
<properties>
<!-- Indicate which directories should be treated as project root directories for
path-to-namespace translations. -->
<property name="src_directory" type="array">
<element value="src"/>
</property>
</properties>
</rule>
<rule ref="Yoast.Files.FileName">
<properties>
<!-- Don't trigger on the main file as renaming it would deactivate the plugin. -->
<property name="excluded_files_strict_check" type="array">
<element value="duplicate-post.php"/>
</property>
<!-- Remove the following prefixes from the names of object structures. -->
<property name="oo_prefixes" type="array">
<element value="duplicate_post"/>
</property>
</properties>
</rule>
<!-- Make sure custom capabilities are recognized. -->
<rule ref="WordPress.WP.Capabilities">
<properties>
<property name="custom_capabilities" type="array">
<element value="copy_posts"/>
</property>
</properties>
</rule>
<!--
#############################################################################
SELECTIVE EXCLUSIONS
Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
#############################################################################
-->
<!-- TEST CODE -->
<!-- Valid usage: For testing purposes, some non-prefixed global constants are being created, which is fine. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
<exclude-pattern>/tests/*/bootstrap\.php$</exclude-pattern>
</rule>
<!--
#############################################################################
TEMPORARY ADJUSTMENTS
Adjustments which should be removed once the associated issue has been resolved.
#############################################################################
-->
<!-- The renaming of the hooks to use the namespace-like prefix is
a breaking change and will be planned in to be actioned
at a future date. -->
<rule ref="Yoast.NamingConventions.ValidHookName.WrongPrefix">
<exclude-pattern>/(admin|common)-functions\.php$</exclude-pattern>
<exclude-pattern>/src/(permissions-helper|post-(duplicator|republisher))\.php$</exclude-pattern>
<exclude-pattern>/src/ui/link-builder\.php$</exclude-pattern>
</rule>
<!-- Technical debt: nonce verification should be added to cover
all relevant uses of superglobals. This will be addressed
by the team at a future date. -->
<rule ref="WordPress.Security.NonceVerification.Missing">
<exclude-pattern>/src/handlers/save-post-handler\.php$</exclude-pattern>
</rule>
<rule ref="WordPress.Security.NonceVerification.Recommended">
<exclude-pattern>/src/post-republisher\.php$</exclude-pattern>
<exclude-pattern>/src/admin/options-page\.php$</exclude-pattern>
<exclude-pattern>/src/ui/bulk-actions\.php$</exclude-pattern>
<exclude-pattern>/src/ui/classic-editor\.php$</exclude-pattern>
<exclude-pattern>/src/watchers/(bulk|link)-actions-watcher\.php$</exclude-pattern>
<exclude-pattern>/src/watchers/republished-post-watcher\.php$</exclude-pattern>
</rule>
</ruleset>