## 2024 02 02.07
+ - 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. It will change formatting slightly in scripts with columns
+ of vertically aligned numbers, and can be deactivated with -nvsn.
+
+ - 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
perltidy -wma somefile.pl
- The -warn version may be customized with three additional parameters if
- necessary to avoid needless warnings:
+ 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.
This option currently is off by default to avoid changing existing
formatting.
- - 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";
-
- - 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.
-
- - 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.
-
- - 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. It will change formatting slightly in scripts with columns
- of vertically aligned numbers, and can be deactivated with -nvsn.
-
- - 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.
-
- 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)
Perltidy reports any obvious issues that are found during formatting, such as
unbalanced braces. But several parameters are available for making certain
-additional checks for issues which might be of interest to a programmer.
+additional checks for issues which might be of interest to a programmer. These
+parameters fall into two categories as indicated by their prefix, B<--dump-> or
+B<--warn->:
+
+=over 4
+
+=item *
+The B<--dump-> parameters read a file, write information to the standard output,
+and then exit without doing any formatting.
+
+=item *
+The B<--warn-> parameters, on the other hand, cause perltidy to function
+normally but issue warnings to the error output when certain conditions are
+encountered.
+
+=back
+
+Some of these have associated control parameters.
=over 4
The parameter B<--dump-mismatched-args>, or B<-dma>, causes perltidy to
examine the definitions of subroutines in a file, and calls to those subs,
-and report any apparent differences. Like all B<--dump> commands, it
+and report certain differences. Like all B<--dump> commands, it
writes its report to standard output and exits immediately. For example
perltidy -dma somefile.pl >results.txt
Only calls which appear to be to subs defined within the file being
processed are checked. But note that a file may contain multiple packages.
-=item *
-When prototypes or signatures are given, they are used to determine the
-expected number of sub arguments. Otherwise, the sub text is scanned.
-
=back
=item B<Use --warn-mismatched-args to produce a warning for function calls with
B<--warn-mismatched-arg-overcount-cutoff=n>, or B<-wmaoc=n>, can be used to
avoid B<overcount> warnings when the expected number of args is less than B<n>.
The default value is B<n=1>. This avoids warning messages for subroutines
-which are dummy placeholders for future development.
+which are dummy placeholders for possible expansion.
=back
if (DEVEL_MODE) {
my @non_existant;
foreach ( 0 .. _LAST_SELF_INDEX_ ) {
- if ( !exists( $self->[$_] ) ) {
+ if ( !exists $self->[$_] ) {
push @non_existant, $_;
}
}
return unless $str;
$str =~ s/\s+$//;
$str =~ s/^\s+//;
- return split( /\s+/, $str );
+ return split /\s+/, $str;
} ## end sub split_words
###########################################
if ( my @q = split_words( $rOpts->{'nospace-after-keyword'} ) ) {
# -nsak='*' selects all the above keywords
- if ( @q == 1 && $q[0] eq '*' ) { @q = keys(%space_after_keyword) }
+ if ( @q == 1 && $q[0] eq '*' ) { @q = keys %space_after_keyword }
@space_after_keyword{@q} = (0) x scalar(@q);
}
my $output_string = <<EOM;
counts with and without call parens made by --dump-mixed-call-parens
+use -wcp=s and/or nwcp=s to find line numbers, where s is a string of words
types are 'k'=builtin keyword 'U'=user sub 'w'=other word
type:word:+count:-count
EOM
)
{
$rsub_call_paren_info_by_seqno->{$type_sequence} = {
- token_mm => $last_last_nonblank_code_token,
- type_mm => $last_last_nonblank_code_type,
- token_m => $last_nonblank_code_token,
- type_m => $last_nonblank_code_type,
+ type_mm => $last_last_nonblank_code_type,
+ token_m => $last_nonblank_code_token,
};
}
}
$count_min = undef if ( !$saw_semicolon );
return;
};
- while ( my $ch = shift(@chars) ) {
+ while ( my $ch = shift @chars ) {
if ( !defined($ch) ) { $saw_array->(); last }
elsif ( $ch eq '(' ) { last if ($count_min) }
elsif ( $ch eq ')' ) { last }
elsif ( $token eq '$_' ) {
# Found $_: currently the search ends at '$_['
- # TODO: eventually this can be handled
my $Kn = $self->K_next_code($KK);
if ( $Kn && $rLL->[$Kn]->[_TOKEN_] eq '[' ) {
return;
my $item = $rsub_call_paren_info_by_seqno->{$seqno};
my $name = $item->{token_m};
my $type_mm = $item->{type_mm};
- ## These values are available but currently unused: [TODO: maybe remove]
- ## my $type_m = $item->{type_m};
- ## my $token_mm = $item->{token_mm};
# find function and package
my $is_ampersand_call;
$name = substr( $name, 1 );
}
+ my $call_type = $is_ampersand_call ? '&' : EMPTY_STRING;
+ my $caller_name = EMPTY_STRING;
+ if ( $type_mm eq '->' ) {
+ $call_type = '->';
+ my $K_m = $self->K_previous_code($Ko);
+ my $K_mm = $self->K_previous_code($K_m);
+ my $K_mmm = $self->K_previous_code($K_mm);
+ if ( defined($K_mmm) && $rLL->[$K_mmm]->[_TYPE_] eq 'i' ) {
+ $caller_name = $rLL->[$K_mmm]->[_TOKEN_];
+ }
+ }
+
# look for explicit package on name
my $package = $current_package;
if ( ( index( $name, ':' ) >= 0 || index( $name, "'" ) >= 0 )
$arg_count = $item->{shift_count_min};
}
- my $call_type = $is_ampersand_call ? '&' : EMPTY_STRING;
- my $caller_name = EMPTY_STRING;
- if ( $type_mm eq '->' ) {
- $call_type = '->';
- my $K_m = $self->K_previous_code($Ko);
- my $K_mm = $self->K_previous_code($K_m);
- my $K_mmm = $self->K_previous_code($K_mm);
- if ( defined($K_mmm) && $rLL->[$K_mmm]->[_TYPE_] eq 'i' ) {
- $caller_name = $rLL->[$K_mmm]->[_TOKEN_];
- }
- }
-
# update the hash of info for this item
my $line_number = $rLL->[$Ko]->[_LINE_INDEX_] + 1;
$item->{arg_count} = $arg_count;
return unless (@ilist);
my $max_line = @{$ri_first} - 1;
- my $inext = shift(@ilist);
+ my $inext = shift @ilist;
# loop over lines, checking length of each with a one-line block
my ( $ibeg, $iend );