-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update WordPress-VIP-Go/ruleset.xml to configure VariableAnalysis #690
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
VariableAnalysis
forWordPress-VIP-Go
so 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
phpcs
run 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: