From f202a80d7702accf2530436ae9ca28c5b0daddda Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 27 Feb 2023 19:34:40 -0800 Subject: [PATCH] remove unused vars --- lib/Perl/Tidy.pm | 1 - lib/Perl/Tidy/Debugger.pm | 1 - lib/Perl/Tidy/FileWriter.pm | 2 +- lib/Perl/Tidy/Formatter.pm | 59 +++++++------------------------- lib/Perl/Tidy/Tokenizer.pm | 6 ++-- lib/Perl/Tidy/VerticalAligner.pm | 15 +++----- 6 files changed, 22 insertions(+), 62 deletions(-) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index f9eb5822..b5f93a13 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -3942,7 +3942,6 @@ sub _process_command_line { } } - my $word; my @raw_options = (); my $config_file = EMPTY_STRING; my $saw_ignore_profile = 0; diff --git a/lib/Perl/Tidy/Debugger.pm b/lib/Perl/Tidy/Debugger.pm index 24896f3c..8ec11f08 100644 --- a/lib/Perl/Tidy/Debugger.pm +++ b/lib/Perl/Tidy/Debugger.pm @@ -45,7 +45,6 @@ sub really_open_debug_file { sub close_debug_file { my $self = shift; - my $fh = $self->{_fh}; if ( $self->{_debug_file_opened} ) { if ( !eval { $self->{_fh}->close(); 1 } ) { diff --git a/lib/Perl/Tidy/FileWriter.pm b/lib/Perl/Tidy/FileWriter.pm index 6db1293b..216ee2c5 100644 --- a/lib/Perl/Tidy/FileWriter.pm +++ b/lib/Perl/Tidy/FileWriter.pm @@ -232,7 +232,7 @@ sub require_blank_code_lines { my $need = $count - $self->[_consecutive_blank_lines_]; my $rOpts = $self->[_rOpts_]; my $forced = $rOpts->{'maximum-consecutive-blank-lines'} > 0; - foreach my $i ( 0 .. $need - 1 ) { + foreach ( 0 .. $need - 1 ) { $self->write_blank_code_line($forced); } return; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index c782d158..94e7bf92 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -6084,7 +6084,6 @@ sub find_level_info { my @stack; my %level_info; - my $err; # TREE_LOOP: foreach my $sseq ( @{$rSS} ) { @@ -6220,7 +6219,6 @@ sub find_loop_label { my $rmccabe_count_sum; my $rLL = $self->[_rLL_]; my $count = 0; - my $Kmax = @{$rLL}; my $Klimit = $self->[_Klimit_]; foreach my $KK ( 0 .. $Klimit ) { $rmccabe_count_sum->{$KK} = $count; @@ -6659,9 +6657,8 @@ sub set_CODE_type { # Examine each line of code and set a flag '$CODE_type' to describe it. # Also return a list of lines with side comments. - my $rLL = $self->[_rLL_]; - my $rlines = $self->[_rlines_]; - my $rblock_type_of_seqno = $self->[_rblock_type_of_seqno_]; + my $rLL = $self->[_rLL_]; + my $rlines = $self->[_rlines_]; my $rOpts_format_skipping_begin = $rOpts->{'format-skipping-begin'}; my $rOpts_format_skipping_end = $rOpts->{'format-skipping-end'}; @@ -6981,8 +6978,7 @@ sub find_non_indenting_braces { DEVEL_MODE && Fault("unexpected line_type=$line_type\n"); next; } - my $CODE_type = $line_of_tokens->{_code_type}; - my $rK_range = $line_of_tokens->{_rK_range}; + my $rK_range = $line_of_tokens->{_rK_range}; my ( $Kfirst, $Klast ) = @{$rK_range}; unless ( defined($Kfirst) && $rLL->[$Klast]->[_TYPE_] eq '#' ) { @@ -7367,7 +7363,6 @@ sub respace_tokens { my $last_line_type = $line_type; $line_type = $line_of_tokens->{_line_type}; next unless ( $line_type eq 'CODE' ); - my $last_CODE_type = $CODE_type; $CODE_type = $line_of_tokens->{_code_type}; if ( $CODE_type eq 'BL' ) { @@ -9700,8 +9695,6 @@ sub keep_old_line_breaks { my $rbreak_before_Kfirst = $self->[_rbreak_before_Kfirst_]; my $rbreak_after_Klast = $self->[_rbreak_after_Klast_]; my $rbreak_container = $self->[_rbreak_container_]; - my $K_opening_container = $self->[_K_opening_container_]; - my $ris_list_by_seqno = $self->[_ris_list_by_seqno_]; #---------------------------------------- # Apply --break-at-old-method-breakpoints @@ -9906,7 +9899,6 @@ sub weld_cuddled_blocks { my $rbreak_container = $self->[_rbreak_container_]; my $ris_broken_container = $self->[_ris_broken_container_]; my $ris_cuddled_closing_brace = $self->[_ris_cuddled_closing_brace_]; - my $K_opening_container = $self->[_K_opening_container_]; my $K_closing_container = $self->[_K_closing_container_]; # A stack to remember open chains at all levels: This is a hash rather than @@ -10599,14 +10591,13 @@ sub weld_nested_containers { # involves setting certain hash values which will be checked # later during formatting. - my $rLL = $self->[_rLL_]; - my $rlines = $self->[_rlines_]; - my $K_opening_container = $self->[_K_opening_container_]; - my $K_closing_container = $self->[_K_closing_container_]; - my $rblock_type_of_seqno = $self->[_rblock_type_of_seqno_]; - my $ris_excluded_lp_container = $self->[_ris_excluded_lp_container_]; - my $ris_asub_block = $self->[_ris_asub_block_]; - my $rmax_vertical_tightness = $self->[_rmax_vertical_tightness_]; + my $rLL = $self->[_rLL_]; + my $rlines = $self->[_rlines_]; + my $K_opening_container = $self->[_K_opening_container_]; + my $K_closing_container = $self->[_K_closing_container_]; + my $rblock_type_of_seqno = $self->[_rblock_type_of_seqno_]; + my $ris_asub_block = $self->[_ris_asub_block_]; + my $rmax_vertical_tightness = $self->[_rmax_vertical_tightness_]; my $rOpts_asbl = $rOpts->{'opening-anonymous-sub-brace-on-new-line'}; @@ -11520,7 +11511,6 @@ sub mark_short_nested_blocks { my $rbreak_container = $self->[_rbreak_container_]; my $ris_broken_container = $self->[_ris_broken_container_]; my $rshort_nested = $self->[_rshort_nested_]; - my $rlines = $self->[_rlines_]; my $rblock_type_of_seqno = $self->[_rblock_type_of_seqno_]; # Variables needed for estimating line lengths @@ -11699,7 +11689,6 @@ sub do_non_indenting_braces { $self->[_rseqno_non_indenting_brace_by_ix_]; return unless ( %{$rseqno_non_indenting_brace_by_ix} ); - my $rLL = $self->[_rLL_]; my $rlines = $self->[_rlines_]; my $K_opening_container = $self->[_K_opening_container_]; my $K_closing_container = $self->[_K_closing_container_]; @@ -11836,7 +11825,6 @@ sub break_before_list_opening_containers { my $ris_broken_container = $self->[_ris_broken_container_]; my $ris_permanently_broken = $self->[_ris_permanently_broken_]; my $rhas_list = $self->[_rhas_list_]; - my $rhas_broken_list = $self->[_rhas_broken_list_]; my $rhas_broken_list_with_lec = $self->[_rhas_broken_list_with_lec_]; my $radjusted_levels = $self->[_radjusted_levels_]; my $rparent_of_seqno = $self->[_rparent_of_seqno_]; @@ -12231,7 +12219,6 @@ sub extended_ci { my $ris_list_by_seqno = $self->[_ris_list_by_seqno_]; my $ris_seqno_controlling_ci = $self->[_ris_seqno_controlling_ci_]; my $rseqno_controlling_my_ci = $self->[_rseqno_controlling_my_ci_]; - my $rlines = $self->[_rlines_]; my $rno_xci_by_seqno = $self->[_rno_xci_by_seqno_]; my $ris_bli_container = $self->[_ris_bli_container_]; my $rblock_type_of_seqno = $self->[_rblock_type_of_seqno_]; @@ -12239,9 +12226,8 @@ sub extended_ci { my %available_space; # Loop over all opening container tokens - my $K_opening_container = $self->[_K_opening_container_]; - my $K_closing_container = $self->[_K_closing_container_]; - my $ris_broken_container = $self->[_ris_broken_container_]; + my $K_opening_container = $self->[_K_opening_container_]; + my $K_closing_container = $self->[_K_closing_container_]; my @seqno_stack; my $seqno_top; my $KLAST; @@ -13001,8 +12987,6 @@ sub is_fragile_block_type { my $line_of_tokens_next = $rlines->[ $iline + 1 ]; my $rtype_count = $rtype_count_by_seqno->{$seqno_end}; - my $comma_count = - defined($rtype_count) ? $rtype_count->{','} : 0; my ( $K_first_next, $K_terminal_next ) = @{ $line_of_tokens_next->{_rK_range} }; @@ -13120,7 +13104,6 @@ sub is_fragile_block_type { my ( $self, $iline, $K_begin_loop, $K_terminal, $K_last ) = @_; my $rLL = $self->[_rLL_]; - my $K_opening_container = $self->[_K_opening_container_]; my $K_closing_container = $self->[_K_closing_container_]; my $rblock_type_of_seqno = $self->[_rblock_type_of_seqno_]; @@ -13534,8 +13517,6 @@ sub process_all_lines { my $self = shift; my $rlines = $self->[_rlines_]; - my $sink_object = $self->[_sink_object_]; - my $fh_tee = $self->[_fh_tee_]; my $rOpts_keep_old_blank_lines = $rOpts->{'keep-old-blank-lines'}; my $file_writer_object = $self->[_file_writer_object_]; my $logger_object = $self->[_logger_object_]; @@ -15579,8 +15560,6 @@ EOM { my $K_closing_container = $self->[_K_closing_container_]; - my $K_opening_container = - $self->[_K_opening_container_]; my $p_seqno = $parent_seqno_to_go[$max_index_to_go]; my $Kc = $K_closing_container->{$p_seqno}; my $is_excluded = @@ -16629,7 +16608,6 @@ EOM else { my $type_sequence = $type_sequence_to_go[$i_break]; if ($type_sequence) { - my $closing_token = $matching_token{ $tokens_to_go[$i_break] }; $postponed_breakpoint{$type_sequence} = 1; } } @@ -19797,7 +19775,6 @@ sub insert_final_ternary_breaks { my $nmax = @{$ri_right} - 1; # scan the left and right end tokens of all lines - my $count = 0; my $i_first_colon = -1; for my $n ( 0 .. $nmax ) { my $il = $ri_left->[$n]; @@ -19981,7 +19958,6 @@ sub correct_lp_indentation { my ( $self, $ri_first, $ri_last ) = @_; # first remove continuation indentation if appropriate - my $rLL = $self->[_rLL_]; my $max_line = @{$ri_first} - 1; #--------------------------------------------------------------------------- @@ -20714,8 +20690,6 @@ sub break_lines_inner_loop { while ( ++$i_test <= $imax ) { my $type = $types_to_go[$i_test]; my $token = $tokens_to_go[$i_test]; - my $next_type = $types_to_go[ $i_test + 1 ]; - my $next_token = $tokens_to_go[ $i_test + 1 ]; my $i_next_nonblank = $inext_to_go[$i_test]; my $next_nonblank_type = $types_to_go[$i_next_nonblank]; my $next_nonblank_token = $tokens_to_go[$i_next_nonblank]; @@ -21622,12 +21596,6 @@ EOM # broken it into pieces and over-commented it. #-------------------------------------------------------------------- - my $rLL = $self->[_rLL_]; - my $ris_list_by_seqno = $self->[_ris_list_by_seqno_]; - my $ris_broken_container = $self->[_ris_broken_container_]; - my $rbreak_before_container_by_seqno = - $self->[_rbreak_before_container_by_seqno_]; - $starting_depth = $nesting_depth_to_go[0]; $block_type = SPACE; @@ -24598,9 +24566,7 @@ sub get_available_spaces_to_go { my %last_lp_equals = (); my $rLL = $self->[_rLL_]; - my $Klimit = $self->[_Klimit_]; my $starting_in_quote = $self->[_this_batch_]->[_starting_in_quote_]; - my $radjusted_levels = $self->[_radjusted_levels_]; my $imin = 0; @@ -26997,7 +26963,6 @@ sub get_seqno { && $self->[_ris_cuddled_closing_brace_]->{$seqno_beg}; if ( $terminal_type eq '{' && !$is_cuddled_closing_brace ) { - my $Kbeg = $K_to_go[$ibeg]; $ci_levels_to_go[$ibeg] = 0; } } diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index a48495f8..fcb59a3d 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -2227,6 +2227,7 @@ EOM /gcx ) { + # For possible future use.. my $subname = $2; my $package = $1 ? $1 : EMPTY_STRING; } @@ -2303,6 +2304,7 @@ EOM /gcx ) { + # For possible future use.. my $subname = $2; my $package = $1 ? $1 : EMPTY_STRING; } @@ -4958,7 +4960,7 @@ EOM $tok = $pre_tok; } - my $prev_tok = $i > 0 ? $rtokens->[ $i - 1 ] : SPACE; +## my $prev_tok = $i > 0 ? $rtokens->[ $i - 1 ] : SPACE; my $prev_type = $i > 0 ? $rtoken_type->[ $i - 1 ] : 'b'; #----------------------------------------------------------- @@ -9496,7 +9498,7 @@ sub do_quote { $i, $in_quote, $quote_character, $quote_pos, $quote_depth, $quoted_string ) - = follow_quoted_string( $i, $in_quote, $rtokens, $quote_character, + = follow_quoted_string( $ibeg, $in_quote, $rtokens, $quote_character, $quote_pos, $quote_depth, $max_token_index ); $quoted_string_2 .= $quoted_string; if ( $in_quote == 1 ) { diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 8fb992a2..11a1acfe 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -1434,7 +1434,6 @@ sub check_fit { my $rfield_lengths = $new_line->{'rfield_lengths'}; my $padding_available = $old_line->get_available_space_on_right(); my $jmax_old = $old_line->{'jmax'}; - my $rtokens_old = $old_line->{'rtokens'}; # Safety check ... only lines with equal array sizes should arrive here # from sub check_match. So if this error occurs, look at recent changes in @@ -1455,10 +1454,7 @@ EOM $alignment->save_column(); } - my $is_hanging_side_comment = $new_line->{'is_hanging_side_comment'}; - # Loop over all alignments ... - my $maximum_field_index = $old_line->{'jmax'}; for my $j ( 0 .. $jmax ) { my $pad = $rfield_lengths->[$j] - $old_line->current_field_width($j); @@ -1561,8 +1557,8 @@ sub _flush_comment_lines { my $group_level = $self->[_group_level_]; my $group_maximum_line_length = $self->[_group_maximum_line_length_]; my $leading_space_count = $self->[_comment_leading_space_count_]; - my $leading_string = - $self->get_leading_string( $leading_space_count, $group_level ); +## my $leading_string = +## $self->get_leading_string( $leading_space_count, $group_level ); # look for excessively long lines my $max_excess = 0; @@ -2280,10 +2276,9 @@ sub sweep_left_to_right { foreach my $ng ( $ngb .. $nge ) { my ( $jbeg, $jend ) = @{ $rgroups->[$ng] }; - my $line = $rlines->[$jbeg]; - my $col = $line->get_column($itok); - my $avail = $line->get_available_space_on_right(); - my $move = $col_want - $col; + my $line = $rlines->[$jbeg]; + my $col = $line->get_column($itok); + my $move = $col_want - $col; if ( $move > 0 ) { # limit padding increase in isolated two lines -- 2.39.5