From: Steve Hancock Date: Tue, 24 Dec 2019 15:18:53 +0000 (-0800) Subject: moved some error-checking code to better location X-Git-Tag: 20200110~13 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9cca124e66aecff031b0baaf7be4f4a75d499e3a;p=perltidy.git moved some error-checking code to better location --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 812ab1bc..682fc62d 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -2997,10 +2997,7 @@ sub respace_tokens { # check a quote for problems elsif ( $type eq 'Q' ) { - - # This is ready to go but is commented out because there is - # still identical logic in sub break_lines. - # $check_Q->($KK, $Kfirst); + $check_Q->( $KK, $Kfirst ); } # handle semicolons @@ -7430,40 +7427,6 @@ EOM $next_nonblank_token_type = $rinput_token_array->[$j_next]->[_TYPE_]; - ###################### - # MAYBE MOVE ELSEWHERE? - ###################### - if ( $type eq 'Q' ) { - note_embedded_tab() if ( $token =~ "\t" ); - - # make note of something like '$var = s/xxx/yyy/;' - # in case it should have been '$var =~ s/xxx/yyy/;' - if ( - $token =~ /^(s|tr|y|m|\/)/ - && $last_nonblank_token =~ /^(=|==|!=)$/ - - # preceded by simple scalar - && $last_last_nonblank_type eq 'i' - && $last_last_nonblank_token =~ /^\$/ - - # followed by some kind of termination - # (but give complaint if we can's see far enough ahead) - && $next_nonblank_token =~ /^[; \)\}]$/ - - # scalar is not declared - && !( - $types_to_go[0] eq 'k' - && $tokens_to_go[0] =~ /^(my|our|local)$/ - ) - ) - { - my $guess = substr( $last_nonblank_token, 0, 1 ) . '~'; - complain( -"Note: be sure you want '$last_nonblank_token' instead of '$guess' here\n" - ); - } - } - # Do not allow breaks which would promote a side comment to a # block comment. In order to allow a break before an opening # or closing BLOCK, followed by a side comment, those sections @@ -11287,11 +11250,10 @@ sub lookup_opening_indentation { # updated per bug report in alex_bug.pl: we must not # mess with the indentation of closing logical braces so # we must treat something like '} else {' as if it were - # an isolated brace my $is_isolated_block_brace = ( - # $iend == $ibeg ) && $block_type_to_go[$ibeg]; + # an isolated brace ############################################################# my $is_isolated_block_brace = $block_type_to_go[$ibeg] - && ( $iend == $ibeg + && ( $i_terminal == $ibeg || $is_if_elsif_else_unless_while_until_for_foreach{ $block_type_to_go[$ibeg] } ); diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 50b3d225..ebd3c073 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -1199,8 +1199,6 @@ sub fix_terminal_else { my $jmax = @{$rfields} - 1; return unless ( $jmax > 0 ); - #my $old_line = $group_lines[-1]; - # check for balanced else block following if/elsif/unless my $rfields_old = $old_line->get_rfields();