Skip to content

Commit adcc190

Browse files
committed
feat: check variable usage with VariableAnalysis ruleset
1 parent 4c50ae9 commit adcc190

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Kleinweb/ruleset.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ SPDX-License-Identifier: GPL-3.0-or-later AND MIT
5757

5858
<!-- === Rules ============================================================================= -->
5959

60+
<!-- Detect undefined and unused variables. -->
61+
<rule ref="VariableAnalysis"/>
62+
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
63+
<properties>
64+
<!-- <https://github.com/sirbrillig/phpcs-variable-analysis#:~:text=allowWordPressPassByRefFunctions> -->
65+
<property name="allowWordPressPassByRefFunctions" value="true"/>
66+
<!-- Allow unused variables with the underscore prefix (e.g. `$_fnord`) -->
67+
<property name="ignoreUnusedRegexp" value="/^_/"/>
68+
</properties>
69+
</rule>
70+
6071
<!--
6172
We are not hosted on WordPress VIP, but their standards generally reflect
6273
best practices in WordPress development. While the rules tend to reflect

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"php": ">=8.1",
99
"automattic/vipwpcs": "^3.0",
1010
"dealerdirect/phpcodesniffer-composer-installer": "*",
11+
"sirbrillig/phpcs-variable-analysis": "^2.12",
1112
"slevomat/coding-standard": "^8.16.0",
1213
"squizlabs/php_codesniffer": "^3.7.2",
1314
"wp-coding-standards/wpcs": "^3.0"

0 commit comments

Comments
 (0)