(Pardon, I hit "send" while typing :/)
I was saying, you can find several examples of wrong and correct code at
[1].
Thiemo pointed out that this patch could encourage to write shorter and
less readable code (you can find his rationale in Gerrit comments), and I
partly agree with him. My proposal is to only trigger the sniff if the "if"
conditions are "short" enough. Which could mean either a single condition,
shorter than xxx characters etc.
We're looking for some feedback to know whether you would deem this feature
useful, and how to tweak it in order to avoid encouraging bad code.
Thanks to you all, and again - sorry for the half message.
Daimona
[0] -
https://gerrit.wikimedia.org/r/#/c/mediawiki/tools/codesniffer/+/486813/
[1] -
https://gerrit.wikimedia.org/r/#/c/mediawiki/tools/codesniffer/+/486813/16/…
Il giorno sab 9 feb 2019 alle ore 12:30 Daimona <daimona.wiki(a)gmail.com> ha
scritto:
Currently, there's a patch under review [0] to
enable a PHP sniff which
would detect so called "Pointless conditionals". These are conditionals
(if...else or ternary) where both branches only assign or return a boolean
value, and which could potentially one-lined using the if condition. T