# Perltidy Change Log
-## 2024 05 11.04
+## 2024 05 11.05
- Add options --dump-mismatched-returns (or -dmr) and
--warn-mismatched-returns (or -wmr). These options report function
undercounts but not arrows. Skip checking for any sub named C<new> or C<old>,
and only warn of undercounts for subs expecting more than 2 args.
-=back
-
=item B<Use --dump-mismatched-returns> to find function calls where the number of requested values may disagree with sub return statements
The parameter B<--dump-mismatched-returns>, or B<-dmr>, examines the return
return ( $name, $flags ); # 2 values with 'return' statement
}
- ( $name ) = $self->info(); # type 'u' (want 1 < 2)
+ $name = $self->info(); # type 'u' (want 1 < 2)
( $name, $flags, $access) = $self->info(); # type 'o' (want 3 > 2)
Issues are only reported when the return transaction involves two or more list
=back
+=back
+
=head2 B<Working with MakeMaker, AutoLoader and SelfLoader>
The first $VERSION line of a file which might be eval'd by MakeMaker
=head1 VERSION
-This man page documents perltidy version 20240511.04
+This man page documents perltidy version 20240511.05
=head1 BUG REPORTS
<h1>Perltidy Change Log</h1>
-<h2>2024 05 11.04</h2>
+<h2>2024 05 11.05</h2>
-<pre><code>- A option was added to filter unimplemented parameters from perltidy
+<pre><code>- Add options --dump-mismatched-returns (or -dmr) and
+ --warn-mismatched-returns (or -wmr). These options report function
+ calls where the number of requested values may disagree with sub
+ return statements. The -dump version writes the results for a single
+ file to standard output and exits:
+
+ perltidy -dmr somefile.pl >results.txt
+
+ The -warn version formats as normal but reports any issues as warnings in
+ the error file:
+
+ perltidy -wmr somefile.pl
+
+ The -warn version may be customized with the following additional
+ parameters if necessary to avoid needless warnings:
+
+ --warn-mismatched-return-types=s (or -wmrt=s),
+ --warn-mismatched-return-exclusion-list=s (or -wmrxl=s)
+
+ These are explained in the manual.
+
+- Updates for issue git #151:
+ (1) --warn-variable-types=u is now okay if it is on the command line
+ with a named file.
+ (2) --warn-variable-exclusion-list=s now allows leading and/or
+ trailing * on variable names to allow a wildcard match. For example
+ -wvxl='*_unused' is okay.
+ (3) --dump-unusual-variables now outputs the filename.
+
+- A option was added to filter unimplemented parameters from perltidy
configuration files, suggested in git #146. If a line in the config
file begins with three dashes followed by a parameter name
(rather than two), then the line will be removed if the parameter is
unknown. Otherwise, a dash will be removed to make the line valid.
- Parameters --dump-mismatched-args (or -dma) and
- --warn-mismatched-arg (or -wma) have been updated to catch more
+ --warn-mismatched-args (or -wma) have been updated to catch more
arg count issues.
- Fix issue git #143, extend -add-trailing-commas to apply to a list
off by default, but it could become the default in a future version.
- Add options --dump-mismatched-args (or -dma) and
- --warn-mismatched-arg (or -wma). These options look
+ --warn-mismatched-args (or -wma). These options look
for and report instances where the number of args expected by a
sub appear to differ from the number passed to the sub. The -dump
version writes the results for a single file to standard output
<h1 id="VERSION">VERSION</h1>
-<p>This man page documents Perl::Tidy version 20240511.04</p>
+<p>This man page documents Perl::Tidy version 20240511.05</p>
<h1 id="LICENSE">LICENSE</h1>
<p>The 'u' option (unused) has a limitation: it is not allowed in a <i>.perltidyrc</i> configuration file. But it can be used on the command line provided that perltidy is operating on a named file. This rule is necessary to avoid warnings when perltidy is run on small snippets of code from within an editor.</p>
-<p>A companion flag, <b>--warn-variable-exclusion-list=string</b>, or <b>-wvxl=string</b>, can be used to skip warning checks for a list of variable names. A leading and/or trailing '*' may be placed on any of these variable names to allow a partial match. For example</p>
+<p>A companion flag, <b>--warn-variable-exclusion-list=string</b>, or <b>-wvxl=string</b>, can be used to skip warning checks for a list of variable names. A leading and/or trailing '*' may be placed on any of these variable names to allow a partial match.</p>
<p>For example,</p>
<p>will format <i>somefile.pl</i> and report any arrow-type mismatches and overcount mismatches, but will skip undercount mismatches.</p>
</li>
-<li><p><b>--warn-mismatched-arg-exclusion-list</b>, or <b>-wmaxl=string</b>, can be given to skip the warning checks for a list of subroutine names, entered as a quoted string of space- or comma-separated names. All subs with those names will be skipped, regardless of package.</p>
+<li><p><b>--warn-mismatched-arg-exclusion-list</b>, or <b>-wmaxl=string</b>, can be given to skip the warning checks for a list of subroutine names, entered as a quoted string of space- or comma-separated names, without a package prefix. All subs with those names will be skipped, regardless of package. A leading and/or trailing <b>*</b> on a name may be used to indicate a partial string match.</p>
</li>
<li><p><b>--warn-mismatched-arg-undercount-cutoff=n</b>, or <b>-wmauc=n</b>, can be used to avoid <b>undercount</b> warnings when the expected number of args is less than <b>n</b>. Please note that this number <b>n</b> is the number of args from the point of view of the sub definition, so an object like <code>$self</code> passed with an arrow operator counts as one arg.</p>
<p>means format <i>somefile.pl</i> as usual and check for mismatched overcounts and undercounts but not arrows. Skip checking for any sub named <code>new</code> or <code>old</code>, and only warn of undercounts for subs expecting more than 2 args.</p>
+</dd>
+<dt id="Use---dump-mismatched-returns-to-find-function-calls-where-the-number-of-requested-values-may-disagree-with-sub-return-statements"><b>Use --dump-mismatched-returns</b> to find function calls where the number of requested values may disagree with sub return statements</dt>
+<dd>
+
+<p>The parameter <b>--dump-mismatched-returns</b>, or <b>-dmr</b>, examines the return side of sub call statements. Like all <b>--dump</b> commands, it writes its report to standard output and exits immediately. For example</p>
+
+<pre><code> perltidy -dmr somefile.pl >results.txt</code></pre>
+
+<p>Three types of issues are reported:</p>
+
+<dl>
+
+<dt id="x:-calls-requesting-values-from-a-sub-without-a-return-statement"><b>x:</b> calls requesting values from a sub without a return statement.</dt>
+<dd>
+
+</dd>
+<dt id="o:-overwant-:-the-number-of-values-wanted-by-the-caller-exceeds-the-number-returned-by-the-sub"><b>o:</b> (<b>overwant</b>): the number of values wanted by the caller exceeds the number returned by the sub.</dt>
+<dd>
+
+</dd>
+<dt id="u:-underwant-:-the-number-of-values-wanted-by-the-caller-is-less-than-the-number-returned-by-the-sub"><b>u:</b> (<b>underwant</b>): the number of values wanted by the caller is less than the number returned by the sub.</dt>
+<dd>
+
+</dd>
+</dl>
+
+<p>The three issue types are illustrated with the following code</p>
+
+<pre><code> sub old_school {
+ ...
+ ( $name, $flags ); # 2 values but no 'return' statement
+ }
+
+ ( $name, $flags ) = old_school(); # type 'x' (no return stmt)
+
+ sub info {
+ ...;
+ return ( $name, $flags ); # 2 values with 'return' statement
+ }
+
+ $name = $self->info(); # type 'u' (want 1 < 2)
+ ( $name, $flags, $access) = $self->info(); # type 'o' (want 3 > 2)</code></pre>
+
+<p>Issues are only reported when the return transaction involves two or more list elements, and only when a specific number can be determined. Only return statements are scanned, so this analysis will not work for all programming styles. Reported issues are not necessarily errors, but they might be, or they might indicate potentially confusing code.</p>
+
+</dd>
+<dt id="Use---warn-mismatched-returns-to-issue-warnings-when-the-number-of-requested-values-may-disagree-with-sub-return-statements"><b>Use --warn-mismatched-returns</b> to issue warnings when the number of requested values may disagree with sub return statements</dt>
+<dd>
+
+<p>This is similar to the <b>-dump</b> parameter described above except that any mismatches are reported in the error file and otherwise formatting continues normally. The basic usage is</p>
+
+<pre><code> perltidy -wmr somefile.pl</code></pre>
+
+<p>The following companion controls are available to avoid unwanted error messages:</p>
+
+<ul>
+
+<li><p><b>--warn-mismatched-return-types=s</b>, or <b>-wmrt=s</b>, can be used to limit checks.</p>
+
+<p>To restrict the checking, set the string equal to the letter(s) of that warning, any <b>x</b>, <b>o</b>, or <b>u</b>. For example</p>
+
+<pre><code> perltidy -wmrt='x o' somefile.pl</code></pre>
+
+<p>will format <i>somefile.pl</i> and report issue types <b>x</b> and <b>o</b> but not type <b>u</b>. All checks may be requested with <b>-wmrt='*'</b> or <b>-wmrt=1</b>. This is the default.</p>
+
+</li>
+<li><p><b>--warn-mismatched-return-exclusion-list</b>, or <b>-wmrxl=string</b>, can be given to skip the warning checks for a list of subroutine names, entered as a quoted string of space- or comma-separated names, without a package prefix. All subs with those names will be skipped, regardless of package. A leading and/or trailing <b>*</b> on a name may be used to indicate a partial string match.</p>
+
+</li>
+</ul>
+
</dd>
</dl>
<h1 id="VERSION">VERSION</h1>
-<p>This man page documents perltidy version 20240511.04</p>
+<p>This man page documents perltidy version 20240511.05</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 = '20240511.04';
+ $VERSION = '20240511.05';
} ## end BEGIN
sub DESTROY {
=head1 VERSION
-This man page documents Perl::Tidy version 20240511.04
+This man page documents Perl::Tidy version 20240511.05
=head1 LICENSE
use strict;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use constant EMPTY_STRING => q{};
use constant SPACE => q{ };
use strict;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use constant EMPTY_STRING => q{};
package Perl::Tidy::FileWriter;
use strict;
use warnings;
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
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 = '20240511.04';
+our $VERSION = '20240511.05';
# The Tokenizer will be loaded with the Formatter
##use Perl::Tidy::Tokenizer; # for is_keyword()
package Perl::Tidy::HtmlWriter;
use strict;
use warnings;
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use Carp;
use English qw( -no_match_vars );
use strict;
use warnings;
use Carp;
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use constant DEVEL_MODE => 0;
use constant EMPTY_STRING => q{};
use strict;
use warnings;
use Carp;
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use constant DEVEL_MODE => 0;
use strict;
use warnings;
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
BEGIN {
package Perl::Tidy::Logger;
use strict;
use warnings;
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use Carp;
use English qw( -no_match_vars );
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use Carp;
{ #<<< A non-indenting brace to contain all lexical variables
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use English qw( -no_match_vars );
use Scalar::Util 'refaddr';
use Perl::Tidy::VerticalAligner::Alignment;
use strict;
use warnings;
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
sub new {
my ( $class, $rarg ) = @_;
use strict;
use warnings;
-our $VERSION = '20240511.04';
+our $VERSION = '20240511.05';
use English qw( -no_match_vars );
sub AUTOLOAD {