From: Steve Hancock Date: Sun, 19 Jun 2022 22:05:24 +0000 (-0700) Subject: add option --delete-repeated-commas X-Git-Tag: 20220613.01~33 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c4a9d9ff8dce8f547e2c0e73b1d6277f88617217;p=perltidy.git add option --delete-repeated-commas --- diff --git a/.perlcriticrc b/.perlcriticrc index a68dc59a..94655f77 100644 --- a/.perlcriticrc +++ b/.perlcriticrc @@ -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 diff --git a/CHANGES.md b/CHANGES.md index 2a8a11ee..c9e9e106 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 3f27bc68..a90d90a6 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -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' ); diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index d70b4ec5..4f110d87 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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;