Skip to content

Commit

Permalink
YoastCS rules: flag unused/undefined variables
Browse files Browse the repository at this point in the history
Related to 303

Impact on Yoast packages (individual results still need review):

| Plugin/Tool       | Errors/Warnings |
|-------------------|-----------------|
| PHPUnit Polyfills | --
| WP Test Utils     | --
| YoastCS           | 5
| WHIP              | 1
| Yoast Test Helper | 5
| Duplicate Post    | --
| Yst ACF           | --
| Yst WooCommerce   | --
| Yst News          | 2
| Yst Local         | 99
| Yst Video         | 38
| Yst Premium       | 33
| Yst Free          | 108
  • Loading branch information
jrfnl committed Dec 14, 2023
1 parent a16917a commit 106b5e3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Yoast/Reports/Threshold.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* available which can be used in calling scripts.
*
* @since 2.2.0
*
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Flags unused params which are required via the interface. Invalid.
*/
final class Threshold implements Report {

Expand Down
19 changes: 19 additions & 0 deletions Yoast/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,25 @@
</rule>


<!--
#############################################################################
SNIFF FOR USE OF UNDEFINED/UNUSED VARIABLES
#############################################################################
-->
<rule ref="VariableAnalysis">
<properties>
<property name="allowUnusedCaughtExceptions" value="true"/>
<property name="allowUnusedParametersBeforeUsed" value="true"/>
<property name="allowUnusedForeachVariables" value="true"/>
<property name="allowWordPressPassByRefFunctions" value="true"/>

<!-- These two properties (attempt to) prevent false positives for interaction with views. -->
<property name="allowUnusedVariablesBeforeRequire" value="true"/>
<property name="allowUndefinedVariablesInFileScope" value="true"/>
</properties>
</rule>


<!--
#############################################################################
ADD SOME SPECIFIC EXTRA SNIFFS
Expand Down

0 comments on commit 106b5e3

Please sign in to comment.