Description:
This update for perl-Perl-Tidy fixes the following issues:
- updated to 20240511
## 2024 05 11
- The option --valign-signed-numbers, or -vsn is now the default. It
was introduced in the previous release has been found to significantly
improve the overall appearance of columns of signed and unsigned
numbers. See the previous Change Log entry for an example.
This will change the formatting in scripts with columns
of vertically aligned signed and unsigned numbers.
Use -nvsn to turn this option off and avoid this change.
- Previously, a line break was made before a short concatenated terminal
quoted string, such as "\n", if the previous line had a greater
starting indentation. The break is now placed after the short quote.
This keeps code a little more compact. For example:
# old rule: break before "\n" here because '$name' has more indentation:
my $html = $this->SUPER::genObject( $query, $bindNode, $field . ":$var",
$name, "remove", "UNCHECKED" )
. "\n";
# new rule: break after a short terminal quote like "\n" for compactness;
my $html = $this->SUPER::genObject( $query, $bindNode, $field . ":$var",
$name, "remove", "UNCHECKED" ) . "\n";
- The option --delete-repeated-commas is now the default.
It makes the following checks and changes:
- Repeated commas like ',,' are removed with a warning
- Repeated fat commas like '=> =>' are removed with a warning
- The combination '=>,' produces a warning but is not changed
These warnings are only output if --warning-output, or -w, is set.
Use --nodelete-repeated-commas, or -ndrc, to retain repeated commas.
- The operator ``**=`` now has spaces on both sides by default. Previously,
there was no space on the left. This change makes its spacing the same
as all other assignment operators. The previous behavior can be obtained
with the parameter setting -nwls='**='.
- The option --file-size-order, or -fso is now the default. When
perltidy is given a list of multiple filenames to process, they
are sorted by size and processed in order of increasing size.
This can significantly reduce memory usage by Perl. This
option has always been used in testing, where typically several
jobs each operating on thousands of filenames are running at the
same time and competing for system resources. If this option
is not wanted for some reason, it can be deactivated with -nfso.
- In the option --dump-block-summary, the number of sub arguments indicated
for each sub now includes any leading object variable passed with
an arrow-operator call. Previously the count would have been decreased
by one in this case. This change is needed for compatibility with future
updates.
- Fix issue git #138 involving -xlp (--extended-line-up-parentheses).
When multiple-line quotes and regexes have long secondary lines, these
line lengths could influencing some spacing and indentation, but they
should not have since perltidy has no control over their indentation.
This has been fixed. This will mainly influence code which uses -xlp
and has long multi-line quotes.
- Add option --minimize-continuation-indentation, -mci (see git #137).
This flag allows perltidy to remove continuation indentation in some
special cases where it is not really unnecessary. For a simple example,
the default formatting for the following snippet is:
# perltidy -nmci
$self->blurt( "Error: No INPUT definition for type '$type', typekind '"
. $type->xstype
. "' found" );
The second and third lines are one level deep in a container, and
are also statement continuations, so they get indented by the sum
of the -i value and the -ci value. If this flag is set, the
indentation is reduced by -ci spaces, giving
# perltidy -mci
$self->blurt( "Error: No INPUT definition for type '$type', typekind '"
. $type->xstype
. "' found" );
This situation is relatively rare except in code which has long
quoted strings and the -nolq flag is also set. This flag is currently
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
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
and exits:
perltidy -dma somefile.pl >results.txt
The -warn version formats as normal but reports any issues as warnings in
the error file:
perltidy -wma somefile.pl
The -warn version may be customized with the following additional parameters
if necessary to avoid needless warnings:
--warn-mismatched-arg-types=s (or -wmat=s),
--warn-mismatched-arg-exclusion-list=s (or -wmaxl=s), and
--warn-mismatched-arg-undercount-cutoff=n (or -wmauc=n).
--warn-mismatched-arg-overcount-cutoff=n (or -wmaoc=n).
These are explained in the manual.
- Add option --valign-wide-equals, or -vwe, for issue git #135.
Setting this parameter causes the following assignment operators
= **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=
to be aligned vertically with the ending = all aligned. For example,
here is the default formatting of a snippet of code:
$str .= SPACE x $total_pad_count;
$str_len += $total_pad_count;
$total_pad_count = 0;
$str .= $rfields->[$j];
$str_len += $rfield_lengths->[$j];
And here is the same code formatted with -vwe:
# perltidy -vwe
$str .= SPACE x $total_pad_count;
$str_len += $total_pad_count;
$total_pad_count = 0;
$str .= $rfields->[$j];
$str_len += $rfield_lengths->[$j];
This option currently is off by default to avoid changing existing
formatting.
- Added control --delete-interbracket-arrows, or -dia, to delete optional
hash ref and array ref arrows between brackets as in the following
expression (see git #131)
return $self->{'commandline'}->{'arg_list'}->[0]->[0]->{'hostgroups'};
# perltidy -dia gives:
return $self->{'commandline'}{'arg_list'}[0][0]{'hostgroups'};
Added the opposite control --aia-interbracket-arrows, or -aia, to
add arrows. So applied to the previous line the arrows are restored:
# perltidy -aia
return $self->{'commandline'}->{'arg_list'}->[0]->[0]->{'hostgroups'};
The manual describes additional controls for adding and deleting
just selected interbracket arrows.
- updated to 20240202
see /usr/share/doc/packages/perl-Perl-Tidy/CHANGES.md
## 2024 02 02
- Added --valign-signed-numbers, or -vsn. This improves the appearance
of columns of numbers by aligning leading algebraic signs. For example:
# perltidy -vsn
my $xyz_shield = [
[ -0.060, -0.060, 0. ],
[ 0.060, -0.060, 0. ],
[ 0.060, 0.060, 0. ],
[ -0.060, 0.060, 0. ],
[ -0.0925, -0.0925, 0.092 ],
[ 0.0925, -0.0925, 0.092 ],
[ 0.0925, 0.0925, 0.092 ],
[ -0.0925, 0.0925, 0.092 ],
];
# perltidy -nvsn (current DEFAULT)
my $xyz_shield = [
[ -0.060, -0.060, 0. ],
[ 0.060, -0.060, 0. ],
[ 0.060, 0.060, 0. ],
[ -0.060, 0.060, 0. ],
[ -0.0925, -0.0925, 0.092 ],
[ 0.0925, -0.0925, 0.092 ],
[ 0.0925, 0.0925, 0.092 ],
[ -0.0925, 0.0925, 0.092 ],
];
This new option works well but is currently OFF to allow more testing
and fine-tuning. It is expected to be activated in a future release.
- Added --dump-mixed-call-parens (-dmcp ) which will dump a list of
operators which are sometimes followed by parens and sometimes not.
This can be useful for developing a uniform style for selected operators.
Issue git #128. For example
perltidy -dmcp somefile.pl >out.txt
produces lines like this, where the first number is the count of
uses with parens, and the second number is the count without parens.
k:caller:2:1
k:chomp:3:4
k:close:7:4
- Added --want-call-parens=s (-wcp=s) and --nowant-call-parens=s (-nwcp=s)
options which will warn of paren uses which do not match a selected
style. The manual has details. But for example,
perltidy -wcp='&' somefile.pl
will format as normal but warn if any user subs are called without parens.
- Added --dump-unusual-variables (-duv) option to dump a list of
variables with certain properties of interest. For example
perltidy -duv somefile.pl >vars.txt
produces a file with lines which look something like
1778:u: my $input_file
6089:r: my $j: reused - see line 6076
The values on the line which are separated by colons are:
line number - the number of the line of the input file
issue - a single letter indicating the issue, see below
variable name - the name of the variable, preceded by a keyword
note - an optional note referring to another line
The issue is indicated by a letter which may be one of:
r: reused variable name
s: sigil change but reused bareword
p: lexical variable with scope in multiple packages
u: unused variable
This is very useful for locating problem areas and bugs in code.
- Added a related flag --warn-variable-types=string (-wvt=string) option
to warn if certain types of variables are found in a script. The types
are a space-separated string which may include 'r', 's', and 'p' but
not 'u'. For example
perltidy -wvt='r s' somefile.pl
will check for and warn if any variabls of type 'r', or 's' are seen,
but not 'p'. All possible checks may be indicated with a '*' or '1':
perltidy -wvt='*' somefile.pl
The manual has further details.
- All parameters taking integer values are now checked for
out-of-range values before processing starts. When a maximum or
maximum range is exceeded, the new default behavior is to write a
warning message, reset the value to its default setting, and continue.
This default behavior can be changed with the new parameter
--integer-range-check=n, or -irc=n, as follows:
n=0 skip check completely (for stress-testing perltidy only)
n=1 reset bad values to defaults but do not issue a warning
n=2 reset bad values to defaults and issue a warning [DEFAULT]
n=3 stop immediately if any values are out of bounds
The settings n=0 and n=1 are mainly useful for testing purposes.
- 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).
- When braces are detected to be unbalanced, an attempt is made to
localize the error by comparing the indentation at closing braces
with their actual nesting levels. This can be useful for files which
have previously been formatted by perltidy. To illustrate, a test was
made in which the closing brace at line 30644 was commented out in
a file with a total of over 62000 lines. The new error message is
Final nesting depth of '{'s is 1
The most recent un-matched '{' is on line 6858
...
Table of nesting level differences at closing braces.
This might help localize brace errors if the file was previously formatted.
line: (brace level) - (level expected from old indentation)
30643: 0
30645: 1
Previously, the error file only indicated that the error in this case
was somewhere after line 6858, so the new table is very helpful. Closing
brace indentation is checked because it is unambiguous and can be done
very efficiently.
- The -DEBUG option no longer automatically also writes a .LOG file.
Use --show-options if the .LOG file is needed.
- The run time of this version with all new options in use is no greater
than that of the previous version thanks to optimization work.