[PEAR-BUG] Bug #20367 [Opn->Fbk]: --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
+Status:           Feedback
 Type:             Bug
 Package:          PHP_CodeSniffer
 Operating System: OSX 10.9.4
 Package Version:  1.5.4
 PHP Version:      5.4.30
-Assigned To:      
+Assigned To:      squiz
 Roadmap Versions: 
 New Comment:

-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.


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

[2014-08-10 23:44:07] jeremyclassic

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-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.