Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 36098
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: EDAVIS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.082
Fixed in: 1.105



Subject: RegularExpressions::ProhibitComplexRegexes should not penalize long variable names
This test program: #!/usr/bin/perl use warnings; use strict; use 5.010; my $unchanged_re = qr/unchanged|stable/; my $some_nondigit_blurb_re = qr/[a-zA-Z .,()-]{1,100}/; my $number_re = qr/\d+[.]\d+/; my $blurb = 'At 12.34, the number was down from 12.44 yesterday'; $blurb =~ /^At ($number_re),? $some_nondigit_blurb_re ($number_re|$unchanged_re)/o; say "$1, was $2"; run through 'perlcritic -single-policy RegularExpressions::ProhibitComplexRegexes' generates a warning. This is a bit odd, because the PBP guideline says to break down a large regexp into smaller components, and the code does just that. However if you rename the variables to cryptic $u, $s, and $n, the code does not trigger the warning. perlcritic must use some heuristic to judge the 'complexity' of a regexp, and that can never be perfect, but it needs to do more than just count characters (which I guess it's doing at the moment) or otherwise allow for descriptive variable names.
Subject: Re: [rt.cpan.org #36098] RegularExpressions::ProhibitComplexRegexes should not penalize long variable names
Date: Thu, 22 May 2008 09:40:20 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
EDAVIS via RT wrote: Show quoted text
> perlcritic must use some heuristic to judge the 'complexity' of a > regexp, and that can never be perfect, but it needs to do more than just > count characters (which I guess it's doing at the moment) or otherwise > allow for descriptive variable names.
Yeah, P::C itself is bitten by this. A bit of a pain.
Proposed fix submitted to trunk as svn revision 3470. This is basically the same hack that was used for \P. Tom Wyant
Has this fix been included in the 1.103 release? The test program gives the same result as before.
On Wed Aug 19 12:41:51 2009, EDAVIS wrote: Show quoted text
> Has this fix been included in the 1.103 release? The test program gives > the same result as before.
The fix appears not to be in 1.103, which had other fish to fry. It does appear to be in 1.104. At least, $ perlcritic --single ProhibitComplexRegexes rt36098.PL says "rt36098.PL source OK" when I run it. Tom Wyant
Just realized that my fix for this was being applied even when it should not be (e.g m'$this_is_not_interpolated'). Proposed fix for the fix committed as svn revision 3646.
It appears to me that all fixes (including the PS) are in 1.105, so I'm marking this resolved.