Login
Ternaries now satisfy RequireCheckingReturnValueOfEval:
authorChris Dolan <chris+github@chrisdolan.net>
Mon, 28 Jul 2008 02:39:04 +0000 (02:39 +0000)
committerChris Dolan <chris+github@chrisdolan.net>
Mon, 28 Jul 2008 02:39:04 +0000 (02:39 +0000)
  eval { require Foo; 1; } ? ok() : nok();

lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm
t/ErrorHandling/RequireCheckingReturnValueOfEval.run

index 908ec89..4562715 100644 (file)
@@ -57,12 +57,9 @@ sub violates {
             $following,
         );
 
-    if (
-            $following
-        and $following->isa('PPI::Token::Operator')
-        and $BOOLEAN_OPERATORS{ $following->content() }
-    ) {
-        return;
+    if ( $following and $following->isa('PPI::Token::Operator') ) {
+        return if $BOOLEAN_OPERATORS{ $following->content() };
+        return if q{?} eq $following->content;
     }
 
     return $self->violation($DESC, $EXPL, $elem);
index 7b71e8e..54062f9 100644 (file)
@@ -239,6 +239,15 @@ bleah if eval 'yadda;' == 5;
 
 #-----------------------------------------------------------------------------
 
+## name Ternary
+## failures 0
+## cut
+
+eval { yadda; } ? 1 : 2;
+eval 'yadda;' ? 1 : 2;
+
+#-----------------------------------------------------------------------------
+
 ## name Postfix foreach
 ## failures 0
 ## cut