#14598 closed defect (bug) (invalid)
Minor coding standard flaws?
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | dev-feedback |
| Cc: | wojtek.szkutnik@… |
Description
While browsing the WP code I found a lot of minor coding standard flaws, like wrong-side comparisons ( "if x !== false instead" of "if false !== x" etc). It's a very low-priority thing, but maybe we could correct these things for the sake of code beauty? I could submit a patch, but as there is dozens of these things, it could get outdated very soon...
Change History (5)
comment:2
in reply to:
↑ description
;
follow-up:
↓ 3
filosofo — 3 years ago
Replying to wojtek.szkutnik:
While browsing the WP code I found a lot of minor coding standard flaws, like wrong-side comparisons ( "if x !== false instead" of "if false !== x" etc).
The point of doing those "Yoda conditions" is to be part of a practice that catches mistakes at the point of code construction. After the code is written, their value is gone. So I wouldn't spend time addressing them aside from when they're code changed for other reasons, as sribu suggests.
comment:3
in reply to:
↑ 2
wojtek.szkutnik — 3 years ago
- Cc wojtek.szkutnik@… added
- Resolution set to invalid
- Status changed from new to closed
Replying to filosofo:
Replying to wojtek.szkutnik:
While browsing the WP code I found a lot of minor coding standard flaws, like wrong-side comparisons ( "if x !== false instead" of "if false !== x" etc).
The point of doing those "Yoda conditions" is to be part of a practice that catches mistakes at the point of code construction. After the code is written, their value is gone. So I wouldn't spend time addressing them aside from when they're code changed for other reasons, as sribu suggests.
That's the conclusion I came to after opening the ticket. However, I disagree with "yoda conditions" being useless after the code is written. It makes code more readable and helps avoid more mistakes when any changes are needed, so correcting them further along the way might prove to be useful. This being said, I close the ticket ;)

I think a good strategy is to fix coding standards along the way, as you work on other things.