fix minor issues found with -wv
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 12 Dec 2023 16:20:06 +0000 (08:20 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 12 Dec 2023 16:20:06 +0000 (08:20 -0800)
dev-bin/get_perltidy.pl
dev-bin/perltidy_random_run.pl
dev-bin/perltidy_random_setup.pl
dev-bin/perltidy_tab_test.pl
dev-bin/run_convergence_tests.pl
dev-bin/run_tokenizer_tests.pl
dev-bin/side_comment_test.pl

index 982a5f0019cea50d6adb587f24bf20e8f007708a..857a07f2021325f6049746b01b6f238057388b83 100755 (executable)
@@ -117,7 +117,7 @@ if ($backup_option) {
 }
 
 sub get_latest_perltidy {
-    my ($Dflag) = @_;
+    my ($opt_D) = @_;
     use Cwd qw(getcwd);
     my $starting_dir = getcwd();
     my $dir          = $PERLTIDY_GIT;
@@ -125,7 +125,7 @@ sub get_latest_perltidy {
     my ( $fh_tmp, $tmpfile ) = tempfile();
     chdir $dir;
     my $ofile = $starting_dir . '/perltidy.pl';
-    system "./pm2pl $Dflag -o $ofile >$tmpfile";
+    system "./pm2pl $opt_D -o $ofile >$tmpfile";
     chdir $starting_dir;
     open my $fh, '<', $tmpfile or die "Can't open $tmpfile: $!";
     unlink $tmpfile;
index b97852f3e2d21ab1353c4fdf546b1489ea864342..f6ade465a8a1d2960baada6a04f1001d568b87e9 100755 (executable)
@@ -152,11 +152,11 @@ EOM
 }
 
 # move any GO.sh to a backup to prevent accidentally running multiple copies
-my $runme = "GO.sh";
-if ( -e $runme ) {
-    my $bak = "$runme.bak";
+my $GO_file = "GO.sh";
+if ( -e $GO_file ) {
+    my $bak = "$GO_file.bak";
     if ( -e $bak ) { unlink $bak }
-    system("mv $runme $bak");
+    system("mv $GO_file $bak");
 }
 
 # Outer loop over files
@@ -193,11 +193,11 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) {
     my $ofile_size_min_expected = 0;
 
     my $error_flag    = 0;
-    my $restart_count = 0;
     my $efile_count   = 0;
     my $has_starting_error;
     my $starting_syntax_ok = 1;
     my $tmperr             = "STDERR.txt";
+    my $cmd;
 
     # Inner loop over profiles for a given file
     for ( my $np = $np_beg ; $np <= $np_end ; $np++ ) {
@@ -219,7 +219,7 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) {
         if ( -e $tmperr ) { unlink $tmperr }
 
         #my $cmd = "$binfile <$ifile >$ofile -pro=$profile 2>$tmperr";
-        my $cmd =
+        $cmd =
           "$binfile <$ifile >$ofile -pro=$profile $append_flags 2>$tmperr";
         system_echo( $cmd, $hash );
         my $efile   = "perltidy.ERR";
@@ -329,7 +329,7 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) {
         # Do a syntax check if requested
         if ( $do_syntax_check && $starting_syntax_ok ) {
             my $synfile = "$ofile.syntax";
-            my $cmd     = "perl -c $ofile 2>$synfile";
+            $cmd     = "perl -c $ofile 2>$synfile";
             system_echo( $cmd, $hash );
             my $fh;
             if ( open( $fh, '<', $synfile ) ) {
@@ -358,8 +358,8 @@ for ( my $nf = $nf_beg ; $nf <= $nf_end ; $nf++ ) {
 
         # run perltidy on the output to see if it can be reformatted
         # without errors
-        my $cmd2 = "$binfile <$ofile >$chkfile";
-        system_echo( $cmd2, $hash );
+        $cmd = "$binfile <$ofile >$chkfile";
+        system_echo( $cmd, $hash );
 
         #print STDERR "$cmd2\n";
         my $err;
@@ -608,19 +608,18 @@ EOM
 }
 
 # Write a script to automate search for errors
-write_runme();
+write_runme('RUNME.pl');
 
 # Write a restart file
-my ( $nf, $np );
 if ( $case < $np_end ) {
-    $nf = $file_count;
-    $np = $case + 1;
-    write_GO( $nf, $np );
+    my $nf = $file_count;
+    my $np = $case + 1;
+    write_GO( $GO_file, $nf, $np );
 }
 elsif ( $file_count < $nf_end ) {
-    $nf = $file_count + 1;
-    $np = 1;
-    write_GO( $nf, $np );
+    my $nf = $file_count + 1;
+    my $np = 1;
+    write_GO( $GO_file, $nf, $np );
 }
 
 print STDERR <<EOM;
@@ -713,17 +712,16 @@ EOM
 
 sub write_GO {
 
-    my ( $nf, $np ) = @_;
-    my $runme = "GO.sh";
+    my ( $ofile, $nf, $np ) = @_;
 
-    #unlink $runme if ( -e $runme );
-    if ( -e $runme ) {
-        my $bak = "$runme.bak";
+    #unlink $ofile if ( -e $ofile );
+    if ( -e $ofile ) {
+        my $bak = "$ofile.bak";
         if ( -e $bak ) { unlink $bak }
-        system("mv $runme $bak");
+        system("mv $ofile $bak");
     }
     my $fh;
-    open( $fh, '>', $runme ) || die "cannot open $runme: $!\n";
+    open( $fh, '>', $ofile ) || die "cannot open $ofile: $!\n";
     $fh->print(<<EOM);
 #!/bin/sh
 
@@ -736,15 +734,15 @@ sleep 2
 nohup nice -n19 perltidy_random_run.pl $nf.$np >>nohup.my 2>>nohup.my
 perl RUNME.pl
 EOM
-    system("chmod +x $runme");
-    print STDOUT "To restart, enter ./$runme\n";
+    system("chmod +x $ofile");
+    print STDOUT "To restart, enter ./$ofile\n";
 }
 
 sub write_runme {
 
     # Write a script RUNME.pl which can find problems in nohup.my
-    my $runme = 'RUNME.pl';
-    if ( open( RUN, '>', $runme ) ) {
+    my ($ofile) = @_;
+    if ( open( RUN, '>', $ofile ) ) {
         print RUN <<'EOM';
 #!/usr/bin/perl -w
 my $nohup = "nohup.my";
@@ -825,8 +823,8 @@ system("get_perltidy.pl -b=2");
 print "Enter './GO.sh' to continue\n";
 EOM
         close RUN;
-        system("chmod +x $runme");
-        print "Wrote '$runme'\n";
+        system("chmod +x $ofile");
+        print "Wrote '$ofile'\n";
         return;
     }
 }
index a74f22e28b9700596a585fa6cc335023379f0f10..caed833e7f28c5922dcfb14e49bfe570fccb5f3b 100755 (executable)
@@ -717,312 +717,9 @@ sub get_num {
 
     BEGIN {
 
-        # Here is a static list of all parameters current as of v.20200907
-        # Created with perltidy --dump-long-names
-        # Command line long names (passed to GetOptions)
-        #---------------------------------------------------------------
-        # here is a summary of the Getopt codes:
-        # <none> does not take an argument
-        # =s takes a mandatory string
-        # :s takes an optional string
-        # =i takes a mandatory integer
-        # :i takes an optional integer
-        # ! does not take an argument and may be negated
-        #  i.e., -foo and -nofoo are allowed
-        # a double dash signals the end of the options list
-        #
-        #---------------------------------------------------------------
-        @parameters = qw(
-          DEBUG!
-          add-newlines!
-          add-semicolons!
-          add-whitespace!
-          assert-tidy!
-          assert-untidy!
-          backlink=s
-          backup-and-modify-in-place!
-          backup-file-extension=s
-          blank-lines-after-opening-block-list=s
-          blank-lines-after-opening-block=i
-          blank-lines-before-closing-block-list=s
-          blank-lines-before-closing-block=i
-          blank-lines-before-packages=i
-          blank-lines-before-subs=i
-          blanks-before-blocks!
-          blanks-before-comments!
-          block-brace-tightness=i
-          block-brace-vertical-tightness-list=s
-          block-brace-vertical-tightness=i
-          brace-left-and-indent!
-          brace-left-and-indent-list=s
-          brace-tightness=i
-          brace-vertical-tightness-closing=i
-          brace-vertical-tightness=i
-          break-after-all-operators!
-          break-at-old-attribute-breakpoints!
-          break-at-old-comma-breakpoints!
-          break-at-old-keyword-breakpoints!
-          break-at-old-logical-breakpoints!
-          break-at-old-method-breakpoints!
-          break-at-old-semicolon-breakpoints!
-          break-at-old-ternary-breakpoints!
-          break-before-all-operators!
-          cachedir=s
-          character-encoding=s
-          check-syntax!
-          closing-brace-indentation=i
-          closing-paren-indentation=i
-          closing-side-comment-else-flag=i
-          closing-side-comment-interval=i
-          closing-side-comment-list=s
-          closing-side-comment-maximum-text=i
-          closing-side-comment-prefix=s
-          closing-side-comment-warnings!
-          closing-side-comments!
-          closing-side-comments-balanced!
-          closing-square-bracket-indentation=i
-          closing-token-indentation=i
-          comma-arrow-breakpoints=i
-          continuation-indentation=i
-          cuddled-block-list-exclusive!
-          cuddled-block-list=s
-          cuddled-break-option=i
-          cuddled-else!
-          default-tabsize=i
-          delete-block-comments!
-          delete-closing-side-comments!
-          delete-old-newlines!
-          delete-old-whitespace!
-          delete-pod!
-          delete-semicolons!
-          delete-side-comments!
-          dump-cuddled-block-list!
-          dump-defaults!
-          dump-long-names!
-          dump-options!
-          dump-profile!
-          dump-short-names!
-          dump-token-types!
-          dump-want-left-space!
-          dump-want-right-space!
-          entab-leading-whitespace=i
-          extended-syntax!
-          file-size-order!
-          fixed-position-side-comment=i
-          force-read-binary!
-          format-skipping!
-          format-skipping-begin=s
-          format-skipping-end=s
-          format=s
-          frames!
-          fuzzy-line-length!
-          hanging-side-comments!
-          help
-          html!
-          html-bold-bareword!
-          html-bold-colon!
-          html-bold-comma!
-          html-bold-comment!
-          html-bold-here-doc-target!
-          html-bold-here-doc-text!
-          html-bold-identifier!
-          html-bold-keyword!
-          html-bold-label!
-          html-bold-numeric!
-          html-bold-paren!
-          html-bold-pod-text!
-          html-bold-punctuation!
-          html-bold-quote!
-          html-bold-semicolon!
-          html-bold-structure!
-          html-bold-subroutine!
-          html-bold-v-string!
-          html-color-background=s
-          html-color-bareword=s
-          html-color-colon=s
-          html-color-comma=s
-          html-color-comment=s
-          html-color-here-doc-target=s
-          html-color-here-doc-text=s
-          html-color-identifier=s
-          html-color-keyword=s
-          html-color-label=s
-          html-color-numeric=s
-          html-color-paren=s
-          html-color-pod-text=s
-          html-color-punctuation=s
-          html-color-quote=s
-          html-color-semicolon=s
-          html-color-structure=s
-          html-color-subroutine=s
-          html-color-v-string=s
-          html-entities!
-          html-italic-bareword!
-          html-italic-colon!
-          html-italic-comma!
-          html-italic-comment!
-          html-italic-here-doc-target!
-          html-italic-here-doc-text!
-          html-italic-identifier!
-          html-italic-keyword!
-          html-italic-label!
-          html-italic-numeric!
-          html-italic-paren!
-          html-italic-pod-text!
-          html-italic-punctuation!
-          html-italic-quote!
-          html-italic-semicolon!
-          html-italic-structure!
-          html-italic-subroutine!
-          html-italic-v-string!
-          html-line-numbers
-          html-linked-style-sheet=s
-          html-pre-only
-          html-src-extension=s
-          html-table-of-contents!
-          html-toc-extension=s
-          htmlroot=s
-          ignore-old-breakpoints!
-          ignore-side-comment-lengths!
-          indent-block-comments!
-          indent-closing-brace!
-          indent-columns=i
-          indent-spaced-block-comments!
-          iterations=i
-          keep-interior-semicolons!
-          keep-old-blank-lines=i
-          keyword-group-blanks-after=i
-          keyword-group-blanks-before=i
-          keyword-group-blanks-delete!
-          keyword-group-blanks-inside!
-          keyword-group-blanks-list=s
-          keyword-group-blanks-repeat-count=i
-          keyword-group-blanks-size=s
-          keyword-paren-inner-tightness-list=s
-          keyword-paren-inner-tightness=i
-          libpods=s
-          line-up-parentheses!
-          logfile!
-          logfile-gap:i
-          logical-padding!
-          long-block-line-count=i
-          look-for-autoloader!
-          look-for-hash-bang!
-          look-for-selfloader!
-          maximum-consecutive-blank-lines=i
-          maximum-fields-per-table=i
-          maximum-line-length=i
-          memoize!
-          minimum-space-to-comment=i
-          no-profile
-          nohtml-style-sheets
-          non-indenting-brace-prefix=s
-          non-indenting-braces!
-          noprofile
-          nospace-after-keyword=s
-          notidy
-          nowant-left-space=s
-          nowant-right-space=s
-          npro
-          one-line-block-nesting=i
-          one-line-block-semicolons=i
-          opening-anonymous-sub-brace-on-new-line!
-          opening-brace-always-on-right!
-          opening-brace-on-new-line!
-          opening-hash-brace-right!
-          opening-paren-right!
-          opening-square-bracket-right!
-          opening-sub-brace-on-new-line!
-          outdent-keyword-list=s
-          outdent-keywords!
-          outdent-labels!
-          outdent-long-comments!
-          outdent-long-quotes!
-          outdent-static-block-comments!
-          outfile=s
-          output-file-extension=s
-          output-line-ending=s
-          output-path=s
-          paren-tightness=i
-          paren-vertical-tightness-closing=i
-          paren-vertical-tightness=i
-          pass-version-line!
-          perl-syntax-check-flags=s
-          pod2html!
-          podflush
-          podheader!
-          podindex!
-          podpath=s
-          podquiet!
-          podrecurse!
-          podroot=s
-          podverbose!
-          preserve-line-endings!
-          profile=s
-          quiet!
-          recombine!
-          short-concatenation-item-length=i
-          show-options!
-          space-after-keyword=s
-          space-backslash-quote=i
-          space-for-semicolon!
-          space-function-paren!
-          space-keyword-paren!
-          space-prototype-paren=i
-          space-terminal-semicolon!
-          square-bracket-tightness=i
-          square-bracket-vertical-tightness-closing=i
-          square-bracket-vertical-tightness=i
-          stack-closing-block-brace!
-          stack-closing-hash-brace!
-          stack-closing-paren!
-          stack-closing-square-bracket!
-          stack-opening-block-brace!
-          stack-opening-hash-brace!
-          stack-opening-paren!
-          stack-opening-square-bracket!
-          standard-error-output!
-          standard-output!
-          starting-indentation-level=i
-          static-block-comment-prefix=s
-          static-block-comments!
-          static-side-comment-prefix=s
-          static-side-comments!
-          stylesheet
-          sub-alias-list=s
-          tabs!
-          tee-block-comments!
-          tee-pod!
-          tee-side-comments!
-          tight-secret-operators!
-          timestamp!
-          title=s
-          trim-pod!
-          trim-qw!
-          use-unicode-gcstring!
-          valign!
-          variable-maximum-line-length!
-          version
-          vertical-tightness-closing=i
-          vertical-tightness=i
-          want-break-after=s
-          want-break-before=s
-          want-left-space=s
-          want-right-space=s
-          warning-output!
-          weld-nested-containers!
-          whitespace-cycle=i
-        );
-
-        # We can use the above list, but
-        # normally we want to update to the latest parameters
-        my $UPDATE_PARAMETERS = 1;
-
-        if ($UPDATE_PARAMETERS) {
-            my $rparameters_current = get_parameters();
-            @parameters = @{$rparameters_current};
-            print STDERR "Updating perltidy parameters....\n";
-        }
+        my $rparameters_current = get_parameters();
+        @parameters = @{$rparameters_current};
+        print STDERR "Updating perltidy parameters....\n";
 
         $rinteger_option_range = get_integer_option_range();
 
@@ -1301,18 +998,6 @@ EOM
           backup-file-extension
           backup-method
           character-encoding
-          dump-block-summary
-          dump-block-types
-          dump-block-minimum-lines
-          dump-cuddled-block-list
-          dump-defaults
-          dump-long-names
-          dump-options
-          dump-profile
-          dump-short-names
-          dump-token-types
-          dump-want-left-space
-          dump-want-right-space
           format
           format-skipping-begin
           format-skipping-end
index 6a5f4bc967f1863834cbdf5f44992a54b83bd3a0..876239f4da9cb2c958baf31718df05c67b813bd5 100755 (executable)
@@ -29,7 +29,6 @@ use warnings;
 #   get tabs which will not be removed.  These should be the only results
 #   reported with errors.
 
-my $cmd;
 my @files = @ARGV;
 if ( !@files ) { @files = glob('../*'); }
 my $total_error_count = 0;
index cb675b1566c692e38653f781f96053789d398edb..58c0a9be72e7a006f304f5d87950094dc33a9e71 100755 (executable)
@@ -4,6 +4,12 @@ use warnings;
 use File::Copy;
 use Perl::Tidy;
 
+my $tmp_dir;
+my %Opts;
+
+main();
+
+sub main { #<<<
 my $usage = <<EOM;
 
 This utility runs perltidy on a database of stability test cases. 
@@ -93,7 +99,7 @@ my @option_string = qw(
   u
 );
 
-my %Opts = ();
+%Opts = ();
 if ( !GetOptions( \%Opts, @option_string ) ) {
     die "Programming Bug: error in setting default options";
 }
@@ -110,7 +116,7 @@ my $expect_fname = $0 . ".expect";
 # set tmp dir - you may need to change this depending on setup
 my $git_home = qx[git rev-parse --show-toplevel];
 chomp $git_home;
-my $tmp_dir = $git_home . "/dev-bin/tmp";
+$tmp_dir = $git_home . "/dev-bin/tmp";
 if ( -e $tmp_dir && !-d $tmp_dir ) {
     print STDERR "'$tmp_dir' exists but is not a dir: please fix\n";
     exit 1;
@@ -280,6 +286,7 @@ if ( @{$rexpect_cases_to_update} ) {
 }
 
 exit 1;
+}
 
 sub run_test_cases {
     my ( $rdata_files, $rexpect_files, $rcases ) = @_;
@@ -542,7 +549,6 @@ sub read_data_to_hash {
 
     my $dstring = get_string($db_fname);
     my @lines   = split /^/, $dstring;
-    my $lines   = @lines;
     my $fname   = "";
     my $lno     = 0;
     my $string;
index d74fcca41911ee32794e21d6e5e4e3ae69dfb6bd..ce5dd4e007b7d0c7141e8df91b9db22a8b883907 100755 (executable)
@@ -4,6 +4,10 @@ use warnings;
 use File::Copy;
 use Perl::Tidy;
 
+my $tmp_dir;
+main();
+
+sub main { #<<<
 my $usage = <<EOM;
 
 This utility runs perltidy on a database of tokenizer test cases. 
@@ -105,7 +109,7 @@ my $db_fname = $0 . ".data";
 # set tmp dir - you may need to change this depending on setup
 my $git_home = qx[git rev-parse --show-toplevel];
 chomp $git_home;
-my $tmp_dir = $git_home . "/dev-bin/tmp";
+$tmp_dir = $git_home . "/dev-bin/tmp";
 
 if ( -e $tmp_dir && !-d $tmp_dir ) {
     print STDERR "'$tmp_dir' exists but is not a dir: please fix\n";
@@ -251,6 +255,8 @@ EOM
 run_test_cases( $rdata_files, \@cases );
 exit 1;
 
+}
+
 sub run_test_cases {
     my ( $rdata_files, $rcases ) = @_;
 
@@ -297,7 +303,6 @@ sub run_test_cases {
         }
         my $stderr_string;
         my $errorfile_string;
-        my @output_history;
         my $params = "";
         my $err    = Perl::Tidy::perltidy(
             source      => \$source,
@@ -371,7 +376,6 @@ sub read_data_to_hash {
 
     my $dstring = get_string($db_fname);
     my @lines   = split /\n/, $dstring;
-    my $lines   = @lines;
     my $fname   = "";
     my $lno     = 0;
     my $string;
index 13e22763d991f974499657d99f928b828a12748e..6a1b1cddc77d0403bba9e5b407b2444cd5ebd341 100755 (executable)
@@ -24,6 +24,9 @@ use warnings;
 
 # 4. When done, remove the temporary directory
 
+main();
+
+sub main { #<<<
 my $cmd;
 my @files = @ARGV;
 if ( !@files ) { @files = glob('../*'); }
@@ -70,6 +73,7 @@ foreach my $file (@files) {
 
     # Otherwise, leave the files for analysis
 }
+}
 
 sub add_side_comments {
     my ( $ifile, $ofile ) = @_;