Login
Moved the check for conditionals strings to the top of _is_conditional. Also set...
authorAndy Lester <andy@petdance.com>
Tue, 18 Jul 2006 05:50:36 +0000 (05:50 +0000)
committerAndy Lester <andy@petdance.com>
Tue, 18 Jul 2006 05:50:36 +0000 (05:50 +0000)
lib/Perl/Critic/Policy/Variables/ProhibitConditionalDeclarations.pm

index 5598aaa..d9f3879 100644 (file)
@@ -38,16 +38,17 @@ sub violates {
     return;    #ok!
 }
 
     return;    #ok!
 }
 
+my %conditionals = map {($_,1)} qw(if while foreach for until unless);
+
 sub _is_conditional {
     my (undef, $elem) = @_;
 
 sub _is_conditional {
     my (undef, $elem) = @_;
 
+    return 0 if !$conditionals{$elem};
     return if ! $elem->isa('PPI::Token::Word');
     return if is_hash_key($elem);
     return if is_method_call($elem);
 
     return if ! $elem->isa('PPI::Token::Word');
     return if is_hash_key($elem);
     return if is_method_call($elem);
 
-    # XXX Do this first
-    my @keywords = qw(if while foreach for until unless);
-    return any { $elem eq $_ } @keywords;
+    return 1;
 }
 
 1;
 }
 
 1;