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

Request #11555 Equals sign alignment warnings too hard
Submitted: 2007-07-07 05:59 UTC
From: cweiske Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 0.7.0)
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 : 43 - 14 = ?

 
 [2007-07-07 05:59 UTC] cweiske (Christian Weiske)
Description: ------------ Hello Greg, The PEAR CS allow us to align equal signs so that readbility is increased ('more space may be inserted to promote readability'). While inserting spaces most times increases readability, this isn't true anymore for large numbers: $arData = explode(' ', $strValue); $arCells[$nCurrentCell]->quality = $arData[0]; Could you set a limit at which phpcs doesn't warn to align anymore? (maybe 15 chars?)

Comments

 [2007-07-07 06:01 UTC] cweiske (Christian Weiske)
Also, forcing alignment does not make sense if the resulting line would be longer than 85 chars.
 [2007-07-07 06:28 UTC] squiz (Greg Sherwood)
Hi Christian, This particular sniff only generates warnings and I don't want to change the PEAR CS without PEAR updating their CS docs. However, this sniff lives in the Generic CS, so I can add features to the generic sniff to set limits as to when phpcs suggests you align equals signs. So what you'll probably have to do is either ignore the warnings that you don't want to fix, or create your own standard. I guess the other option is en email to PEAR Dev about changing the standard, or at least adjusting it.
 [2007-07-08 09:23 UTC] cweiske (Christian Weiske)
So does one have the possibility to just provide a file with all directives that shall be ignored and run phpcs with out this rules?
 [2007-07-08 09:37 UTC] squiz (Greg Sherwood)
Well you can either hide warnings using the -n command line arg, or you can create a new coding standard with only the standards you want included or excluded. See the end user docs for how to create a coding standard and use the class methods. The PHPCS coding standard in CVS is a very good example as well. In your case, you'll want to include all of the PEAR CS and just exclude the one Generic sniff that does assignment alignments.
 [2007-07-11 02:03 UTC] squiz (Greg Sherwood)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Previously, you could extend the Generic sniff MultipleStatementAlignment and change the value of "error" to change the warnings to errors. You can now change the value of "maxPadding", from the default of 1000, to something like 15. If the number of spaces required to align the statement exceeds this number, no error or warning will be thrown.