Open deviantintegral opened 2 years ago
I don't accept new sniffs often unless they are part of a published standard. I think this sounds like a good idea but I'd want it to have more support before accepting it so I know it's going to provide enough value for the extra code maintenance.
An easy mistake to make (and an easy one to miss in code review) is to accidentally use a single
&
or|
inside of an if or other conditional. For example, I recently discovered a long-lived bug along the lines of:if (file_exists($path) & filesize($path) != 0) {
At least in the code our teams write, it's very rare that they work with bitfields. Would the maintainers be open to adding a sniff in
\PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis
to detect this? As a first pass, I think the sniff would check inside ofif
,while
, anddo...while
clauses. This would avoid false positives on assignments.If there's interest, we'd be glad to contribute a PR to make this happen. Thanks!
To gauge interest, please leave a 👍 on this comment you would use this sniff, 👎 if not.