WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#14598 closed defect (bug) (invalid)

Minor coding standard flaws?

Reported by: wojtek.szkutnik Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: dev-feedback
Focuses: Cc:

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:1 @scribu5 years ago

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

comment:2 in reply to: ↑ description ; follow-up: @filosofo5 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.szkutnik5 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 ;)

comment:4 @scribu5 years ago

  • Milestone Awaiting Review deleted

comment:5 @filosofo5 years ago

s/they're/their/

I guess I was writing phonetically.

Don't get me wrong; I think Yoda conditions are great and advocate their use.

Note: See TracTickets for help on using tickets.