Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #19820 Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff
Submitted: 2013-02-13 19:56 UTC
From: yunosh Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.4)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 26 - 9 = ?

 
 [2013-02-13 19:56 UTC] yunosh (Jan Schneider)
Description: ------------ Whether to report an error vs. warning is wrong. An empty catch statement makes sense, so it should be warning, anything else an error. It's exactly the opposite at the moment.

Comments

 [2013-02-18 08:09 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
I didn't write that sniff and I've never used it so I can't comment on the authors intentions. But despite the fact that the author wrote unit tests to enforce errors and warnings in a particular way, I agree that it seems backwards. I can see uses cases for empty catch statements, but not for empty foreach, for, do etc statements. So I committed a fix to the github repo here: https://github.com/squizlabs/PHP_CodeSniffer/commit/44f7cc86ea688f2726ce5c798bf ecf960c5ad5cc I just reversed the severity levels and changed the unit tests.