[PEAR-BUG] Bug #20367 [Opn]: --ignore does not accept pipes in <patterns>

[email protected]
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at https://pear.php.net/bugs/bug.php?id=20367&edit=1

 ID:               20367
 Updated by:       [email protected]
 Reported By:      edgellj at gmail dot com
 Summary:          --ignore does not accept pipes in <patterns>
 Status:           Open
 Type:             Bug
 Package:          PHP_CodeSniffer
 Operating System: OSX 10.9.4
 Package Version:  1.5.4
 PHP Version:      5.4.30
 Roadmap Versions: 
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[2014-08-10 23:10:38] jeremyclassic

Added #patch
bug:20367;patch:20367-change-ignore-delimeters;revision:1407708638;.

------------------------------------------------------------------------

[2014-08-10 22:51:32] jeremyclassic

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

------------------------------------------------------------------------


-- 
Edit this bug report at https://pear.php.net/bugs/bug.php?id=20367&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.