=over 4
-=item *
-When prototypes or signatures are given, they are used to determine the
-expected number of sub arguments. Otherwise, the sub text is scanned.
-
=item *
This option works best for subs which unpack call args in an orderly
manner near the beginning of the sub from C<@_> and/or with C<shift>
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
=item *
B<--warn-mismatched-arg-undercount-cutoff=n>, or B<-wmauc=n>, can be used to
-avoid undercount warnings when the number of args expected is B<n> or less.
+avoid B<undercount> warnings when the expected number of args is less than B<n>.
Please note that this number B<n> is the number of args from the point of
view of the sub definition, so an object like C<$self> passed with an arrow
operator counts as one arg.
-The default value is B<n=3>. This has been found to allow most programs to
+The default value is B<n=4>. This has been found to allow most programs to
pass without warnings, but it should be reduced if possible for better error
checking. The minimum possible value of B<n> needed to avoid triggering an
error for a program can be determined by running with B<-wma -wmauc=0>. If
there are undercount errors, a note at the bottom of the error output
indicates the value of B<n> required to avoid reporting them.
+=item *
+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.
+
=back
To illustrate these controls,
$add_option->( 'warn-mismatched-args', 'wma', '!' );
$add_option->( 'warn-mismatched-arg-types', 'wmat', '=s' );
$add_option->( 'warn-mismatched-arg-undercount-cutoff', 'wmauc', '=i' );
+ $add_option->( 'warn-mismatched-arg-overcount-cutoff', 'wmaoc', '=i' );
$add_option->( 'warn-mismatched-arg-exclusion-list', 'wmaxl', '=s' );
$add_option->( 'add-interbracket-arrows', 'aia', '!' );
maximum-unexpected-errors=0
memoize
minimum-space-to-comment=4
- warn-mismatched-arg-undercount-cutoff=3
+ warn-mismatched-arg-undercount-cutoff=4
+ warn-mismatched-arg-overcount-cutoff=1
nobrace-left-and-indent
nocuddled-else
nodelete-old-whitespace
'maximum-unexpected-errors' => [ 0, undef ],
'minimum-space-to-comment' => [ 0, undef ],
'warn-mismatched-arg-undercount-cutoff' => [ 0, undef ],
+ 'warn-mismatched-arg-overcount-cutoff' => [ 0, undef ],
'one-line-block-nesting' => [ 0, 1 ],
'one-line-block-semicolons' => [ 0, 2 ],
'paren-tightness' => [ 0, 2 ],
# initialize for dump mode
my $ris_mismatched_call_type = { 'a' => 1, 'o' => 1, 'u' => 1, 'i' => 1 };
my $mismatched_arg_undercount_cutoff = 0;
+ my $mismatched_arg_overcount_cutoff = 0;
my $ris_mismatched_call_excluded_name = {};
if ($warn_mode) {
$ris_mismatched_call_type = \%warn_mismatched_arg_types;
$mismatched_arg_undercount_cutoff =
$rOpts->{'warn-mismatched-arg-undercount-cutoff'};
+ $mismatched_arg_overcount_cutoff =
+ $rOpts->{'warn-mismatched-arg-overcount-cutoff'};
$ris_mismatched_call_excluded_name =
\%is_warn_mismatched_arg_excluded_name;
}
# issue 'o': overcount
if ($num_over_count) {
- if ( $ris_mismatched_call_type->{'o'} ) {
+ if ( $ris_mismatched_call_type->{'o'}
+ && $shift_count_max >= $mismatched_arg_overcount_cutoff )
+ {
my $lines_over_count = stringify_line_range($rover_count);
my $total = $num_direct + $num_self;
# Skip the warning for small lists with undercount
if ( $ris_mismatched_call_type->{'u'}
- && $shift_count_min > $mismatched_arg_undercount_cutoff )
+ && $shift_count_min >= $mismatched_arg_undercount_cutoff )
{
my $lines_under_count = stringify_line_range($runder_count);
my $total = $num_direct + $num_self;
my $hint = EMPTY_STRING;
if ($number_of_undercount_warnings) {
+ my $wmauc_min = $max_shift_count_with_undercount + 1;
$hint = <<EOM;
-Note: use -wmauc=$max_shift_count_with_undercount or greater to prevent undercount warnings in this file
+Note: use -wmauc=$wmauc_min or greater to prevent undercount warnings in this file
EOM
}
return ( \@warnings, $hint );
# warn if call arg counts differ from sub definitions
# (requires version > 20240202.04)
--warn-mismatched-args
---warn-mismatched-arg-undercount-cutoff=4
+--warn-mismatched-arg-undercount-cutoff=5
# user-defined subs must have args in parens
--want-call-parens='&'