]> git.donarmstrong.com Git - perltidy.git/commitdiff
add option --delete-repeated-commas
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 19 Jun 2022 22:05:24 +0000 (15:05 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 19 Jun 2022 22:05:24 +0000 (15:05 -0700)
.perlcriticrc
CHANGES.md
lib/Perl/Tidy.pm
lib/Perl/Tidy/Formatter.pm

index a68dc59a563c343ca051e1fe5156b018fdcc99a5..94655f772276853552027827b09f65b143b6f658 100644 (file)
@@ -1,4 +1,4 @@
-# perlcritic is a great tool for locating potentially 'dodgy' coding.
+# perlcritic is a good tool for locating potentially 'dodgy' coding.
 
 # Some useful links:
 # https://manpages.ubuntu.com/manpages/xenial/man1/perlcritic.1p.html
@@ -12,9 +12,11 @@ verbose = %f: [%p] %m at line %l, column %c.\n
 # perlcritic --single-policy Subroutines::ProhibitSubroutinePrototypes Module.pm
 
 # Below is a list of policies that are skipped or customized to the needs of
-# Perl::Tidy.  After experimenting with ## no critic comments, I decided that
-# they cause more trouble than the value they provide, so policies are either
-# 'on' or 'off'.
+# Perl::Tidy.  I have found that using 'no critic' comments is very
+# troublesome*, so policies are either 'on' or 'off' for all modules.
+# ( *For example, why is it necessary to specify a policy in a side comment?
+# The very long policy names are ugly and typically make the side comment
+# exceed the desired line length. )
 
 #--------------------------------------------------------------
 # Following is a list of policies to be skipped for severity=4:
@@ -81,7 +83,8 @@ max_nests=11
 # any benefit in reduced run time or clarity.
 [-ControlStructures::ProhibitCascadingIfElse]
 
-# Agree - these are in process of being converted to if's
+# This is a reasonable policy for new code but it is not worth changing
+# debugged code for it.
 [-ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions]
 
 # This is a good general policy but not always the best for efficiency
index 2a8a11ee06d6ade482b9b915f636e5a9a3a671b5..c9e9e106e3b772b4e1a530280bc3f8b222f35ece 100644 (file)
@@ -1,5 +1,15 @@
 # Perltidy Change Log
 
+## 2022 xx xx
+
+    - Added parameter --delete-repeated-commas (-drc) to delete repeated
+      commas. This is off by default. For example, given this line:
+
+            ignoreSpec( $file, "file",, \%spec, \%Rspec );
+
+      # perltidy -drc:
+            ignoreSpec( $file, "file", \%spec, \%Rspec );
+
 ## 2022 06 13
 
     - No significant bugs have been found since the last release but users
index 3f27bc682422d168cb28d9a7724c12e4576bd8eb..a90d90a6ea0948b5e0b16b3a3b06091284a8c6da 100644 (file)
@@ -2872,6 +2872,7 @@ sub generate_options {
     $add_option->( 'block-brace-tightness',                     'bbt',   '=i' );
     $add_option->( 'brace-tightness',                           'bt',    '=i' );
     $add_option->( 'delete-old-whitespace',                     'dws',   '!' );
+    $add_option->( 'delete-repeated-commas',                    'drc',   '!' );
     $add_option->( 'delete-semicolons',                         'dsm',   '!' );
     $add_option->( 'function-paren-vertical-alignment',         'fpva',  '!' );
     $add_option->( 'keyword-paren-inner-tightness',             'kpit',  '=i' );
index d70b4ec559aef004f558114f211dddc6477fee9b..4f110d8771245ce34c5a17dfa9958e6cca7f8d6c 100644 (file)
@@ -7140,6 +7140,17 @@ EOM
                 next;
             } ## end if ( $type eq 'q' )
 
+            # delete repeated commas if requested
+            elsif ( $type eq ',' ) {
+                if (   $last_nonblank_code_type eq ','
+                    && $rOpts->{'delete-repeated-commas'} )
+                {
+                    # Could note this deletion as a possible future update:
+                    ## $self->note_deleted_comma($input_line_number);
+                    next;
+                }
+            }
+
             # change 'LABEL   :'   to 'LABEL:'
             elsif ( $type eq 'J' ) {
                 $token =~ s/\s+//g;