-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
New Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence
sniff
#197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context for others: this PR has already been extensively reviewed in PHPCSStandards/PHPCSExtra#271 .
@TimWolla Thank you for porting this PR over and all your work on it!
I just have two questions (and I'd be happy to fix this up myself as discussed off-GH):
- In Add Universal.CodeAnalysis.MixedBooleanOperator PHPCSExtra#271 we ended up renaming the sniff to
RequireExplicitBooleanOperatorPrecedence
. Is there a pertinent reason why that change was not made for this PR ?
(this also means there is now a mismatch between the sniff name and thetitle
attribute for the docs) - In Add Universal.CodeAnalysis.MixedBooleanOperator PHPCSExtra#271 the sniff docblock contains some additional information about the choices made for this sniff, while here it contains a code sample. Any particular reason for that ?
Other than that, all good. 👍🏻
No, this is an oversight. After the review I've copied over just the implementation and tests into squizlabs/PHP_CodeSniffer#3205, because of the differences in code style / namespace between PHPCSExtra and CodeSniffer itself and missed adjusting the "basename" of the Sniff - and this PR is just a respin of that older CodeSniffer PR.
Yes. Existing Sniffs in CodeSniffer itself contain a code sample within their docblocks. Here's an example: https://github.com/squizlabs/PHP_CodeSniffer/blob/c6c65ca0dc8608ba87631523b97b2f8d5351a854/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php#L9-L23
I'd appreciate if you could perform the last few changes yourself. This would ensure that the result looks exactly like you wish it to be, without a back-and-forth taking up valuable time for both of us - especially since CI would need explicit approval for every additional push I make. But please let me know if I can do something to make that process easier for you (e.g. squashing the existing commits in this PR or so). |
@TimWolla Thanks for your response, I just wanted to verify/confirm, that was all. 👍🏻 I'll make those last changes myself and will rebase and squash the commits before merging. |
Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence
sniff
Thank you! |
@TimWolla It took a little while, but we got there in the end! Thank you for working with me on this one. |
3 years and 2 days since opening the first PR on the old CodeSniffer repository 😁 |
…niff (#197) This PR adds a sniff that detects mixed boolean operators (`&&`, `||`) within a single expression without making precedence clear using parentheses.
Ouch... well, at least from when we moved it to PHPCSExtra (and active review started) till now is less than five months, so progress. ;-) |
Description
This is a simple respin of squizlabs/PHP_CodeSniffer#3205 in the new home of PHP CodeSniffer. I've rebased the branch onto the latest master, the resulting diff should be identical, except for package.xml, which no longer exists, and the addition of the XML doc taken from PHPCSStandards/PHPCSExtra#271.
Suggested changelog entry
Add
MixedBooleanOperatorSniff++RequireExplicitBooleanOperatorPrecedence++ - Forbid mixing different binary boolean operators within a single expression without making precedence clear using parentheses.Related issues/external references
Closes squizlabs/PHP_CodeSniffer#3205
Closes PHPCSStandards/PHPCSExtra#271
Types of changes
PR checklist