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

Bug #19283 CSS @media rules cause false positives
Submitted: 2012-02-10 05:07 UTC
From: klausi Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version SVN)
PHP Version: 5.3.9 OS: Ubuntu 11.10
Roadmaps: (Not assigned)    
Subscription  


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 : 47 - 29 = ?

 
 [2012-02-10 05:07 UTC] klausi (Klaus Purer)
Description: ------------ CSS @media rules can contain nested CSS definitions. 2 sniffs are not prepared for that, patch attached. See also the example CSS test snippet. Test script: --------------- @media screen and (max-device-width: 769px) { header #logo img { max-width: 100%; } } Expected result: ---------------- All CSS sniffs should pass. Actual result: -------------- Squiz_Sniffs_CSS_IndentationSniff and Squiz_Sniffs_CSS_MissingColonSniff report false positives.

Comments

 [2012-02-10 05:08 UTC] klausi (Klaus Purer)
 [2012-02-10 05:08 UTC] klausi (Klaus Purer)
 [2012-02-10 05:54 UTC] squiz (Greg Sherwood)
-Summary: CSS @media rules +Summary: CSS @media rules cause flase positives -Assigned To: +Assigned To: squiz
 [2012-02-10 05:54 UTC] squiz (Greg Sherwood)
-Summary: CSS @media rules cause flase positives +Summary: CSS @media rules cause false positives
 [2012-02-10 05:56 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Fixed in Git: https://github.com/squizlabs/PHP_CodeSniffer/commit/440d99d022314ae187b3a39f2 826b129a6d97806 Thanks again for another great patch.
 [2012-02-10 20:37 UTC] klausi (Klaus Purer)
-Status: Closed +Status: Open
Here is a followup patch that addresses some white space issues in the sniffs. I think a nested rule definition should not be treated as class definition. Therefore blank lines should be allowed in it. CSS Test sample: -------------------- @media screen and (max-device-width: 769px) { header #logo img { max-width: 100%; } .inner { min-width: 1281px; max-width: 1500px; } }
 [2012-02-10 20:37 UTC] klausi (Klaus Purer)
 [2012-02-13 11:05 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Feedback
I couldn't use your patch directly because here was a typo in the indentation sniff (wrong var, minor thing), it didn't quite work with multiple classes in the nested area and I actually wanted to enforce spacing around the braces of a nesting class definition anyway. So I've updated the sniffs you identified and another as well. THe git repo has been updated. Relevant commits: https://github.com/squizlabs/PHP_CodeSniffer/commit/f09151959e8d0bdb93b50b8f1 04f1945a303213f https://github.com/squizlabs/PHP_CodeSniffer/commit/d18cd88150e8a80400bae36d2 12cb1795c612f8f Hopefully that fixes the problems with nested classes. Let me know if you find more and thanks for all your help so far.
 [2012-03-12 07:38 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
Closing as I haven't got feedback about the latest change. If something isn't working, please reopen and let me know.