]> git.donarmstrong.com Git - perltidy.git/commitdiff
code cleanups; remove unused subs
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 9 Jan 2021 14:59:53 +0000 (06:59 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 9 Jan 2021 14:59:53 +0000 (06:59 -0800)
bin/perltidy
dev-bin/RandomTesting.md
lib/Perl/Tidy.pm
lib/Perl/Tidy/Formatter.pm

index f4c2c8331a5cec20e1ad6395d7c0de3baa53ba0a..ed90fa183a2ede8f8eee6f82dfa4e0a648c2e31d 100755 (executable)
@@ -416,7 +416,13 @@ Use n columns per indentation level (default n=4).
 The default maximum line length is n=80 characters.  Perltidy will try
 to find line break points to keep lines below this length. However, long
 quotes and side comments may cause lines to exceed this length. 
-Setting B<-l=0> is equivalent to setting B<-l=(a large number)>. 
+
+The default length of 80 comes from the past when this was the standard CRT
+screen width.  Many programmers prefer to increase this to something like 120.
+
+Setting B<-l=0> is equivalent to setting B<-l=(a very large number)>.  But this is
+not recommended because, for example, a very long list will be formatted in a
+single long line.
 
 =item B<-vmll>, B<--variable-maximum-line-length>
 
index c2b221be94a229330c9c3a2f353768fa9d53debf..77e095974836eb31b505575c043c9ec24fd5132f 100644 (file)
@@ -11,7 +11,7 @@ through the results.
 When this type of testing was begun, several dozen problems were quickly
 identified and fixed.  The most common problem was that an uninitialized
 variable was referenced in some way.  It has been some time since a new problem
-was detected with these scripts, but it is important to periodically run these
+was detected with these scripts, but it is important to run these
 tests periodically, and always before a release, because new coding and new
 parameters may introduce bugs.
 
@@ -28,7 +28,7 @@ personal bin directory.
 ## Prepare a temporary directory
 
 First collect a large number (say 50 or more) of arbitrary perl scripts in a
-single directory.  These files can also contain arbitrary other files, such as
+single directory.  You may also include other arbitrary files, such as
 text or html files.
 
 Then create a temporary sub directory and enter it, say
@@ -86,7 +86,7 @@ menu.  You will be generating profiles here (a profile being a file with a
 random set of perltidy parameters). The number of random profiles is set to 50
 but I sometimes increase it to 100 or 200.  Every input file will be run
 against every random profile, so this can significantly increase the total run
-time. The main menu looks like this (I am not sure if this will format correctly):
+time. The main menu looks like this
 
 ```
 R   - Read a config file
index 0ef550910a5d7a5493534d8c7549d8c808d9fdf9..d2184f17834324523544de32421293380a257304 100644 (file)
@@ -2427,19 +2427,19 @@ sub generate_options {
     ########################################
     $category = 13;    # Debugging
     ########################################
-##  $add_option->( 'DIAGNOSTICS',                     'I',    '!' );
-    $add_option->( 'DEBUG',                           'D',     '!' );
-    $add_option->( 'dump-cuddled-block-list',         'dcbl',  '!' );
-    $add_option->( 'dump-defaults',                   'ddf',   '!' );
-    $add_option->( 'dump-long-names',                 'dln',   '!' );
-    $add_option->( 'dump-options',                    'dop',   '!' );
-    $add_option->( 'dump-profile',                    'dpro',  '!' );
-    $add_option->( 'dump-short-names',                'dsn',   '!' );
-    $add_option->( 'dump-token-types',                'dtt',   '!' );
-    $add_option->( 'dump-want-left-space',            'dwls',  '!' );
-    $add_option->( 'dump-want-right-space',           'dwrs',  '!' );
-    $add_option->( 'fuzzy-line-length',               'fll',   '!' );
-    $add_option->( 'help',                            'h',     '' );
+    $add_option->( 'DIAGNOSTICS',             'I',    '!' ) if (DEVEL_MODE);
+    $add_option->( 'DEBUG',                   'D',    '!' );
+    $add_option->( 'dump-cuddled-block-list', 'dcbl', '!' );
+    $add_option->( 'dump-defaults',           'ddf',  '!' );
+    $add_option->( 'dump-long-names',         'dln',  '!' );
+    $add_option->( 'dump-options',            'dop',  '!' );
+    $add_option->( 'dump-profile',            'dpro', '!' );
+    $add_option->( 'dump-short-names',        'dsn',  '!' );
+    $add_option->( 'dump-token-types',        'dtt',  '!' );
+    $add_option->( 'dump-want-left-space',    'dwls', '!' );
+    $add_option->( 'dump-want-right-space',   'dwrs', '!' );
+    $add_option->( 'fuzzy-line-length',       'fll',  '!' );
+    $add_option->( 'help',                    'h',    '' );
     $add_option->( 'short-concatenation-item-length', 'scl',   '=i' );
     $add_option->( 'show-options',                    'opt',   '!' );
     $add_option->( 'timestamp',                       'ts',    '!' );
index 9016df9e1ddde11b325b242e65e74f37a90de9e3..2e9bf525aa409d3e256d25ff9b008406dea5832c 100644 (file)
@@ -769,40 +769,6 @@ sub new {
 # CODE SECTION 2: Some Basic Utilities
 ######################################
 
-sub check_keys {
-    my ( $rtest, $rvalid, $msg, $exact_match ) = @_;
-
-    # Check the keys of a hash:
-    # $rtest   = ref to hash to test
-    # $rvalid  = ref to hash with valid keys
-
-    # $msg = a message to write in case of error
-    # $exact_match defines the type of check:
-    #     = false: test hash must not have unknown key
-    #     = true:  test hash must have exactly same keys as known hash
-    my @unknown_keys =
-      grep { !exists $rvalid->{$_} } keys %{$rtest};
-    my @missing_keys =
-      grep { !exists $rtest->{$_} } keys %{$rvalid};
-    my $error = @unknown_keys;
-    if ($exact_match) { $error ||= @missing_keys }
-    if ($error) {
-        local $" = ')(';
-        my @expected_keys = sort keys %{$rvalid};
-        @unknown_keys = sort @unknown_keys;
-        Die(<<EOM);
-------------------------------------------------------------------------
-Program error detected checking hash keys
-Message is: '$msg'
-Expected keys: (@expected_keys)
-Unknown key(s): (@unknown_keys)
-Missing key(s): (@missing_keys)
-------------------------------------------------------------------------
-EOM
-    }
-    return;
-}
-
 {    ## begin closure for logger routines
     my $logger_object;
 
@@ -6125,13 +6091,13 @@ sub keep_old_line_breaks {
     foreach my $item ( @{$rKrange_code_without_comments} ) {
         my ( $Kfirst, $Klast ) = @{$item};
 
-        my $typeb = $rLL->[$Kfirst]->[_TYPE_];
-        if ( $keep_break_before_type{$typeb} ) {
+        my $type_first = $rLL->[$Kfirst]->[_TYPE_];
+        if ( $keep_break_before_type{$type_first} ) {
             $rbreak_before_Kfirst->{$Kfirst} = 1;
         }
 
-        my $typee = $rLL->[$Klast]->[_TYPE_];
-        if ( $keep_break_after_type{$typee} ) {
+        my $type_last = $rLL->[$Klast]->[_TYPE_];
+        if ( $keep_break_after_type{$type_last} ) {
             $rbreak_after_Klast->{$Klast} = 1;
         }
     }
@@ -6160,7 +6126,7 @@ sub weld_containers {
     # Note that weld_nested_containers() changes the _LEVEL_ values, so
     # weld_cuddled_blocks must use the _TRUE_LEVEL_ values instead.
 
-    # Here is a good test case to  Be sure that both cuddling and welding
+    # Here is a good test case to be sure that both cuddling and welding
     # are working and not interfering with each other: <<snippets/ce_wn1.in>>
 
     #   perltidy -wn -ce
@@ -6202,6 +6168,8 @@ sub cumulative_length_before_K {
 }
 
 sub cumulative_length_after_K {
+
+    # NOTE: This routine not currently called; could be deleted
     my ( $self, $KK ) = @_;
     my $rLL = $self->[_rLL_];
     return $rLL->[$KK]->[_CUMULATIVE_LENGTH_];
@@ -10897,11 +10865,6 @@ EOM
           @unmatched_closing_indexes_in_this_batch;
     }
 
-    sub comma_arrow_count {
-        my $seqno = shift;
-        return $comma_arrow_count{$seqno};
-    }
-
     sub match_opening_and_closing_tokens {
 
         # Match up indexes of opening and closing braces, etc, in this batch.
@@ -18354,68 +18317,6 @@ sub pad_token {
     return;
 }
 
-sub mate_index_to_go {
-    my ( $self, $i ) = @_;
-
-    # NOTE: This works but is too inefficient, but is retained for info.
-
-    # Return the matching index of a container or ternary pair
-    # This is equivalent to the array @mate_index_to_go
-    my $K      = $K_to_go[$i];
-    my $K_mate = $self->K_mate_index($K);
-    my $i_mate = -1;
-    if ( defined($K_mate) ) {
-        $i_mate = $i + ( $K_mate - $K );
-        if ( $i_mate < 0 || $i_mate > $max_index_to_go ) {
-            $i_mate = -1;
-        }
-    }
-    my $i_mate_alt = $mate_index_to_go[$i];
-
-    # FIXME: Old Debug code which can be removed eventually
-    if ( 0 && $i_mate_alt != $i_mate ) {
-        my $tok       = $tokens_to_go[$i];
-        my $type      = $types_to_go[$i];
-        my $tok_mate  = '*';
-        my $type_mate = '*';
-        if ( $i_mate >= 0 && $i_mate <= $max_index_to_go ) {
-            $tok_mate  = $tokens_to_go[$i_mate];
-            $type_mate = $types_to_go[$i_mate];
-        }
-        my $seq  = $type_sequence_to_go[$i];
-        my $file = get_input_stream_name();
-
-        Warn(
-"mate_index: file '$file': i=$i, imate=$i_mate, should be $i_mate_alt, K=$K, K_mate=$K_mate\ntype=$type, tok=$tok, seq=$seq, max=$max_index_to_go, tok_mate=$tok_mate, type_mate=$type_mate"
-        );
-    }
-    return $i_mate;
-}
-
-sub K_mate_index {
-
-   # Given the index K of an opening or closing container,  or ?/: ternary pair,
-   # return the index K of the other member of the pair.
-    my ( $self, $K ) = @_;
-    return unless defined($K);
-    my $rLL   = $self->[_rLL_];
-    my $seqno = $rLL->[$K]->[_TYPE_SEQUENCE_];
-    return unless ($seqno);
-
-    my $K_opening = $self->[_K_opening_container_]->{$seqno};
-    if ( defined($K_opening) ) {
-        if ( $K != $K_opening ) { return $K_opening }
-        return $self->[_K_closing_container_]->{$seqno};
-    }
-
-    $K_opening = $self->[_K_opening_ternary_]->{$seqno};
-    if ( defined($K_opening) ) {
-        if ( $K != $K_opening ) { return $K_opening }
-        return $self->[_K_closing_ternary_]->{$seqno};
-    }
-    return;
-}
-
 {    ## begin closure make_alignment_patterns
 
     my %block_type_map;