]> git.donarmstrong.com Git - perltidy.git/commitdiff
some -wmr code cleanups
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 5 Jul 2024 23:29:25 +0000 (16:29 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 5 Jul 2024 23:29:25 +0000 (16:29 -0700)
lib/Perl/Tidy/Formatter.pm

index ad42fc19e896501b75c4887bce9cb82d73665f91..ab6fbb76b3267990aa6fd94e177355b0e8ea51cc 100644 (file)
@@ -14879,14 +14879,23 @@ sub count_return_values_wanted {
     my $seqno_list = $item->{seqno_list};
     return unless ($seqno_list);
 
-    # Give up at a call chain like:
+    # Give up if call is followed by a bound operator, for example
     #     my ( $fh, $tmpfile ) = $self->io()->tempfile( DIR => $dir );
     #                                      |
     #                                      ^--$Kc
     my $rLL  = $self->[_rLL_];
     my $Kc   = $self->[_K_closing_container_]->{$seqno_list};
     my $Kc_n = $self->K_next_code($Kc);
-    if ( $Kc_n && $rLL->[$Kc_n]->[_TYPE_] eq '->' ) { return }
+    if ($Kc_n) {
+        my $type_n = $rLL->[$Kc_n]->[_TYPE_];
+        my $ok     = $type_n eq ';' || $is_closing_type{$type_n};
+        if ( !$ok && $type_n eq 'k' ) {
+            my $token_n = $rLL->[$Kc_n]->[_TOKEN_];
+            $ok ||= $is_if_unless{$token_n};
+            $ok ||= $is_and_or{$token_n};
+        }
+        return unless $ok;
+    }
 
     my $Ko   = $self->[_K_opening_container_]->{$seqno_list};
     my $K_m  = $self->K_previous_code($Ko);
@@ -15348,10 +15357,6 @@ sub update_sub_call_paren_info {
 
 use constant DEBUG_SELF => 0;
 
-# FIXME: this should be 1 for testing, 2 for normal work
-use constant RETURN_COUNT_LOWER_BOUND => 1;
-##use constant RETURN_COUNT_LOWER_BOUND => 2;
-
 sub cross_check_call_args {
 
     my ($self) = @_;
@@ -15804,10 +15809,10 @@ sub cross_check_call_args {
           :                            1;
 
         my $rhs_ok =
-            !defined($rK_return_list)                    ? 0
-          : !defined($return_count_max)                  ? -1
-          : $return_count_max < RETURN_COUNT_LOWER_BOUND ? 0
-          :                                                1;
+            !defined($rK_return_list)   ? 0
+          : !defined($return_count_max) ? -1
+          : $return_count_max < 1       ? 0
+          :                               1;
 
         next if ( $lhs_ok + $rhs_ok <= 0 );