15 of 20 grant-funded Perl::Critic policies done

ChrisDolan on 2007-09-13T06:34:29

I wrote one pretty easy policy this week (RegularExpressions::ProhibitComplexRegexes) and one really hard one (RegularExpressions::ProhibitUnusedCaptures).

If any readers test that latter policy against some real world code, I'd appreciate the help. TO do so, get a Perl:Critic SVN checkout from the Perl-Critic-1.xxx branch and run P::C as usual. I'm concerned that there may be several scenarios I didn't think of. The problem sounds simple: make sure all captures get used somehow, either via $1, $2, ... variables or by catching the return value from the regexp in array context. But there are so many ways of doing either of those things...

Both of the new policies make use of Regexp::Parser by Jeff "japhy" Pinyan (because PPI doesn't parse the actual regexes). If you don't have that optional module installed, the policies pass silently. Regexp::Parser has a few missing features of regexp syntax, but nothing too important. My biggest complaint is that if you want it to parse with an "x" flag, you have to explicitly wrap the regexp with "(?x:...)" and there's no easy way to get just a subtree of the object model.

Interested in getting involved in P::C? Send a note to the P::C developer list and we'd be happy to point out a few policies on the to-do list that would be straightforward to write for a newcomer.