# Perltidy Change Log
-## 2023 09 12.03
+## 2023 09 12.04
- The --dump-block-summary (-dbs) option now includes the number of sub
args in the 'type' column. For example, 'sub(9)' indicates a sub
t/snippets26.t
t/snippets27.t
t/snippets28.t
+t/snippets29.t
t/snippets3.t
t/snippets4.t
t/snippets5.t
=head1 VERSION
-This man page documents perltidy version 20230912.03
+This man page documents perltidy version 20230912.04
=head1 BUG REPORTS
<h1>Perltidy Change Log</h1>
+<h2>2023 09 12.04</h2>
+
+<pre><code>- The --dump-block-summary (-dbs) option now includes the number of sub
+ args in the 'type' column. For example, 'sub(9)' indicates a sub
+ with 9 args. Subs whose arg count cannot easily be determined are
+ indicated as 'sub(*)'. The count does not include a leading '$self'
+ or '$class' arg.
+
+- Added flag --space-signature-paren=n, or -ssp=n (issue git #125).
+ This flag works the same as the existing flag --space-prototype-paren=n
+ except that it applies to the space before the opening paren of a sub
+ signature instead of a sub prototype. Previously, there was no control
+ over this (a space always occurred). For example, given the following
+ line:
+
+ sub circle( $xc, $yc, $rad );
+
+ The following results can now be obtained, according to the value of n:
+
+ sub circle( $xc, $yc, $rad ); # n=0 [no space]
+ sub circle( $xc, $yc, $rad ); # n=1 [default; same as input]
+ sub circle ( $xc, $yc, $rad ); # n=2 [space]
+
+ The spacing in previous versions of perltidy corresponded to n=2 (always
+ a space). The new default value, n=1, will produce a space if and only
+ if there was a space in the input text.
+
+- The dump-block-summary option can report an if-elsif-elsif-.. chain
+ as a single line item with the notation -dbt='elsif3', for example,
+ where the '3' is an integer which specifies the minimum number of elsif
+ blocks required for a chain to be reported. The manual has details.
+
+- Fix problem c269, in which the new -ame parameter could incorrectly
+ emit an else block when two elsif blocks were separated by a hanging
+ side comment (a very rare situation).
+</code></pre>
+
<h2>2023 09 12</h2>
<pre><code>- Fix for git #124: remove a syntax error check which could cause
<h1 id="VERSION">VERSION</h1>
-<p>This man page documents Perl::Tidy version 20230912</p>
+<p>This man page documents Perl::Tidy version 20230912.04</p>
<h1 id="LICENSE">LICENSE</h1>
sub usage(); # n=1 [default; follows input]
sub usage (); # n=2 [space]</code></pre>
+</dd>
+<dt id="ssp-n-or---space-signature-paren-n"><b>-ssp=n</b> or <b>--space-signature-paren=n</b></dt>
+<dd>
+
+<p>This flag is analogous to the previous except that it applies to the space before the opening paren of a sub <b>signature</b> rather than a sub <b>prototype</b>.</p>
+
+<p>For example, consider the following line:</p>
+
+<pre><code> sub circle( $xc, $yc, $rad )</code></pre>
+
+<p>This space before the opening paren can be controlled with integer <b>n</b> which may have the value 0, 1, or 2 with these meanings:</p>
+
+<pre><code> -ssp=0 means no space before the paren
+ -ssp=1 means follow the example of the source code [DEFAULT]
+ -ssp=2 means always put a space before the paren</code></pre>
+
+<p>The default is <b>-ssp=1</b>, meaning that will be a space in the output if, and only if, there is one in the input. Given the above line of code, the result of applying the different options would be:</p>
+
+<pre><code> sub circle( $xc, $yc, $rad ) # n=0 [no space]
+ sub circle( $xc, $yc, $rad ) # n=1 [default; same as input]
+ sub circle ( $xc, $yc, $rad ) # n=2 [space]</code></pre>
+
</dd>
<dt id="kpit-n-or---keyword-paren-inner-tightness-n"><b>-kpit=n</b> or <b>--keyword-paren-inner-tightness=n</b></dt>
<dd>
<p>This feature was developed to help identify complex sections of code as an aid in refactoring. The McCabe complexity measure follows the definition used by Perl::Critic. By default the table contains these values for subroutines, but the user may request them for any or all blocks of code or packages. For blocks which are loops nested within loops, a postfix '+' to the <code>type</code> is added to indicate possible code complexity. Although the table does not otherwise indicate which blocks are nested in other blocks, this can be determined by computing and comparing the block ending line numbers.</p>
+<p>For subroutines, the number of call arguments (args) is listed in parentheses in the <code>type</code> column. For example, <code>sub(9)</code> indicates a sub with 9 args. Subroutines whose arg count cannot easily be determined are indicated as <code>sub(*)</code>. The count does not include a leading variable named <b>$self</b> or <b>$class</b>.</p>
+
<p>By default the table lists subroutines with more than 20 <code>code_lines</code>, but this can be changed with the following two parameters:</p>
-<p><b>--dump-block-minimum-lines=n</b>, or <b>-dbl=n</b>, where <b>n</b> is the minimum number of <code>code_lines</code> to be included. The default is <b>-n=20</b>. Note that <code>code_lines</code> is the number of lines excluding and comments, blanks and pod.</p>
+<p><b>--dump-block-minimum-lines=n</b>, or <b>-dbl=n</b>, where <b>n</b> is the minimum number of <code>code_lines</code> to be included. The default is <b>-n=20</b>. Note that <code>code_lines</code> is the number of lines excluding comments, blanks and pod.</p>
<p><b>--dump-block-types=s</b>, or <b>-dbt=s</b>, where string <b>s</b> is a list of block types to be included. The type of a block is either the name of the perl builtin keyword for that block (such as <b>sub if elsif else for foreach ..</b>) or the word immediately before the opening brace. In addition, there are a few symbols for special block types, as follows:</p>
* - any block except nameless blocks
+ - any nested inner block loop
package - any package or class
- closure - any nameless block</code></pre>
+ closure - any nameless block
+ elsif3 - an if-elsif-..-else chain with 3 or more elsif's (3 is arbitrary, see below)</code></pre>
+
+<p>A chain of <b>if-elsif-...</b> blocks may be reported as a single line item by entering the word <b>elsif</b> with an appended integer, as indicated by the last item in this list. The integer indicates the number of <b>elsif</b> blocks required for a chain to be reported. If you use this, you may want to also use <b>-dbl=n</b>, with a smaller number of lines <b>n</b> than the default.</p>
<p>In addition, specific block loop types which are nested in other loops can be selected by adding a <b>+</b> after the block name. (Nested loops are sometimes good candidates for restructuring).</p>
<pre><code> perltidy -dbs -dbl=1 -dbt='* closure' somefile.pl >blocks.csv</code></pre>
+</li>
+<li><p>This selects every if-chain which contains 2 or more <b>elsif</b> blocks:</p>
+
+<pre><code> perltidy -dbs -dbl=1 -dbt='elsif2' somefile.pl >blocks.csv</code></pre>
+
</li>
</ul>
<h1 id="VERSION">VERSION</h1>
-<p>This man page documents perltidy version 20230912</p>
+<p>This man page documents perltidy version 20230912.04</p>
<h1 id="BUG-REPORTS">BUG REPORTS</h1>
# then the Release version must be bumped, and it is probably past time for
# a release anyway.
- $VERSION = '20230912.03';
+ $VERSION = '20230912.04';
} ## end BEGIN
sub DESTROY {
=head1 VERSION
-This man page documents Perl::Tidy version 20230912.03
+This man page documents Perl::Tidy version 20230912.04
=head1 LICENSE
use strict;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use constant EMPTY_STRING => q{};
use constant SPACE => q{ };
use strict;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use constant EMPTY_STRING => q{};
package Perl::Tidy::FileWriter;
use strict;
use warnings;
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use constant DEVEL_MODE => 0;
use constant EMPTY_STRING => q{};
use Carp;
use English qw( -no_match_vars );
use List::Util qw( min max first ); # min, max first are in Perl 5.8
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
# The Tokenizer will be loaded with the Formatter
##use Perl::Tidy::Tokenizer; # for is_keyword()
my $type_p = $rLL->[$K_p]->[_TYPE_];
my $token_p = $rLL->[$K_p]->[_TOKEN_];
- if ( $type_p eq 'k'
- && $token_p =~ /^(my|our|local)$/ )
- {
+ if ( $type_p eq 'k' && $is_my_our_local{$token_p} ) {
next;
}
- if ( $type_p eq 'i'
- && $token_p =~ /^\$(self|class)$/ )
+ if ( $type_p eq 'i'
+ && ( $token_p eq '$self' || $token_p eq '$class' ) )
{
$arg_count_by_seqno{$seqno_current} = -1;
$saw_self = 1;
package Perl::Tidy::HtmlWriter;
use strict;
use warnings;
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use English qw( -no_match_vars );
use File::Basename;
use strict;
use warnings;
use Carp;
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use constant DEVEL_MODE => 0;
use constant EMPTY_STRING => q{};
use strict;
use warnings;
use Carp;
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use constant DEVEL_MODE => 0;
package Perl::Tidy::IndentationItem;
use strict;
use warnings;
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
BEGIN {
package Perl::Tidy::Logger;
use strict;
use warnings;
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use English qw( -no_match_vars );
use constant DEVEL_MODE => 0;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use Carp;
use warnings;
use Carp;
use English qw( -no_match_vars );
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
use Perl::Tidy::VerticalAligner::Alignment;
use Perl::Tidy::VerticalAligner::Line;
{ #<<< A non-indenting brace
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
sub new {
my ( $class, $rarg ) = @_;
use strict;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20230912.03';
+our $VERSION = '20230912.04';
sub AUTOLOAD {