Login
Make sub _parse_private_name_regex() the parser for parameter
authorTom Wyant <harryfmudd@comcast.net>
Sat, 31 Oct 2009 20:12:55 +0000 (20:12 +0000)
committerTom Wyant <harryfmudd@comcast.net>
Sat, 31 Oct 2009 20:12:55 +0000 (20:12 +0000)
private_name_regex in P::C::P::Subroutines::ProhibitUnusedPrivateSubroutines.

Remove the negative lookahead assertion on 'parse_' in the
ProhibitUnusedPrivateSubroutines setup, since with the above fix and the
previous one on ProtectPrivateSubs it is no longer needed.

lib/Perl/Critic/Policy/Subroutines/ProhibitUnusedPrivateSubroutines.pm
xt/author/40_perlcriticrc-code

index 3332dac..803aa81 100644 (file)
@@ -40,6 +40,7 @@ sub supported_parameters {
             description     => 'Pattern that determines what a private subroutine is.',
             default_string  => '\b_\w+\b',
             behavior        => 'string',
+            parser          => \&_parse_private_name_regex,
         },
         {
             name            => 'allow',
@@ -59,6 +60,8 @@ sub applies_to           { return 'PPI::Statement::Sub'  }
 
 sub _parse_private_name_regex {
     my ($self, $parameter, $config_string) = @_;
+    defined $config_string
+        or $config_string = $parameter->get_default_string();
 
     my $regex;
     eval { $regex = qr/$config_string/; 1 } ## no critic (RegularExpressions)
index 9a9bfdb..4f1ff8d 100644 (file)
@@ -47,7 +47,7 @@ allow_all_brackets = 1
 allow_all_brackets = 1
 
 [Subroutines::ProhibitUnusedPrivateSubroutines]
-private_name_regex = _(?!_|parse_)\w+
+private_name_regex = _(?!_)\w+
 allow = _get_behavior_values _get_description_with_trailing_period
 
 [Subroutines::ProtectPrivateSubs]