| 1 | # ABSTRACT: Make sure your POD covers more ground than just subroutines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # PODNAME: Pod::Coverage::More | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Pod::Coverage::More 0.005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use 5.036; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 13 | ▶ | use warnings FATAL => q{all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use re q{/xsaa}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use List::Util qw{all any none}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use Module::Runtime qw{module_notional_filename require_module}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | use mro; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 13 | ▶ | use Package::Stash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 13 | ▶ | use Pod::Find qw(pod_where); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 13 | ▶ | use Types::Standard qw{Any ArrayRef CodeRef GlobRef HashRef ScalarRef Str}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 13 | ▶ | use parent 'Pod::Coverage::TrustPod'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 13 | ▶ | use Pod::Coverage::More::Analyzer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 13 | ▶ | use Pod::Coverage::More::Documentation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Set to print what the parse and the coverage found, for debugging. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 13 | our $TRACE_ALL = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 13 | our @CHECKS = qw{arguments argument_types returns termination examples}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # The fraction of the public subs that the POD documents, as L<Pod::Coverage> rates it, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # from the headings that L<Pod::Coverage::More::Documentation> reads. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # Nothing when the package has no POD or no public subs, and C<why_unrated> says why. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # @returns Num from 0 to 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # @example my $rating = $pc->coverage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 15 | ▶ | sub coverage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage: called CC=11 SCAR=25.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 15 | my $package = $self->{package}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 15 | my $doc = $self->_documentation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 15 | _trace_dump($doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 15 | ▶ | return unless $doc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 14 | my %symbols = map { $_ => 0 } $self->_get_syms($package); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 14 | ▶ | if ( !%symbols && $self->{why_unrated} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not %symbols and $self->{"why_unrated"}
MC/DC0%0/2
not %symbols and $self->{"why_unrated"}
not %symbols
$self->{"why_unrated"}
Truth table33%1/3
not(A) and B
A= not %symbolsB= $self->{"why_unrated"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # _get_syms failed violently | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 14 | ▶ | print "tying shoelaces\n" if $TRACE_ALL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 14 | foreach my $documentation ( $self->_documentations ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 15 | foreach my $pod ( $documentation->identifiers ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 135 | ▶ | $symbols{$pod} = 1 if exists $symbols{$pod}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 14 | foreach my $sym ( keys %symbols ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 139 | ▶ | $symbols{$sym} = 1 if $self->_trustme_check($sym); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # stash the results for later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 14 | $self->{symbols} = \%symbols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 14 | _trace_dump($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 14 | my $symbols = scalar keys %symbols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 14 | my $documented = scalar grep { $_ } values %symbols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 14 | ▶ | unless ($symbols) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $self->{why_unrated} = "no public symbols defined"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 14 | return $documented / $symbols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # The failures of each check, for each public sub that has a section in the POD: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # a HASHREF from the name of the sub to a HASHREF with C<section>, the section that C<section_for> returns, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # C<inherited>, true when that section is in the POD of a parent class, and C<failures>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # a HASHREF from the name of each check in THE CHECKS to an ARRAYREF of the messages of its failures, empty when it passes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # The report is made once. Nothing when there is no POD to rate, and C<why_unrated> says why. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # @returns HashRef the report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # @example my $failures = $pc->coverage_report->{resize}{failures}{examples}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 24 | ▶ | sub coverage_report { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage_report: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 24 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 24 | ▶ | return $self->{report} if $self->{report}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 19 | ▶ | return if !$self->_documentation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 18 | my $analysis = $self->analysis; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 18 | my %report; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 18 | foreach my $name ( sort $self->_get_syms( $self->{package} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 257 | ▶ | my $section = $self->section_for($name) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 255 | ▶ | my $rec = $analysis->{$name} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 255 | ▶ | my $inherited = $self->_documentation->section_for($name) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 255 | my %failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 255 | foreach my $check (@CHECKS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1275 | my $method = "_check_$check"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1275 | $failures{$check} = [ $self->$method( $name, $section, $rec, $inherited ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 255 | $report{$name} = { section => $section, inherited => $inherited, failures => \%failures }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 18 | return $self->{report} = \%report; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # The result of the B<arguments> check over every sub: a HASHREF with C<status>, true when it passes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # and C<message>, the messages of its failures, one per line, or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # @returns HashRef with status and message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # @example my $result = $pc->coverage_arguments; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # @example print $result->{message} if !$result->{status}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | ▶ | sub coverage_arguments { my ($self) = @_; return $self->_check_result('arguments') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage_arguments: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # The result of the B<argument_types> check, as C<coverage_arguments> returns it for its check. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # @returns HashRef with status and message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # @example my $result = $pc->coverage_argument_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | ▶ | sub coverage_argument_types { my ($self) = @_; return $self->_check_result('argument_types') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage_argument_types: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # The result of the B<returns> check, as C<coverage_arguments> returns it for its check. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # @returns HashRef with status and message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # @example my $result = $pc->coverage_return_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | sub coverage_return_types { my ($self) = @_; return $self->_check_result('returns') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage_return_types: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # The result of the B<termination> check, as C<coverage_arguments> returns it for its check. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # @returns HashRef with status and message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # @example my $result = $pc->coverage_termination; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | ▶ | sub coverage_termination { my ($self) = @_; return $self->_check_result('termination') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage_termination: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # The result of the B<examples> check, as C<coverage_arguments> returns it for its check. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # @returns HashRef with status and message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # @example my $result = $pc->coverage_examples; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | ▶ | sub coverage_examples { my ($self) = @_; return $self->_check_result('examples') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage_examples: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 11 | ▶ | sub _check_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_result: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 11 | my ( $self, $check ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 11 | ▶ | my $report = $self->coverage_report or return { status => 0, message => ( $self->{why_unrated} // 'no POD' ) . "\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{"why_unrated"} // "no POD"
MC/DC0%0/1
$self->{"why_unrated"} // "no POD"
$self->{"why_unrated"}
Truth table50%1/2
A
A= $self->{"why_unrated"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 10 | my @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 10 | foreach my $name ( sort keys %$report ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 244 | push @failures, @{ $report->{$name}{failures}{$check} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 10 | ▶ | return { status => @failures ? 0 : 1, message => @failures ? join( q{}, map { "$_\n" } @failures ) : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # The names that a POD argument can match: the parameters, the keys of named arguments, and the declared parameters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 188 | ▶ | sub _accepted_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accepted_names: called CC=7 SCAR=22.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 188 | my ($rec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 188 | my @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 188 | foreach my $param ( @{ $rec->{params} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 314 | ▶ | push @names, $param->{name} if defined $param->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 188 | push @names, _named_keys($rec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 188 | ▶ | foreach my $param ( @{ $rec->{declared}{params} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$rec->{'declared'}{'params'} || []
MC/DC0%0/1
$rec->{'declared'}{'params'} || []
$rec->{'declared'}{'params'}
Truth table50%1/2
A
A= $rec->{'declared'}{'params'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | push @names, $param->{name} if defined $param->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | push @names, $param->{named} if defined $param->{named}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 188 | return _bare_names(@names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # The keys of the hashes of named arguments of a sub. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 225 | ▶ | sub _named_keys { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_named_keys: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 225 | my ($rec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 225 | my @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 225 | foreach my $param ( @{ $rec->{params} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 392 | ▶ | push @keys, @{ $param->{keys} || [] } if !_is_invocant( $rec, $param ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$param->{'keys'} || []
MC/DC100%1/1
$param->{'keys'} || []
$param->{'keys'}
Truth table100%2/2
A
A= $param->{'keys'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 225 | return @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # The arguments in ARGS, the list of the POD, that stand at the position of a parameter with no name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # such as a placeholder in a signature, which the POD may call anything, or at or after a slurpy one with no name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 225 | ▶ | sub _at_unnamed_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_at_unnamed_params: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 225 | my ( $rec, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 225 | my ( @params, %invocants ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 225 | foreach my $param ( sort { $a->{index} <=> $b->{index} } @{ $rec->{params} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 392 | ▶ | if ( _is_invocant( $rec, $param ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 92 | ▶ | $invocants{ Pod::Coverage::More::Documentation->bare_name( $param->{name} ) } = 1 if defined $param->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 92 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 300 | push @params, $param; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 225 | my @listed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 225 | foreach my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 331 | ▶ | push @listed, $arg if !$invocants{ Pod::Coverage::More::Documentation->bare_name($arg) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # A slurpy parameter takes every argument from its position on, so an argument beyond it stands at it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 225 | my @unnamed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 225 | foreach my $at ( 0 .. $#listed ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 331 | ▶ | my $param = $at <= $#params ? $params[$at] : $params[-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 331 | ▶ | next if !$param || ( $at > $#params && !$param->{slurpy} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $param or $at > $#params and not $param->{"slurpy"}
$at > $#params and not $param->{"slurpy"}
MC/DC100%3/3
not $param or $at > $#params and not $param->{"slurpy"}
not $param
$at > $#params
not $param->{"slurpy"}
Truth table100%4/4
not(A) or B and not(C)
A= not $paramB= $at > $#paramsC= not $param->{"slurpy"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 310 | ▶ | push @unnamed, $listed[$at] if !defined $param->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 225 | return @unnamed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # The arguments in ARGS, the list of the POD, that the sub takes, by name or at the position of a parameter with no name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | sub _taken { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_taken: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | my ( $rec, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | my %taken = map { $_ => 1 } _accepted_names($rec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my %unnamed = map { $_ => 1 } _at_unnamed_params( $rec, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | my @taken; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | foreach my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | ▶ | push @taken, $arg if $unnamed{$arg} || $taken{ Pod::Coverage::More::Documentation->bare_name($arg) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$unnamed{$arg} or $taken{"Pod::Coverage::More::Documentation"->bare_name($arg)}
MC/DC50%1/2
$unnamed{$arg} or $taken{"Pod::Coverage::More::Documentation"->bare_name($arg)}
$unnamed{$arg}
$taken{"Pod::Coverage::More::Documentation"->bare_name($arg)}
Truth table66%2/3
A or B
A= $unnamed{$arg}B= $taken{"Pod::Coverage::More::Documentation"->bare_name($arg)}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | return @taken; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # Whether PARAM is the object or class that a method is called on, whose keys are its fields and not named arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 800 | ▶ | sub _is_invocant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_invocant: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 800 | my ( $rec, $param ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 800 | ▶ | return 1 if $param->{source} eq 'invocant'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 800 | ▶ | my $name = $param->{name} // return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$param->{"name"} // (return 0)
MC/DC100%1/1
$param->{"name"} // (return 0)
$param->{"name"}
Truth table100%2/2
A
A= $param->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 720 | ▶ | return 1 if $name =~ m/\A\$(?:self|class|proto)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 520 | ▶ | return @{ $rec->{usage}{$name}{methods} || [] } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$rec->{'usage'}{$name}{'methods'} || []
MC/DC0%0/1
$rec->{'usage'}{$name}{'methods'} || []
$rec->{'usage'}{$name}{'methods'}
Truth table50%1/2
A
A= $rec->{'usage'}{$name}{'methods'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # Whether the code of a sub shows nothing of its arguments: an XS sub or a constant, or a stub with no signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # that reads nothing of @_, as a default that subclasses override. Its POD names its arguments on the author's word. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 510 | ▶ | sub _is_stub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_stub: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 510 | my ($rec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 510 | ▶ | return 1 if $rec->{kind} ne 'perl'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 510 | ▶ | return 0 if $rec->{signature} || $rec->{reads_args} || @{ $rec->{params} } || @{ $rec->{declared}{params} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition72%8/11
$rec->{"signature"} or $rec->{"reads_args"} or @{$rec->{"params"};} or @{$rec->{"declared"}{"params"} or [];}
$rec->{"signature"} or $rec->{"reads_args"} or @{$rec->{"params"};}
$rec->{"signature"} or $rec->{"reads_args"}
$rec->{'declared'}{'params'} || []
MC/DC50%2/4
$rec->{"signature"} or $rec->{"reads_args"} or @{$rec->{"params"};} or @{$rec->{"declared"}{"params"} or [];}
$rec->{"signature"}
$rec->{"reads_args"}
@{$rec->{"params"};}
@{$rec->{"declared"}{"params"} or [];}
MC/DC0%0/1
$rec->{'declared'}{'params'} || []
$rec->{'declared'}{'params'}
Truth table60%3/5
A or B or C or D
A= $rec->{"signature"}B= $rec->{"reads_args"}C= @{$rec->{"params"};}D= @{$rec->{"declared"}{"params"} or [];}
Truth table50%1/2
A
A= $rec->{'declared'}{'params'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 110 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # Whether a sub is an abstract method: it takes at most its invocant and never returns, as a default that dies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # for a subclass that does not override it. Its POD documents the interface of the overrides. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 400 | ▶ | sub _is_abstract { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_abstract: called CC=9 SCAR=24.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 400 | my ($rec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 400 | ▶ | return 0 if !$rec->{never_returns} || @{ $rec->{declared}{params} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
not $rec->{"never_returns"} or @{$rec->{"declared"}{"params"} or [];}
$rec->{'declared'}{'params'} || []
MC/DC50%1/2
not $rec->{"never_returns"} or @{$rec->{"declared"}{"params"} or [];}
not $rec->{"never_returns"}
@{$rec->{"declared"}{"params"} or [];}
MC/DC0%0/1
$rec->{'declared'}{'params'} || []
$rec->{'declared'}{'params'}
Truth table66%2/3
not(A) or B
A= not $rec->{"never_returns"}B= @{$rec->{"declared"}{"params"} or [];}
Truth table50%1/2
A
A= $rec->{'declared'}{'params'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 24 | my @params = @{ $rec->{params} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 24 | ▶ | return 0 if @params > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 24 | ▶ | return 1 if !@params; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 24 | ▶ | return $params[0]{index} == 0 && ( !defined $params[0]{name} || _is_invocant( $rec, $params[0] ) ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$params[0]{"index"} == 0 and !defined($params[0]{"name"}) || _is_invocant($rec, $params[0])
not defined $params[0]{"name"} or _is_invocant($rec, $params[0])
MC/DC0%0/3
$params[0]{"index"} == 0 and !defined($params[0]{"name"}) || _is_invocant($rec, $params[0])
$params[0]{"index"} == 0
not defined $params[0]{"name"}
_is_invocant($rec, $params[0])
Truth table50%2/4
A and not(B) or C
A= $params[0]{"index"} == 0B= not defined $params[0]{"name"}C= _is_invocant($rec, $params[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 255 | ▶ | sub _check_arguments { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_arguments: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 255 | my ( $self, $name, $section, $rec, $inherited ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 255 | ▶ | return if _is_stub($rec) || _is_abstract($rec) || $inherited; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
_is_stub($rec) or _is_abstract($rec) or $inherited
_is_stub($rec) or _is_abstract($rec)
MC/DC100%3/3
_is_stub($rec) or _is_abstract($rec) or $inherited
_is_stub($rec)
_is_abstract($rec)
$inherited
Truth table100%4/4
A or B or C
A= _is_stub($rec)B= _is_abstract($rec)C= $inherited
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 186 | ▶ | my $args = $section->{args}{$name} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 186 | my @accepted = _accepted_names($rec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 186 | my %unnamed = map { $_ => 1 } _at_unnamed_params( $rec, @$args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 186 | my @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 186 | foreach my $arg ( _bare_names( grep { !$unnamed{$_} } @$args ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 231 | ▶ | push @failures, "Var Mismatch for function $name: $arg not in @accepted" if none { $_ eq $arg } @accepted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 186 | return @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 13 | our %SIGIL_TYPES = ( '$' => 'scalar', '@' => 'array', '%' => 'hash' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 255 | ▶ | sub _check_argument_types { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_argument_types: called CC=16 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 255 | my ( $self, $name, $section, $rec, $inherited ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 255 | ▶ | return if _is_stub($rec) || _is_abstract($rec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
_is_stub($rec) or _is_abstract($rec)
MC/DC100%2/2
_is_stub($rec) or _is_abstract($rec)
_is_stub($rec)
_is_abstract($rec)
Truth table100%3/3
A or B
A= _is_stub($rec)B= _is_abstract($rec)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 188 | ▶ | my $args = $section->{args}{$name} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 188 | ▶ | $args = [ _taken( $rec, @$args ) ] if $inherited; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 188 | my @params = grep { defined } map { $_->{name} } @{ $rec->{params} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # Strategy 1: the POD wrote each argument with its sigil, so it must match the sigil of the parameter, in any case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # A key of the named arguments, as the heading writes it in key => value, has no sigil to match. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 188 | ▶ | if ( any { m/\A[\$*\\@%&|]/ } @$args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 37 | my %unnamed = map { $_ => 1 } _at_unnamed_params( $rec, @$args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 37 | my %keys = map { $_ => 1 } _named_keys($rec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 37 | my @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 37 | ▶ | foreach my $arg ( map { s/\A\\[\$*@%&|]/\$/r } grep { !$unnamed{$_} && !$keys{$_} } @$args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$unnamed{$_} || $keys{$_}
MC/DC100%2/2
$unnamed{$_} || $keys{$_}
$unnamed{$_}
$keys{$_}
Truth table100%3/3
A || B
A= $unnamed{$_}B= $keys{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 46 | ▶ | push @failures, "Var Type Mismatch for function $name: $arg not in @params" if none { lc($_) eq lc($arg) } @params; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 37 | return @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # Strategy 2: the type of each argument is in an =item of its section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 151 | ▶ | my $types = $section->{types}{$name} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$section->{'types'}{$name} || {}
MC/DC100%1/1
$section->{'types'}{$name} || {}
$section->{'types'}{$name}
Truth table100%2/2
A
A= $section->{'types'}{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 151 | my @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 151 | foreach my $arg (@$args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 222 | ▶ | push @failures, "Var $arg not documented whatsoever for $name!" if !$types->{ Pod::Coverage::More::Documentation->bare_name($arg) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 151 | foreach my $param ( @{ $rec->{params} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 236 | ▶ | next if !defined $param->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 204 | ▶ | my ( $sigil, $arg_name ) = $param->{name} =~ m/\A(.)(.+)\z/ or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 204 | ▶ | my $documented = $types->{ lc $arg_name } or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 130 | push @failures, _type_failures( $name, $arg_name, $SIGIL_TYPES{$sigil}, $documented, $param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 151 | return @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # The failures of the documented type of one parameter: against its sigil, its declared type, and its uses. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 130 | ▶ | sub _type_failures { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_type_failures: called CC=18 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 130 | my ( $name, $arg_name, $sigil_type, $documented, $param ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 130 | my $word = $documented->{word}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 130 | ▶ | return "No type declared for arg $arg_name of $name" if $word eq q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 124 | ▶ | return if $word eq 'mixed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # An item with the sigil of a list documents the type of each element, which the code shows nothing of. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 123 | ▶ | if ( my $elements = $documented->{sigil} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 9 | ▶ | return if defined $sigil_type && $SIGIL_TYPES{$elements} eq $sigil_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $sigil_type and $Pod::Coverage::More::SIGIL_TYPES{$elements} eq $sigil_type
MC/DC50%1/2
defined $sigil_type and $Pod::Coverage::More::SIGIL_TYPES{$elements} eq $sigil_type
defined $sigil_type
$Pod::Coverage::More::SIGIL_TYPES{$elements} eq $sigil_type
Truth table66%2/3
A and B
A= defined $sigil_typeB= $Pod::Coverage::More::SIGIL_TYPES{$elements} eq $sigil_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | ▶ | return "Type mismatch for arg $arg_name of $name: documented the elements of $elements$arg_name, expected " . ( $sigil_type // 'a parameter with a sigil' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$sigil_type // "a parameter with a sigil"
MC/DC0%0/1
$sigil_type // "a parameter with a sigil"
$sigil_type
Truth table50%1/2
A
A= $sigil_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # A word for a container names the kind of the parameter itself, and only a container parameter is one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 114 | ▶ | if ( defined $sigil_type && $word ne $sigil_type && ( $word eq 'array' || $word eq 'hash' || $sigil_type ne 'scalar' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%9/12
defined $sigil_type and $word ne $sigil_type and $word eq "array" || $word eq "hash" || $sigil_type ne "scalar"
defined $sigil_type and $word ne $sigil_type
$word eq "array" or $word eq "hash" or $sigil_type ne "scalar"
$word eq "array" or $word eq "hash"
MC/DC40%2/5
defined $sigil_type and $word ne $sigil_type and $word eq "array" || $word eq "hash" || $sigil_type ne "scalar"
defined $sigil_type
$word ne $sigil_type
$word eq "array"
$word eq "hash"
$sigil_type ne "scalar"
Truth table50%3/6
A and B and C or D or E
A= defined $sigil_typeB= $word ne $sigil_typeC= $word eq "array"D= $word eq "hash"E= $sigil_type ne "scalar"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | return "Type mismatch for arg $arg_name of $name: got $word, expected $sigil_type"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 112 | ▶ | my $type = $documented->{type} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 112 | ▶ | if ( my $declared = $param->{declared} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 12 | ▶ | return if $type->equals($declared) || $type->is_subtype_of($declared); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type->equals($declared) or $type->is_subtype_of($declared)
MC/DC100%2/2
$type->equals($declared) or $type->is_subtype_of($declared)
$type->equals($declared)
$type->is_subtype_of($declared)
Truth table100%3/3
A or B
A= $type->equals($declared)B= $type->is_subtype_of($declared)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 4 | return "Type mismatch for arg $arg_name of $name: documented " . $type->display_name . ", but $param->{declared_by} declares " . $declared->display_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 100 | ▶ | if ( my $inferred = $param->{inferred} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 42 | ▶ | return "Type mismatch for arg $arg_name of $name: documented " . $type->display_name . ', but the code uses it as ' . $inferred->display_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | if _contradicts( $type, $inferred ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 96 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # The kinds of value that no type of another kind can be. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 13 | our @KINDS = ( HashRef, ArrayRef, CodeRef, ScalarRef, GlobRef, Str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 116 | ▶ | sub _kinds_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_kinds_of: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 116 | my ($type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | my @members = $type->can('type_constraints') ? @{ $type->type_constraints } : ($type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 116 | my %kinds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 116 | foreach my $member (@members) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 116 | foreach my $kind (@KINDS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 696 | ▶ | $kinds{ $kind->name } = 1 if $member->is_a_type_of($kind); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 116 | return \%kinds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # Whether a documented type and a type that the code implies are of different kinds, as a hash reference and an array reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 58 | ▶ | sub _contradicts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_contradicts: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 58 | my ( $documented, $inferred ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 58 | my $documented_kinds = _kinds_of($documented); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 58 | my $inferred_kinds = _kinds_of($inferred); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 58 | ▶ | return 0 if !%$documented_kinds || !%$inferred_kinds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
%$documented_kinds and %$inferred_kinds
MC/DC50%1/2
%$documented_kinds and %$inferred_kinds
%$documented_kinds
%$inferred_kinds
Truth table66%2/3
A and B
A= %$documented_kindsB= %$inferred_kinds
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 48 | ▶ | return ( none { $inferred_kinds->{$_} } keys %$documented_kinds ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 255 | ▶ | sub _check_returns { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_returns: called CC=20 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 255 | my ( $self, $name, $section, $rec ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 255 | my @returned = grep { $_->{type} ne 'empty' } @{ $rec->{returns} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 255 | ▶ | my @declared = @{ $rec->{declared}{returns} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$rec->{'declared'}{'returns'} || []
MC/DC0%0/1
$rec->{'declared'}{'returns'} || []
$rec->{'declared'}{'returns'}
Truth table50%1/2
A
A= $rec->{'declared'}{'returns'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 255 | ▶ | return if !@returned && !@declared; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@returned or @declared
MC/DC50%1/2
@returned or @declared
@returned
@declared
Truth table66%2/3
A or B
A= @returnedB= @declared
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 150 | my @statements = @{ $section->{returns} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 150 | ▶ | return "No return value documented for $name" if !@statements; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 129 | my @documented = map { @{ $_->{types} } } @statements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 129 | ▶ | if ( !@documented ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 32 | ▶ | return if !_all_nothing(@statements); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # What a call returns is not in this code, and may be nothing, so only another value contradicts the POD. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 16 | ▶ | return if !@declared && all { $_->{type} eq 'call' || $_->{type} eq 'method' } @returned; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Branch: 2 branches
Condition66%2/3
not @declared and &all(sub {
$_->{"type"} eq "call" or $_->{"type"} eq "method";
}
, @returned)
MC/DC50%1/2
not @declared and &all(sub {
$_->{"type"} eq "call" or $_->{"type"} eq "method";
}
, @returned)
not @declared
&all(sub {
$_->{"type"} eq "call" or $_->{"type"} eq "method";
}
, @returned)
Truth table66%2/3
not(A) and B
A= not @declaredB= &all(sub {
$_->{"type"} eq "call" or $_->{"type"} eq "method";
}
, @returned)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 8 | return "$name is documented to return nothing, but it returns a value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 97 | my @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | my %seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my @checked = ( ( map { [ $_->{constraint}, "line $_->{line}", $_->{weak}, $_ ] } grep { $_->{constraint} } @returned ), ( map { [ $_, 'declared', 0 ] } @declared ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 97 | foreach my $returned (@checked) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 107 | my ( $type, $where, $weak, $evidence ) = @$returned; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 107 | ▶ | next if _covered( $type, \@documented ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # A literal is one value, which can satisfy a type that its own type is no subtype of, as 1 satisfies Bool. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 56 | ▶ | next if $evidence && exists $evidence->{value} && _value_covered( $evidence->{value}, \@documented ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$evidence and exists $evidence->{"value"} and _value_covered($evidence->{"value"}, \@documented)
$evidence and exists $evidence->{"value"}
MC/DC66%2/3
$evidence and exists $evidence->{"value"} and _value_covered($evidence->{"value"}, \@documented)
$evidence
exists $evidence->{"value"}
_value_covered($evidence->{"value"}, \@documented)
Truth table75%3/4
A and B and C
A= $evidenceB= exists $evidence->{"value"}C= _value_covered($evidence->{"value"}, \@documented)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # The code shows the kind of what it returns, as [ ... ] is an ArrayRef, but not what is inside it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 32 | ▶ | next if $evidence && !exists $evidence->{value} && _parameterizes( $type, \@documented ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$evidence and not exists $evidence->{"value"} and _parameterizes($type, \@documented)
$evidence and not exists $evidence->{"value"}
MC/DC66%2/3
$evidence and not exists $evidence->{"value"} and _parameterizes($type, \@documented)
$evidence
not exists $evidence->{"value"}
_parameterizes($type, \@documented)
Truth table75%3/4
A and not(B) and C
A= $evidenceB= not exists $evidence->{"value"}C= _parameterizes($type, \@documented)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # The type of the result of an operator is weak: overloading can change it, so it fails only when it contradicts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 28 | ▶ | next if $weak && any { !_contradicts( $_, $type ) } @documented; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
$weak and &any(sub {
not _contradicts($_, $type);
}
, @documented)
MC/DC100%2/2
$weak and &any(sub {
not _contradicts($_, $type);
}
, @documented)
$weak
&any(sub {
not _contradicts($_, $type);
}
, @documented)
Truth table100%3/3
A and B
A= $weakB= &any(sub {
not _contradicts($_, $type);
}
, @documented)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 16 | ▶ | next if $seen{ $type->display_name }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 16 | push @failures, "Return type mismatch for $name: returns " . $type->display_name . " ($where), documented as " . join( ' or ', _names_of( \@documented ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 97 | return @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # Whether the statements of the return value only say that it returns nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 32 | ▶ | sub _all_nothing { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_all_nothing: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 32 | my (@statements) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 32 | ▶ | return ( any { $_->{nothing} } @statements ) && ( none { @{ $_->{types} } } @statements ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition66%2/3
&any(sub {
$_->{'nothing'};
}
, @statements) && &none(sub {
@{$_->{'types'};};
}
, @statements)
MC/DC50%1/2
&any(sub {
$_->{'nothing'};
}
, @statements) && &none(sub {
@{$_->{'types'};};
}
, @statements)
&any(sub {
$_->{'nothing'};
}
, @statements)
&none(sub {
@{$_->{'types'};};
}
, @statements)
Truth table66%2/3
A && B
A= &any(sub {
$_->{'nothing'};
}
, @statements)B= &none(sub {
@{$_->{'types'};};
}
, @statements)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 28 | ▶ | sub _value_covered { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value_covered: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 28 | my ( $value, $documented ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 28 | foreach my $candidate (@$documented) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 28 | ▶ | return 1 if $candidate->check($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 4 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 107 | ▶ | sub _covered { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_covered: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 107 | my ( $type, $documented ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 107 | foreach my $candidate (@$documented) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 112 | ▶ | return 1 if $candidate->equals(Any) || $type->equals($candidate) || $type->is_subtype_of($candidate); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$candidate->equals(&Any()) or $type->equals($candidate) or $type->is_subtype_of($candidate)
$candidate->equals(&Any()) or $type->equals($candidate)
MC/DC66%2/3
$candidate->equals(&Any()) or $type->equals($candidate) or $type->is_subtype_of($candidate)
$candidate->equals(&Any())
$type->equals($candidate)
$type->is_subtype_of($candidate)
Truth table75%3/4
A or B or C
A= $candidate->equals(&Any())B= $type->equals($candidate)C= $type->is_subtype_of($candidate)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 56 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # Whether a documented type is a parameterization of TYPE, as ArrayRef[HashRef] is of ArrayRef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 28 | ▶ | sub _parameterizes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parameterizes: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 28 | my ( $type, $documented ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 28 | foreach my $candidate (@$documented) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 28 | ▶ | return 1 if $candidate->is_parameterized && $candidate->parameterized_from->equals($type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$candidate->is_parameterized and $candidate->parameterized_from->equals($type)
MC/DC100%2/2
$candidate->is_parameterized and $candidate->parameterized_from->equals($type)
$candidate->is_parameterized
$candidate->parameterized_from->equals($type)
Truth table100%3/3
A and B
A= $candidate->is_parameterizedB= $candidate->parameterized_from->equals($type)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 24 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # The names of NAMES without sigils, in lower case, as the POD and the code are compared. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 374 | ▶ | sub _bare_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bare_names: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 374 | my (@names) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 374 | my @bare; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 374 | foreach my $name (@names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 526 | push @bare, Pod::Coverage::More::Documentation->bare_name($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 374 | return @bare; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # The display names of the constraints in the ARRAYREF TYPES. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 16 | ▶ | sub _names_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_names_of: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 16 | my ($types) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 16 | my @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 16 | foreach my $type (@$types) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 16 | push @names, $type->display_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 16 | return @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 255 | ▶ | sub _check_termination { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_termination: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 255 | my ( $self, $name, $section, $rec ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 255 | my @uncaught = grep { !$_->{caught} } @{ $rec->{dies} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 255 | ▶ | return if !@uncaught || @{ $section->{terminations} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not @uncaught or @{$section->{"terminations"};}
MC/DC100%2/2
not @uncaught or @{$section->{"terminations"};}
not @uncaught
@{$section->{"terminations"};}
Truth table100%3/3
not(A) or B
A= not @uncaughtB= @{$section->{"terminations"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 4 | return "$name can terminate ($uncaught[0]{via} at line $uncaught[0]{line}), but its POD does not say so"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 255 | ▶ | sub _check_examples { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_examples: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 255 | my ( $self, $name, $section ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 255 | my @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 255 | ▶ | if ( $section->{assigns} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 8 | my $args = $section->{args}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 8 | ▶ | my $head = $name . ( $args ? '(' . join( ', ', @$args ) . ')' : q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 8 | push @failures, "The heading of $name is an example: move `$section->{heading}` into a verbatim block, and head the section $head"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 255 | ▶ | push @failures, "No example of $name in its POD" if none { m/\b\Q$name\E\s*\(|->\s*\Q$name\E\b/ } @{ $section->{verbatim} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 255 | return @failures; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 29 | ▶ | sub _trace_dump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trace_dump: called CC=2 SCAR=10.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 29 | my ($data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 29 | ▶ | return if !$TRACE_ALL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | print Data::Dumper::Dumper($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 366 | ▶ | sub _documentation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_documentation: called CC=8 SCAR=21.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 366 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 366 | ▶ | return $self->{documentation} if $self->{documentation}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 31 | my $package = $self->{package}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 31 | ▶ | print "getting pod location for '$package'\n" if $TRACE_ALL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 31 | ▶ | $self->{pod_from} ||= pod_where( { -inc => 1 }, $package ) // $INC{ module_notional_filename($package) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$self->{"pod_from"} ||= pod_where({"-inc", 1}, $package) // $INC{&module_notional_filename($package)}
pod_where({"-inc", 1}, $package) // $INC{&module_notional_filename($package)}
MC/DC0%0/3
$self->{"pod_from"} ||= pod_where({"-inc", 1}, $package) // $INC{&module_notional_filename($package)}
$self->{"pod_from"}
pod_where({"-inc", 1}, $package)
$INC{&module_notional_filename($package)}
Truth table0%0/4
A ||= B // C
A= $self->{"pod_from"}B= pod_where({"-inc", 1}, $package)C= $INC{&module_notional_filename($package)}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 31 | my $pod_from = $self->{pod_from}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 31 | ▶ | unless ($pod_from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 2 | $self->{why_unrated} = "couldn't find pod"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # The headings name subs only once the package is loaded, so load it before reading its symbols. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 29 | ▶ | if ( !eval { require_module($package); 1 } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $self->{why_unrated} = "requiring '$package' failed"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 29 | ▶ | print "parsing '$pod_from'\n" if $TRACE_ALL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 29 | my @subs = Package::Stash->new($package)->list_all_symbols('CODE'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 29 | return $self->{documentation} = Pod::Coverage::More::Documentation->new( subs => \@subs )->parse_file($pod_from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # The documentation of the package, then of each of its parent classes, as Pod::Coverage::CountParents reads them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 273 | ▶ | sub _documentations { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_documentations: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 273 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 273 | ▶ | return @{ $self->{documentations} } if $self->{documentations}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 24 | ▶ | my $own = $self->_documentation or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 24 | my @documentations = ($own); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 24 | foreach my $parent ( @{ mro::get_linear_isa( $self->{package} ) } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 28 | ▶ | next if $parent eq $self->{package}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 4 | ▶ | my $file = pod_where( { -inc => 1 }, $parent ) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 4 | my @subs = Package::Stash->new($parent)->list_all_symbols('CODE'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 4 | push @documentations, Pod::Coverage::More::Documentation->new( subs => \@subs )->parse_file($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 24 | $self->{documentations} = \@documentations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 24 | return @documentations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # The section that documents the sub C<name>, as C<section_for> of L<Pod::Coverage::More::Documentation> returns it: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # the section in the POD of the package, or else in that of the nearest parent class that documents it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # Nothing when no POD documents it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # @param name Str the name of the sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # @returns HashRef the section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # @example my $section = $pc->section_for('coverage'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 259 | ▶ | sub section_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
section_for: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 259 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 259 | foreach my $documentation ( $self->_documentations ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 264 | my $section = $documentation->section_for($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 264 | ▶ | return $section if $section; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # The section that documents the sub C<name> in the POD of the package itself, not of a parent class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # Nothing when the POD of the package does not document it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # @param name Str the name of the sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # @returns HashRef the section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # @example my $section = $pc->own_section_for('coverage'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 52 | ▶ | sub own_section_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
own_section_for: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 52 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 52 | ▶ | my $documentation = $self->_documentation or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 52 | return $documentation->section_for($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | # The analysis of every sub of the package, as C<analyze_package> of L<Pod::Coverage::More::Analyzer> returns it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # The package is analyzed once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # @returns HashRef from the name of each sub to the record of its analysis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # @example my $records = $pc->analysis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 28 | ▶ | sub analysis { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analysis: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 28 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 28 | ▶ | return $self->{analysis} //= Pod::Coverage::More::Analyzer->new->analyze_package( $self->{package} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"analysis"} //= "Pod::Coverage::More::Analyzer"->new->analyze_package($self->{"package"})
MC/DC0%0/2
$self->{"analysis"} //= "Pod::Coverage::More::Analyzer"->new->analyze_package($self->{"package"})
$self->{"analysis"}
"Pod::Coverage::More::Analyzer"->new->analyze_package($self->{"package"})
Truth table66%2/3
A //= B
A= $self->{"analysis"}B= "Pod::Coverage::More::Analyzer"->new->analyze_package($self->{"package"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # The public subs of the package, as L<Pod::Coverage> counts them: not private, not imported, and not trusted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # @returns the names of the subs, as a list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # @example my @names = $pc->public_subs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 11 | ▶ | sub public_subs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
public_subs: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 11 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 11 | my @public; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 11 | foreach my $name ( $self->_get_syms( $self->{package} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 67 | ▶ | push @public, $name if !$self->_trustme_check($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 11 | return @public; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||