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

Bug #20367 --ignore does not accept pipes in <patterns>
Submitted: 2014-08-11 02:51 UTC
From: jeremyclassic Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.4)
PHP Version: 5.4.30 OS: OSX 10.9.4
Roadmaps: (Not assigned)    
Subscription  


 [2014-08-11 02:51 UTC] jeremyclassic (Jeremy Edgell)
Description: ------------ The delimiter used to bookend the patterns provided via --ignore fails when pipe " | " are used in the expression. It is not standard practice to utilize a character which has an evaluative meaning in a regular expression as a delimiter. In this case, the pipe means "OR". See attempted command in "Test Script". Using a pipe in regular expressions is, I think, a very common thing, especially when evaluating against paths and file extensions. This error is remedied by changing the regular expression delimiters to any other acceptable delimiter resolves the issue: http://php.net/manual/en/regexp.reference.delimiters.php#10637 1 Test script: --------------- /usr/local/bin/phpcs --standard=PSR2 --ignore="\.(svn|git)/","\.(phtml|html|xml|js|css|less|scss|xml|txt|java|svg|sql|png|jpg|gif|doc|pdf|odt|md)","*/(docs|vendor)/*" -w --report=xml "/path/to/my/repo/vendor/kzykhys/git/README.md" Expected result: ---------------- <?xml version="1.0" encoding="UTF-8"?> <phpcs version="1.5.4"> </phpcs> Actual result: -------------- PHP Warning: preg_match(): Unknown modifier 'g' in /usr/local/Cellar/php-code-sniffer/1.5.4/CodeSniffer.php on line 1285 Warning: preg_match(): Unknown modifier 'g' in /usr/local/Cellar/php-code-sniffer/1.5.4/CodeSniffer.php on line 1285 PHP Warning: preg_match(): Unknown modifier 'h' in /usr/local/Cellar/php-code-sniffer/1.5.4/CodeSniffer.php on line 1285 Warning: preg_match(): Unknown modifier 'h' in /usr/local/Cellar/php-code-sniffer/1.5.4/CodeSniffer.php on line 1285 PHP Warning: preg_match(): Unknown modifier 'v' in /usr/local/Cellar/php-code-sniffer/1.5.4/CodeSniffer.php on line 1285 Warning: preg_match(): Unknown modifier 'v' in /usr/local/Cellar/php-code-sniffer/1.5.4/CodeSniffer.php on line 1285 ^C

Comments

 [2014-08-11 03:10 UTC] jeremyclassic (Jeremy Edgell)
 [2014-08-11 03:44 UTC] jeremyclassic (Jeremy Edgell)
Forgot to include my use case: In my situation, I'm using this with Jenkins, for an automated build, but I could easily see something like this being used for a git hook to prevent themselves from submitting bad code before it got to their CI server for a build.
 [2014-08-11 04:38 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
I already came across this, but only made the modifications in the 2.x version because I want to keep 1.x as stable as possible during the 2.x testing. The commit is here: https://github.com/squizlabs/PHP_CodeSniffer/commit/26e53a807b27cdec8ee65dc d0620097e8dc2ae18 While I haven't had any reports of problems yet, I don't want to back-port it with 2.x only a couple of months from going stable. Thanks for the PR is any case. It would be great if you could test the 2.x version and see if it solves your problems.
 [2014-08-28 09:49 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed