From 5be96b2086076f43abfe2549b839c124ea94e00a Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 26 Jun 2023 09:42:40 -0700 Subject: [PATCH] change param name -ipcsl to -ipc This simplifies documentation --- CHANGES.md | 12 ++++---- bin/perltidy | 31 ++++++++++---------- lib/Perl/Tidy.pm | 59 +++++++++++++++++++------------------- lib/Perl/Tidy/Formatter.pm | 22 +++++++------- t/snippets/comments3.par | 2 +- t/snippets17.t | 2 +- 6 files changed, 64 insertions(+), 64 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 57f33edf..647b9d12 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,12 +2,12 @@ ## 2023 03 09.03 - - Add parameter -ipscl, or --ignore-perlcritic-side-comment-lengths. This - is on by default to help avoid problems due to unwanted line breaks - caused by long side comments beginning with '## no critic'. Perlcritic - users can also use the more general parameter B<-iscl> for this purpose, - but that parameter is off by default. This new parameter is on by - default and serves as a backup in case B<-iscl> has not been set. + - Add parameter -ipc, or --ignore-perlcritic-comments. Perltidy, by + default, will look for side comments beginning with B<## no critic> and + ignore their lengths when making line break decisions, even if the user + has not set B<-iscl>. The reason is that an unwanted line break can + make these special comments ineffective in controlling B. + The parameter -ipc can be set if, for some reason, this is not wanted. - Issue git #121. Added parameters -xbt, or --extended-block-tightness, and -xbtl=s, or --extended-block-tightness-list=s, to allow diff --git a/bin/perltidy b/bin/perltidy index 228d13db..c4b2389b 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -1793,14 +1793,15 @@ whereas without the -iscl flag the line will be broken: $vmsfile =~ s/;[\d\-]*$// ; # Clip off version number; we can use a newer version as well -=item B<-ipscl>, B<--ignore-perlcritic-side-comment-lengths> +=item B<-ipc>, B<--ignore-perlcritic-comments> -The parameter B<-ipscl> tells perltidy to ignore the length of side comments -beginning with B<## no critic> when making line breaks, even if the previous -parameter B<-iscl> has not been set. This parameter is on by default to avoid -allowing these special B comments, which are often quite long, to -cause an unwanted line break, and thereby making the side comment ineffective -in controlling B. +Perltidy, by default, will look for side comments beginning with +B<## no critic> and ignore their lengths when making line break decisions, +even if the user has not set B<-iscl>. The reason is that an unwanted line +break can make these special comments ineffective in controlling B. + +Setting B<--ignore-perlcritic-comments> tells perltidy not to look for these +B<## no critic> comments. =item B<-hsc>, B<--hanging-side-comments> @@ -5645,14 +5646,14 @@ The following list shows all short parameter names which allow a prefix hbm hbn hbp hbpd hbpu hbq hbs hbsc hbv hbw hent hic hicm hico hih hihh hii hij hik him hin hip hipd hipu hiq his hisc hiv hiw hsc - html ibc icb icp iob isbc iscl kgb kgbd kgbi - kis lal log lop lp lsl mem nib ohbr okw - ola olc oll olq opr opt osbc osbr otr ple - pod pvl q sac sbc sbl scbb schb scp scsb - sct se sfp sfs skp sob sobb sohb sop sosb - sot ssc st sts t tac tbc toc tp tqw - trp ts tsc tso vbc vc viu vmll vsc w - wfc wn x xbt xci xlp xs + html ibc icb icp iob ipc isbc iscl kgb kgbd + kgbi kis lal log lop lp lsl mem nib ohbr + okw ola olc oll olq opr opt osbc osbr otr + ple pod pvl q sac sbc sbl scbb schb scp + scsb sct se sfp sfs skp sob sobb sohb sop + sosb sot ssc st sts t tac tbc toc tp + tqw trp ts tsc tso vbc vc viu vmll vsc + w wfc wn x xbt xci xlp xs Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be used. diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 35436e7c..616fbe69 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -3243,35 +3243,35 @@ sub generate_options { ######################################## $category = 4; # Comment controls ######################################## - $add_option->( 'closing-side-comment-else-flag', 'csce', '=i' ); - $add_option->( 'closing-side-comment-interval', 'csci', '=i' ); - $add_option->( 'closing-side-comment-list', 'cscl', '=s' ); - $add_option->( 'closing-side-comment-maximum-text', 'csct', '=i' ); - $add_option->( 'closing-side-comment-prefix', 'cscp', '=s' ); - $add_option->( 'closing-side-comment-warnings', 'cscw', '!' ); - $add_option->( 'closing-side-comments', 'csc', '!' ); - $add_option->( 'closing-side-comments-balanced', 'cscb', '!' ); - $add_option->( 'code-skipping', 'cs', '!' ); - $add_option->( 'code-skipping-begin', 'csb', '=s' ); - $add_option->( 'code-skipping-end', 'cse', '=s' ); - $add_option->( 'format-skipping', 'fs', '!' ); - $add_option->( 'format-skipping-begin', 'fsb', '=s' ); - $add_option->( 'format-skipping-end', 'fse', '=s' ); - $add_option->( 'hanging-side-comments', 'hsc', '!' ); - $add_option->( 'indent-block-comments', 'ibc', '!' ); - $add_option->( 'indent-spaced-block-comments', 'isbc', '!' ); - $add_option->( 'fixed-position-side-comment', 'fpsc', '=i' ); - $add_option->( 'minimum-space-to-comment', 'msc', '=i' ); - $add_option->( 'non-indenting-braces', 'nib', '!' ); - $add_option->( 'non-indenting-brace-prefix', 'nibp', '=s' ); - $add_option->( 'outdent-long-comments', 'olc', '!' ); - $add_option->( 'outdent-static-block-comments', 'osbc', '!' ); - $add_option->( 'static-block-comment-prefix', 'sbcp', '=s' ); - $add_option->( 'static-block-comments', 'sbc', '!' ); - $add_option->( 'static-side-comment-prefix', 'sscp', '=s' ); - $add_option->( 'static-side-comments', 'ssc', '!' ); - $add_option->( 'ignore-side-comment-lengths', 'iscl', '!' ); - $add_option->( 'ignore-perlcritic-side-comment-lengths', 'ipcl', '!' ); + $add_option->( 'closing-side-comment-else-flag', 'csce', '=i' ); + $add_option->( 'closing-side-comment-interval', 'csci', '=i' ); + $add_option->( 'closing-side-comment-list', 'cscl', '=s' ); + $add_option->( 'closing-side-comment-maximum-text', 'csct', '=i' ); + $add_option->( 'closing-side-comment-prefix', 'cscp', '=s' ); + $add_option->( 'closing-side-comment-warnings', 'cscw', '!' ); + $add_option->( 'closing-side-comments', 'csc', '!' ); + $add_option->( 'closing-side-comments-balanced', 'cscb', '!' ); + $add_option->( 'code-skipping', 'cs', '!' ); + $add_option->( 'code-skipping-begin', 'csb', '=s' ); + $add_option->( 'code-skipping-end', 'cse', '=s' ); + $add_option->( 'format-skipping', 'fs', '!' ); + $add_option->( 'format-skipping-begin', 'fsb', '=s' ); + $add_option->( 'format-skipping-end', 'fse', '=s' ); + $add_option->( 'hanging-side-comments', 'hsc', '!' ); + $add_option->( 'indent-block-comments', 'ibc', '!' ); + $add_option->( 'indent-spaced-block-comments', 'isbc', '!' ); + $add_option->( 'fixed-position-side-comment', 'fpsc', '=i' ); + $add_option->( 'minimum-space-to-comment', 'msc', '=i' ); + $add_option->( 'non-indenting-braces', 'nib', '!' ); + $add_option->( 'non-indenting-brace-prefix', 'nibp', '=s' ); + $add_option->( 'outdent-long-comments', 'olc', '!' ); + $add_option->( 'outdent-static-block-comments', 'osbc', '!' ); + $add_option->( 'static-block-comment-prefix', 'sbcp', '=s' ); + $add_option->( 'static-block-comments', 'sbc', '!' ); + $add_option->( 'static-side-comment-prefix', 'sscp', '=s' ); + $add_option->( 'static-side-comments', 'ssc', '!' ); + $add_option->( 'ignore-side-comment-lengths', 'iscl', '!' ); + $add_option->( 'ignore-perlcritic-comments', 'ipc', '!' ); ######################################## $category = 5; # Linebreak controls @@ -3560,7 +3560,6 @@ sub generate_options { function-paren-vertical-alignment fuzzy-line-length hanging-side-comments - ignore-perlcritic-side-comment-lengths indent-block-comments indent-columns=4 iterations=1 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 6b5a6922..330cde9c 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -209,7 +209,7 @@ my ( $rOpts_fuzzy_line_length, $rOpts_ignore_old_breakpoints, $rOpts_ignore_side_comment_lengths, - $rOpts_ignore_perlcritic_side_comment_lengths, + $rOpts_ignore_perlcritic_comments, $rOpts_indent_closing_brace, $rOpts_indent_columns, $rOpts_indent_only, @@ -2445,14 +2445,13 @@ sub initialize_global_option_vars { $rOpts_ignore_old_breakpoints = $rOpts->{'ignore-old-breakpoints'}; $rOpts_ignore_side_comment_lengths = $rOpts->{'ignore-side-comment-lengths'}; - $rOpts_ignore_perlcritic_side_comment_lengths = - $rOpts->{'ignore-perlcritic-side-comment-lengths'}; - $rOpts_indent_closing_brace = $rOpts->{'indent-closing-brace'}; - $rOpts_indent_columns = $rOpts->{'indent-columns'}; - $rOpts_indent_only = $rOpts->{'indent-only'}; - $rOpts_keep_interior_semicolons = $rOpts->{'keep-interior-semicolons'}; - $rOpts_line_up_parentheses = $rOpts->{'line-up-parentheses'}; - $rOpts_extended_block_tightness = $rOpts->{'extended-block-tightness'}; + $rOpts_ignore_perlcritic_comments = $rOpts->{'ignore-perlcritic-comments'}; + $rOpts_indent_closing_brace = $rOpts->{'indent-closing-brace'}; + $rOpts_indent_columns = $rOpts->{'indent-columns'}; + $rOpts_indent_only = $rOpts->{'indent-only'}; + $rOpts_keep_interior_semicolons = $rOpts->{'keep-interior-semicolons'}; + $rOpts_line_up_parentheses = $rOpts->{'line-up-parentheses'}; + $rOpts_extended_block_tightness = $rOpts->{'extended-block-tightness'}; $rOpts_extended_line_up_parentheses = $rOpts->{'extended-line-up-parentheses'}; $rOpts_logical_padding = $rOpts->{'logical-padding'}; @@ -9189,8 +9188,9 @@ sub store_token { my $ignore_sc_length = $rOpts_ignore_side_comment_lengths; - # Ignore length of '## no critic' comments if requested - if ( $rOpts_ignore_perlcritic_side_comment_lengths + # Ignore length of '## no critic' comments even if -iscl is not set + if ( !$ignore_sc_length + && !$rOpts_ignore_perlcritic_comments && $token_length > 10 && substr( $token, 1, 1 ) eq '#' && $token =~ /^##\s*no\s+critic\b/ ) diff --git a/t/snippets/comments3.par b/t/snippets/comments3.par index c3b787cb..feb212e0 100644 --- a/t/snippets/comments3.par +++ b/t/snippets/comments3.par @@ -1,4 +1,4 @@ --maximum-consecutive-blank-lines=2 # -mbl=2 --indent-spaced-block-comments # -isbc --no-format-skipping # -nfs ---noignore-perlcritic-side-comment-lengths # -nipscl +--ignore-perlcritic-comments # -ipc diff --git a/t/snippets17.t b/t/snippets17.t index 16ea5ce4..16e8fb64 100644 --- a/t/snippets17.t +++ b/t/snippets17.t @@ -55,7 +55,7 @@ BEGIN { --maximum-consecutive-blank-lines=2 # -mbl=2 --indent-spaced-block-comments # -isbc --no-format-skipping # -nfs ---noignore-perlcritic-side-comment-lengths # -nipscl +--ignore-perlcritic-comments # -ipc ---------- 'comments4' => <<'----------', # testing --keep-old-blank-lines=2 [=all] and -- 2.39.5