This may or may not be an error, but it is worth checking. It might become an
error in the future if sub C<Fault> starts to access C<$self>.
-=item B<o:> (B<overcount): the number of call args exceeds the expected number.
+=item B<o:> (B<overcount>): the number of call args exceeds the expected number.
-=item B<u:> (B<undercount): the number of call args is less than the expected number.
+=item B<u:> (B<undercount>): the number of call args is less than the expected number.
For example
=back
-B<Some Limitations:>
+B<Notes and Limitations:>
=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>
skipped, regardless of package.
=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. 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 pass
-without warnings, but it should be reduced if possible for better error
+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.
+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
+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<-wmauc=0>, or by
-running with B<--dump-mismatched-args>. The output shows, for each mismatch,
-the number of args expected by a sub plus the range of the number of args
-actually passed to it.
+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.
+
+=back
To illustrate these controls,
=back
-=back
-
=head2 B<Working with MakeMaker, AutoLoader and SelfLoader>
The first $VERSION line of a file which might be eval'd by MakeMaker
# output for multiple types
my $output_string = <<EOM;
-Issues abbreviations u=unused r=reused s=multi-sigil p=package crossing
+Issue abbreviations u=unused r=reused s=multi-sigil p=package crossing
Line:Issue: Var: note
EOM
foreach my $item ( @{$rlines} ) {
# Now look for issues
#--------------------
my @warnings;
+ my $max_shift_count_with_undercount = 0;
+ my $number_of_undercount_warnings = 0;
# Look at each key:
foreach my $key ( keys %common_hash ) {
# issue 'u': undercount
if ($num_under_count) {
+ if ( $shift_count_min > $max_shift_count_with_undercount ) {
+ $max_shift_count_with_undercount = $shift_count_min;
+ }
+
# Skip the warning for small lists with undercount
if ( $ris_mismatched_call_type->{'u'}
&& $shift_count_min > $mismatched_arg_undercount_cutoff )
$note =
"missing args at $num_under_count of $total calls($lines_under_count)";
+ $number_of_undercount_warnings++;
push @warnings,
{
line_number => $lno,
} @warnings;
}
- return \@warnings;
+ my $hint = EMPTY_STRING;
+ if ($number_of_undercount_warnings) {
+ $hint = <<EOM;
+Note: use -wmauc=$max_shift_count_with_undercount or greater to prevent undercount warnings in this file
+EOM
+ }
+ return ( \@warnings, $hint );
} ## end sub cross_check_call_args
sub stringify_line_range {
# - warn-mismatched-arg-exclusion-list
# - warn-mismatched-arg-undercount-cutoff
- my $rwarnings = $self->cross_check_call_args(1);
+ my ( $rwarnings, $hint ) = $self->cross_check_call_args(1);
return unless ( $rwarnings && @{$rwarnings} );
my $wma_key = 'warn-mismatched-args';
my $output_string = "Begin scan for --$wma_key\n";
$output_string .= <<EOM;
-Line:Mismatch:Name:#args:Min:Max: note
+Issue abbreviations a=arrow mismatch u=undercount o=overcount
+Line:Issue:Name:#args:Min:Max: note
EOM
# output the results, ignoring any excluded names
$output_string .=
"$lno:$letter:$name:$shift_count:$min_arg_count:$max_arg_count: $note\n";
}
+ if ($hint) { $output_string .= $hint }
$output_string .= "End scan for --$wma_key\n";
warning($output_string);
# process a --dump-mismatched-args command
- my $rwarnings = $self->cross_check_call_args(0);
+ my ( $rwarnings, $hint ) = $self->cross_check_call_args(0);
return unless ( $rwarnings && @{$rwarnings} );
my $output_string = <<EOM;
-Line:Mismatch:Name:#args:Min:Max: note
+Issue abbreviations a=arrow mismatch u=undercount o=overcount i=indeterminate
+Line:Issue:Name:#args:Min:Max: note
EOM
foreach my $item ( @{$rwarnings} ) {
my $lno = $item->{line_number};