From 66987ffbdda0b96b92821e409bb74166f3a1e026 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 17 Sep 2021 15:14:46 -0700 Subject: [PATCH] add some anonymous sub returns missed by perl critic --- CHANGES.md | 5 +++++ lib/Perl/Tidy.pm | 3 ++- lib/Perl/Tidy/Formatter.pm | 21 +++++++++++++++++---- lib/Perl/Tidy/HtmlWriter.pm | 4 +++- lib/Perl/Tidy/Tokenizer.pm | 1 + lib/Perl/Tidy/VerticalAligner.pm | 14 +++++++++----- 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7c961d06..c33ffbff 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,11 @@ ## 2021 07 17.02 + - Update the man pages to clarify the flags -valign and -novalign + for turning vertical alignment on and off (issue git #72). + Added parameters -vc -vsc -vbc for separately turning off vertical + alignment of code, side comments and block comments. + - Fixed problem where a blank line following a closing code-skipping comment, '#>>V', can be lost. A workaround for the previous version is to include the parameter '-mbl=2'. diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index ffbfc4c4..0866f6a5 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -1,4 +1,3 @@ -#!/usr/bin/perl # ########################################################### # @@ -2219,6 +2218,7 @@ sub generate_options { $expansion{$nshort_name} = [$nolong_name]; } } + return; }; # Install long option names which have a simple abbreviation. @@ -3280,6 +3280,7 @@ sub check_options { $rOpts->{$key} = 100; } } + return; }; # check for reasonable number of blank lines and fix to avoid problems diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 133cc507..2bf07c48 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1382,6 +1382,7 @@ EOM ( $lbs, $rbs ); } } + return; }; my $break_before = sub { @@ -1394,6 +1395,7 @@ EOM ( $lbs, $rbs ); } } + return; }; $break_after->(@all_operators) if ( $rOpts->{'break-after-all-operators'} ); @@ -2312,6 +2314,7 @@ sub set_whitespace_flags { $closing_container_inside_ws{$sequence_number} = $ws_flag; } } + return; }; my ( $ws_1, $ws_2, $ws_3, $ws_4 ); @@ -5855,6 +5858,7 @@ sub respace_tokens { # and finally, add this item to the new array push @{$rLL_new}, $item; + return; }; my $store_token_and_space = sub { @@ -5891,6 +5895,7 @@ sub respace_tokens { # then the token $store_token->($item); + return; }; my $add_phantom_semicolon = sub { @@ -6019,6 +6024,7 @@ sub respace_tokens { $store_token->($rcopy); push @{$rK_phantom_semicolons}, @{$rLL_new} - 1; } + return; }; my $check_Q = sub { @@ -6087,6 +6093,7 @@ sub respace_tokens { "Line $lno: Note: be sure you want '$previous_nonblank_token' instead of '$guess' here\n" ); } + return; }; ############################################ @@ -10428,6 +10435,7 @@ EOM } } } + return; }; my $delete_if_blank = sub { @@ -10456,6 +10464,7 @@ EOM while ( my $ibl = pop(@iblanks) ) { $rhash_of_desires->{$ibl} = 2 } + return; }; my $end_group = sub { @@ -10536,6 +10545,8 @@ EOM @group = (); @subgroup = (); @iblanks = (); + + return; }; my $find_container_end = sub { @@ -20182,10 +20193,10 @@ EOM && $token =~ /$closing_side_comment_prefix_pattern/ ) ); - # - For the particular combination -vc -nvsc, we put all side comments + # - For the specific combination -vc -nvsc, we put all side comments # at fixed locations. Note that we will lose hanging side comment # alignments. Otherwise, hsc's can move to strange locations. - # - For -nvc -nvsc we will make all side comments vertical alignments + # - For -nvc -nvsc we make all side comments vertical alignments # because the vertical aligner will check for -nvsc and be able # to reduce the final padding to the side comments for long lines. # and keep hanging side comments aligned. @@ -21382,12 +21393,12 @@ sub pad_token { sub make_alignment_patterns { # Here we do some important preliminary work for the - # vertical aligner. We create three arrays for one + # vertical aligner. We create four arrays for one # output line. These arrays contain strings that can # be tested by the vertical aligner to see if # consecutive lines can be aligned vertically. # - # The three arrays are indexed on the vertical + # The four arrays are indexed on the vertical # alignment fields and are: # @tokens - a list of any vertical alignment tokens for this line. # These are tokens, such as '=' '&&' '#' etc which @@ -21400,6 +21411,8 @@ sub pad_token { # @patterns - a modified list of token types, one for each alignment # field. These should normally each match before alignment is # allowed, even when the alignment tokens match. + # @field_lengths - the display width of each field + my ( $self, $ibeg, $iend, $ralignment_type_to_go ) = @_; my @tokens = (); my @fields = (); diff --git a/lib/Perl/Tidy/HtmlWriter.pm b/lib/Perl/Tidy/HtmlWriter.pm index 9ff2f57a..d957b154 100644 --- a/lib/Perl/Tidy/HtmlWriter.pm +++ b/lib/Perl/Tidy/HtmlWriter.pm @@ -226,6 +226,7 @@ sub add_toc_item { $html_toc_fh->print("\n\n"); ${$rin_toc_package} = ""; } + return; }; my $start_package_list = sub { @@ -236,6 +237,7 @@ sub add_toc_item {