[PEAR-BUG] Doc #20369 [Opn->Fbk]: Unclear usage of regexes in exclude patterns

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

 ID:               20369
 Updated by:       [email protected]
 Reported By:      pear at larsheber dot de
 Summary:          Unclear usage of regexes in exclude patterns
-Status:           Open
+Status:           Feedback
 Type:             Documentation Problem
 Package:          PHP_CodeSniffer
 Package Version:  2.0.0RC1
 PHP Version:      Irrelevant
-Assigned To:      
+Assigned To:      squiz
 Roadmap Versions: 
 New Comment:

-Status:      Open
+Status:      Feedback
-Assigned To:
+Assigned To: squiz
1. Comma is used to separate patterns on the command line, so you need
to 
escape any commas you use in the patterns themselves. So I remove the
escape 
chars for commas only. The * -> .* change is just a convenience thing,
as was the 
norm when I added this feature years ago. It's easier to just do --
exclude=*/tests/*. Removing this would be a huge backwards compatibly
break, so 
I'd never do it.

2. I assume you mean this code from where files are excluded:
if (DIRECTORY_SEPARATOR === '\\') {
    $replacements['/'] = '\\\\';
}

That code isn't present when doing sniff exclusions. I don't think there
is any 
reason for that and it can be added in easily. Before I do, is this what
you are 
talking about specifically?


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

[2014-08-11 08:57:11] pittiplatsch

Description:
------------
Hello,
due to quite incomplete docs I'm trying to find out the exact
possibilities of exclude patterns by inspecting the sources.

However, some questions remain:
1.
Obviously, exclude patterns are rendered as regexes. In some issues
concerning excl-pat's regular expression syntax is 

recommended (e.g. issue #19648).
However, what's the point then of hard-coded string-replace of "\\," to
"," and "*" to ".*" before processing the regex?
a)
I see some convenience to simply use "*" - but this leads to some
regexes failing where they shouldn't:
The regex "^application/test.*\.php" is changed to
"^application/test..*\.php" which leads the file "application/test.php"


to fail although my original regex includes this file!
b)
What about the "\\," to "," thing?

2.
Why are exclude patterns processed differently for global use and
per-sniff?
I have the concrete problem that (using Windows) for global usage both
patterns "application\\" and "application/" work 

perfectly fine, while on per-sniff basis only "application\\" works
which obviously prevents portability to *NIX systems.

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


-- 
Edit this bug report at https://pear.php.net/bugs/bug.php?id=20369&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.