Skip to content

ForbiddenGlobalVariableVariable: fix false positives and more#564

Merged
wimg merged 1 commit intomasterfrom
feature/537-fix-false-positive-forbidden-global-variable-variable
Dec 25, 2017
Merged

ForbiddenGlobalVariableVariable: fix false positives and more#564
wimg merged 1 commit intomasterfrom
feature/537-fix-false-positive-forbidden-global-variable-variable

Conversation

@jrfnl
Copy link
Copy Markdown
Member

@jrfnl jrfnl commented Dec 24, 2017

The ForbiddenGlobalVariableVariable sniff was a little overzealous and would throw errors for valid variable variables.

The sniff has now been partially refactored.

The following improvements were made:

  • Don't throw errors for non-complex variable variables. Issue ForbiddenGlobalVariableVariable false positive #537.
  • Correctly handle variable variables with whitespace or comments within the variable.
  • Throw an error for each forbidden variable. Previously only one error would be thrown per global statement.
    • The error is now thrown on the line containing the variable, not the line containing the global keyword.
    • The error message now shows the problem variable encountered.
  • Throw a warning for non-bare variables encountered in a global statement.
    • This warning has a separate errorcode allowing for easy exclusion.
    • The warning, like the error, will show the problem variable encountered.

The unit tests have been redone to account for these changes.

Fixes #537

@wimg If needed, the warning can be taken out quite easily. Let me know if you don't want it in the sniff.

The `ForbiddenGlobalVariableVariable` sniff was a little overzealous and would throw errors for valid variable variables.

The sniff has now been partially refactored.

The following improvements were made:
* Don't throw errors for non-complex variable variables. Issue 537.
* Correctly handle variable variables with whitespace or comments within the variable.
* Throw an `error` for *each* forbidden variable. Previously only one error would be thrown per `global` statement.
    - The error is now thrown on the line containing the variable, not the line containing the `global` keyword.
    - The error message now shows the problem variable encountered.
* Throw a `warning` for non-bare variables encountered in a `global` statement.
    - This warning has a separate errorcode allowing for easy exclusion.
    - The warning, like the error, will show the problem variable encountered.

The unit tests have been redone to account for these changes.

Fixes 537
@wimg wimg merged commit 86b6738 into master Dec 25, 2017
@wimg wimg deleted the feature/537-fix-false-positive-forbidden-global-variable-variable branch December 25, 2017 21:36
@jrfnl jrfnl added this to the 8.1.0 milestone Dec 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants