From 1f342692bd2ac7e834f064710b9759230d240d14 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 12 Dec 2023 08:20:06 -0800 Subject: [PATCH] fix minor issues found with -wv --- dev-bin/get_perltidy.pl | 4 +- dev-bin/perltidy_random_run.pl | 58 +++--- dev-bin/perltidy_random_setup.pl | 321 +------------------------------ dev-bin/perltidy_tab_test.pl | 1 - dev-bin/run_convergence_tests.pl | 12 +- dev-bin/run_tokenizer_tests.pl | 10 +- dev-bin/side_comment_test.pl | 4 + 7 files changed, 53 insertions(+), 357 deletions(-) diff --git a/dev-bin/get_perltidy.pl b/dev-bin/get_perltidy.pl index 982a5f00..857a07f2 100755 --- a/dev-bin/get_perltidy.pl +++ b/dev-bin/get_perltidy.pl @@ -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; diff --git a/dev-bin/perltidy_random_run.pl b/dev-bin/perltidy_random_run.pl index b97852f3..f6ade465 100755 --- a/dev-bin/perltidy_random_run.pl +++ b/dev-bin/perltidy_random_run.pl @@ -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 <', $runme ) || die "cannot open $runme: $!\n"; + open( $fh, '>', $ofile ) || die "cannot open $ofile: $!\n"; $fh->print(<>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; } } diff --git a/dev-bin/perltidy_random_setup.pl b/dev-bin/perltidy_random_setup.pl index a74f22e2..caed833e 100755 --- a/dev-bin/perltidy_random_setup.pl +++ b/dev-bin/perltidy_random_setup.pl @@ -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: - # 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 diff --git a/dev-bin/perltidy_tab_test.pl b/dev-bin/perltidy_tab_test.pl index 6a5f4bc9..876239f4 100755 --- a/dev-bin/perltidy_tab_test.pl +++ b/dev-bin/perltidy_tab_test.pl @@ -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; diff --git a/dev-bin/run_convergence_tests.pl b/dev-bin/run_convergence_tests.pl index cb675b15..58c0a9be 100755 --- a/dev-bin/run_convergence_tests.pl +++ b/dev-bin/run_convergence_tests.pl @@ -4,6 +4,12 @@ use warnings; use File::Copy; use Perl::Tidy; +my $tmp_dir; +my %Opts; + +main(); + +sub main { #<<< my $usage = < \$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; diff --git a/dev-bin/side_comment_test.pl b/dev-bin/side_comment_test.pl index 13e22763..6a1b1cdd 100755 --- a/dev-bin/side_comment_test.pl +++ b/dev-bin/side_comment_test.pl @@ -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 ) = @_; -- 2.39.5