Update WordPress-VIP-Go/ruleset.xml to configure VariableAnalysis#690
Update WordPress-VIP-Go/ruleset.xml to configure VariableAnalysis#690rebeccahum merged 2 commits intodevelopfrom
Conversation
|
This PR is testable with the following <?xml version="1.0"?>
<ruleset>
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
<properties>
<property name="allowUndefinedVariablesInFileScope" value="false"/>
<property name="allowUnusedVariablesInFileScope" value="false"/>
</properties>
</rule>
</ruleset>And the following <?php
$my_foo = 'foo';
echo $my_bar;and running With both properties as false, two violations will appear. By changing each of the properties to However... There are two issues in VariableAnalysis 2.x (cc @sirbrillig) that I think make these not as useful as they could be:
So while this PR will enable some redundant violations of unused or undefined variables in the file-scope (typically in WP template files) to not be reported, others still will be for now. |
Hopefully https://github.com/sirbrillig/phpcs-variable-analysis/releases/tag/v2.11.1 will resolve the issues you were seeing. |
|
@sirbrillig - Thank you for your prompt work and release! cc @gudmdharalds as we'll want to bump the bot to use 2.11.1. @rebeccahum We'll probably also want to bump VIP-Coding-Standards/composer.json Line 20 in 086b3da |
|
Updated |
|
@GaryJones : Given the discussion above, I guess it is safe to merge this PR? |
This patch will configure
VariableAnalysisforWordPress-VIP-Goso not to report on undefined variables under certain circumstances. To quote an issue reported forvip-go-ci:This patch will accomplish this, reducing noise a bit for our end-users.
See here for more discussion.
Details on testing
The following code was put into a file:
And
phpcsrun with the patch applied:With the patch removed, this warning here is added to the results:
The same pattern was seen with this code here, using the same command:
With the patch applied, this was reported:
and without the patch, this was added: