moodlehq / moodle-cs

Moodle Coding Style

Home Page:https://github.com/moodlehq/moodle-cs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Who turned on "Empty IF statement detected" and why?

timhunt opened this issue · comments

This code https://github.com/moodle/moodle/blob/328b48ebc592a8f0a551aacc6e2e447a50a50c90/mod/quiz/review.php#L196 has been there for years, and is the clearest way to express the correct logic. Who though that should start generating codechecker warnings? (I never saw a policy issue about this.)

In that case, perhaps upstream have changed the bahviour of that sniff recently, so they no longer count a comment as sufficient. (I fell it is reasonable to insist on a comment to explain when this patten is used.)

I've not looked if/when that behaviour has changed, but I'm pretty sure that it has been there since long, long ago.

Because I used to "abuse" those empty conditions a lot and now, instead, I always use conditions leading to real "food" (code) (and, personally, I think it's good practice).

Not defending anything, just saying/sharing that I think - 80% sure - it's not a "new" thing.

Ciao :-)

OK. Whatever.

There are times when I think the style leads to much cleaner code. I guess I can jsut ignore this rule when it complains.