Closed jedgell closed 10 years ago
Are you kidding me? So, I went to the trouble of installing the extra plugin and debugging down through that bit and I missed that you're calling toLowerCase() on the file name as well? How would a user know this? I'll get you a pull request back to you to fix this, but don't tell people they're entering a regular expression, if all you want is a pipe delimited list.
Thanks for your contribution ... This match-find issue is new to me.
Under the general settings, there's a field for an ignore regex. If you put a true regular expression in there, it fails. The method in use in code is [java.util.regex.Pattern.matches](http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#matches%28java.lang.String, java.lang.CharSequence%29) which is a convenience method that maps to java.util.regex.Matcher.matches after compiling the regular expression. The thing is...Matcher.matches() does not do true regular expression matching - it kinda does work, sorta. The string passed to Matcher.matches() as a regex might as well have ^ and $ wrapped around it, because it evaluates whether the passed in regex is the same as the string passed for comparison.
In phpcsmd/src/de/foopara/phpcsmd/generics/GenericHelper.java, you should be using Matcher.find(), in stead, as it actually runs a true comparison.
How I found this out: I elaborated on the pre-populated regex in the field to come up with the following:
The failures started happening immediately on .Ds_Store and README files in my project directory. Here are a couple example paths:
I tested the regex in PHP and JS interpreters. It works. I found on online Java Regular Expression Test Page (because I don't write Java) and it was able to test the regular expression against Matcher's many methods and link me to the JavaDoc, where I read this:
Please, if you're going to offer me the opportunity to write my own regular expression, do not crimp my style. Give me the find method and lemme go hog wild.
I have no mechanism for testing any code I might supply (because I don't write Java), so here's my suggested resolution:
Starting at line 157, something like:
I'm sorry for the very long winded message. This is the third project I've run into this week where an author has said "Put regex here:", and when I did, something funny was happening behind the scenes, and the lovely regex I'd crafted didn't work.