add some missing terminal else blocks
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 31 Aug 2023 00:52:31 +0000 (17:52 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 31 Aug 2023 00:52:31 +0000 (17:52 -0700)
Some dangling elsif's still exist in Formatter and Tokenizer

lib/Perl/Tidy.pm
lib/Perl/Tidy/HtmlWriter.pm
lib/Perl/Tidy/VerticalAligner.pm

index 1f3a40dc067bb56ac1fb7cb049555cff49a3a796..51810b4dffd008ab0f41eac51dc9ebbe66d3b709 100644 (file)
@@ -2067,17 +2067,21 @@ EOM
                     $msg .= " (-pbp contains -st; see manual)" if ($saw_pbp);
                     Die("$msg\n");
                 }
-                elsif ($destination_stream) {
+
+                if ($destination_stream) {
                     Die(
 "You may not specify a destination array and -o together\n"
                     );
                 }
-                elsif ( defined( $rOpts->{'output-path'} ) ) {
+
+                if ( defined( $rOpts->{'output-path'} ) ) {
                     Die("You may not specify -o and -opath together\n");
                 }
-                elsif ( defined( $rOpts->{'output-file-extension'} ) ) {
+
+                if ( defined( $rOpts->{'output-file-extension'} ) ) {
                     Die("You may not specify -o and -oext together\n");
                 }
+
                 $output_file = $rOpts->{outfile};
                 $output_name = $output_file;
 
@@ -2610,7 +2614,8 @@ sub process_iteration_layer {
         {
             $max_iterations = 1;
         }
-        elsif ( $max_iterations > 6 ) {
+
+        if ( $max_iterations > 6 ) {
             $max_iterations = 6;
         }
 
@@ -2834,6 +2839,9 @@ EOM
                         print {*STDERR}
 "STRANGE no conv in $display_name: stopping on it=$iter, but not converged in formatter\n";
                     }
+                    else {
+                        ## looks ok
+                    }
                 }
 
                 # we are stopping the iterations early;
@@ -3608,13 +3616,16 @@ sub generate_options {
     foreach my $opt (@option_string) {
         my $long_name = $opt;
         $long_name =~ s/(!|=.*|:.*)$//;
-        unless ( defined( $option_category{$long_name} ) ) {
+        if ( !defined( $option_category{$long_name} ) ) {
             if ( $long_name =~ /^html-linked/ ) {
                 $category = 10;    # HTML options
             }
             elsif ( $long_name =~ /^pod2html/ ) {
                 $category = 11;    # Pod2html
             }
+            else {
+                $category = 12;    # HTML properties
+            }
             $option_category{$long_name} = $category_name[$category];
         }
     }
@@ -4184,6 +4195,9 @@ sub _process_command_line {
             Perl::Tidy::Tokenizer->dump_token_types(*STDOUT);
             Exit(0);
         }
+        else {
+            ## no more special cases
+        }
     }
 
     if ( $saw_dump_profile && $saw_ignore_profile ) {
@@ -5217,6 +5231,9 @@ sub read_config_file {
                 last;
             }
         }
+        else {
+            ## done
+        }
 
         # Now store any parameters
         if ($body) {
@@ -5267,7 +5284,7 @@ sub strip_comment {
     }
 
     # handle case of no quotes
-    elsif ( $instr !~ /['"]/ ) {
+    if ( $instr !~ /['"]/ ) {
 
         # We now require a space before the # of a side comment
         # this allows something like:
index e4e5a507734d9963b316b2d759ce2aa2b5de6187..06cf6676d304dbe66da3906ddd684b60c3a8116c 100644 (file)
@@ -747,6 +747,9 @@ sub pod_to_html {
                 $kwd =~ s/^pod//;
                 push @args, "--no$kwd";
             }
+            else {
+                ## ok - not defined
+            }
         }
 
         # "flush",
@@ -1179,14 +1182,19 @@ PRE_END
     my $css_string;
     my $fh_css = Perl::Tidy::IOScalar->new( \$css_string, 'w' );
 
-    # use css linked to another file
+    # use css linked to another file,
     if ( $rOpts->{'html-linked-style-sheet'} ) {
         $fh_css->print(
             qq(<link rel="stylesheet" href="$css_linkname" type="text/css" />));
     }
 
-    # use css embedded in this file
-    elsif ( !$rOpts->{'nohtml-style-sheets'} ) {
+    # or no css,
+    elsif ( $rOpts->{'nohtml-style-sheets'} ) {
+
+    }
+
+    # or use css embedded in this file
+    else {
         $fh_css->print( <<'ENDCSS');
 <style type="text/css">
 <!--
@@ -1321,6 +1329,9 @@ sub markup_tokens {
                 $self->add_toc_item( $package, 'package' );
             }
         }
+        else {
+            ## level unchanged
+        }
         ${$rlast_level} = $level;
 
         #-------------------------------------------------------
index dc5f4751b3774d4eebbd4b8799eacf799a186d1b..abb730f7ec165fe588ec3be1218dc22000da4370 100644 (file)
@@ -950,6 +950,10 @@ sub valign_input {
         $self->_flush_group_lines(-1);
     }
 
+    else {
+        ##ok: no output needed
+    }
+
     # --------------------------------------------------------------------
     # Some old debugging stuff
     # --------------------------------------------------------------------
@@ -1403,6 +1407,9 @@ sub check_match {
                 $GoToMsg = "Not all tokens match: $imax_align != $jlimit\n";
                 $return_value = NO_MATCH;
             }
+            else {
+                ##ok: continue
+            }
         }
     }
 
@@ -1940,6 +1947,9 @@ EOM
                 my $side_comment = $new_line->{'rfields'}->[-1];
                 end_rgroup(-1) unless ( $side_comment && $prev_comment );
             }
+            else {
+                ##ok: continue
+            }
 
             # See if the new line matches and fits the current group,
             # if it still exists. Flush the current group if not.
@@ -2005,6 +2015,10 @@ EOM
             elsif ( $new_line->{'end_group'} ) {
                 end_rgroup(-1);
             }
+
+            else {
+                ##ok: continue
+            }
         } ## end loop over lines
 
         end_rgroup(-1);
@@ -2311,6 +2325,9 @@ sub sweep_left_to_right {
 
                 # spot to take special action on failure to move
             }
+            else {
+                ##ok: (move==0)
+            }
         }
         return;
     } ## end sub move_to_common_column
@@ -2423,21 +2440,29 @@ sub sweep_left_to_right {
                 }
 
                 # Otherwise allow some minimal padding of good alignments
-                elsif (
+                else {
 
-                    defined( $is_good_alignment_token{$raw_tok} )
+                    if (
 
-                    # We have to be careful if there are just 2 lines.  This
-                    # two-line factor allows large gaps only for 2 lines which
-                    # are simple lists with fewer items on the second line. It
-                    # gives results similar to previous versions of perltidy.
-                    && (   $lines_total > 2
-                        || $group_list_type && $jmax < $jmax_m && $top_level )
-                  )
-                {
-                    $factor += 1;
-                    if ($top_level) {
+                        defined( $is_good_alignment_token{$raw_tok} )
+
+                        # We have to be careful if there are just 2 lines.
+                        # This two-line factor allows large gaps only for 2
+                        # lines which are simple lists with fewer items on the
+                        # second line. It gives results similar to previous
+                        # versions of perltidy.
+                        && (
+                            $lines_total > 2
+                            || (   $group_list_type
+                                && $jmax < $jmax_m
+                                && $top_level )
+                        )
+                      )
+                    {
                         $factor += 1;
+                        if ($top_level) {
+                            $factor += 1;
+                        }
                     }
                 }
 
@@ -3265,6 +3290,7 @@ sub match_line_pairs {
                         if ($match_code) {
                             if    ( $match_code == 1 ) { $i_nomatch = $i }
                             elsif ( $match_code == 2 ) { $i_nomatch = 0 }
+                            else                       { }                  ##ok
                             last;
                         }
                     }
@@ -4242,6 +4268,9 @@ sub Dump_tree_groups {
                 $is_marginal = $pat0 ne $pat1;
             }
         }
+        else {
+            ##ok: (none of the above)
+        }
 
         #-----------------------------------------------------
         # Turn off the marginal flag if we saw an 'if' or 'or'