blib/lib/Test/Pod/LinkCheck/Lite.pm

filter: Statementstmt 94.6% 568 / 600 Branchbran 71.2% 181 / 254 Conditioncond 58.3% 42 / 72 MC/DCmcdc 27.9% 12 / 43 Subroutinesub 95.6% 111 / 116 Podpod 100% 16 / 16 totaltotal 84.4% 930 / 1101 CC 165 SCAR 18.2
CC
165
Cov
85%
__ANON__
23.8
_handle_man
17.1
_handle_url
16.7
CRAP 6.2
↑ Summary
1 package Test::Pod::LinkCheck::Lite;
2  
3 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use strict; # Core since 5.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings; # Core since 5.6.0
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use utf8; # Core since 5.6.0
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use B::Keywords (); # Not core
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Exporter (); # Core since 5.0
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use File::Find (); # Core since 5.0
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use File::Spec; # Core since 5.4.5
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use HTTP::Tiny; # Core since 5.13.9
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use IPC::Cmd (); # Core since 5.9.5
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Module::Load::Conditional (); # Core since 5.9.5
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Pod::Perldoc (); # Core since 5.8.1
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Pod::Simple (); # Core since 5.9.3
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Pod::Simple::LinkSection; # Core since 5.9.3 (part of Pod::Simple)
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use Storable (); # Core since 5.7.3
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Test::Builder (); # Core since 5.6.2
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 2 our $VERSION = '0.014';
24  
25 2 our @ISA = qw{ Exporter };
26  
27 2 our @EXPORT_OK = qw{
28 ALLOW_REDIRECT_TO_INDEX
29 MAYBE_IGNORE_GITHUB
30 };
31  
32 our %EXPORT_TAGS = (
33 2 const => [ grep { m/ \A [[:upper:]_]+ \z /smx } @EXPORT_OK ],
34 );
35  
36 2 ▶use constant ON_DARWIN => 'darwin' eq $^O;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 ▶use constant ON_VMS => 'VMS' eq $^O;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 2 our $DIRECTORY_LEADER; # FOR TESTING ONLY -- may be retracted without notice
40 2 ▶defined $DIRECTORY_LEADER
Branch: 1 branch
BranchTrueFalseTotal
defined $Test::Pod::LinkCheck::Lite::DIRECTORY_LEADER or $Test::Pod::LinkCheck::Lite::DIRECTORY_LEADER = "." 1 1 2
41 or $DIRECTORY_LEADER = ON_VMS ? '_' : '.';
42  
43 2 my $DOT_CPAN = "${DIRECTORY_LEADER}cpan";
44  
45 2 ▶use constant ARRAY_REF => ref [];
Subroutine BEGIN: called CC=1 SCAR=0.0
46 2 ▶use constant CODE_REF => ref sub {};
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: not called CC=1 SCAR=0.0
47 2 ▶use constant HASH_REF => ref {};
Subroutine BEGIN: called CC=1 SCAR=0.0
48 2 ▶use constant NON_REF => ref 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 2 ▶use constant REGEXP_REF => ref qr<x>smx;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 2 ▶use constant SCALAR_REF => ref \0;
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 # Pod::Simple versions earlier than this were too restrictive in
53 # recognizing 'man' links, so some valid ones ended up classified as
54 # 'pod'. We conditionalize fix-up code on this constant so that, if the
55 # fix-up is not needed, the optimizer ditches it.
56 2 ▶use constant NEED_MAN_FIX => Pod::Simple->VERSION lt '3.24';
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 2 ▶use constant ALLOW_REDIRECT_TO_INDEX => sub {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=3 SCAR=11.3
59 4 my ( undef, $resp, $url ) = @_;
60 # Does not apply to non-hierarchical URLs. This list is derived from
61 # the URI distribution, and represents those classes that do not
62 # inherit from URI::_generic.
63 $url =~ m/ \A (?: data | mailto | urn ) : /smxi
64 4 ▶ and return $resp->{url} ne $url;
Branch: 1 branch
BranchTrueFalseTotal
$url =~ / \A (?: data | mailto | urn ) : /imsx and return $resp->{"url"} ne $url 0 4 4
65 $url =~ m| / \z |smx
66 4 ▶ or return $resp->{url} ne $url;
Branch: 1 branch
BranchTrueFalseTotal
$url =~ m[ / \z ]msx or return $resp->{"url"} ne $url 4 0 4
67 4 ( my $resp_url = $resp->{url} ) =~ s| (?<= / ) [^/]* \z ||smx;
68 4 return $resp_url ne $url;
69 2 };
70  
71 2 ▶use constant MAYBE_IGNORE_GITHUB => sub {
Subroutine BEGIN: called CC=1 SCAR=2.0
Subroutine __ANON__: called CC=7 SCAR=31.7
72 1 ▶ m< \A https://github\.com \b >smx
Branch: 1 branch
BranchTrueFalseTotal
m[ \A https://github\.com \b ]msx or return 1 0 1
73 or return;
74 1 ▶ my $git_dir = $ENV{GIT_DIR} || '.git';
Condition50%1/2
$ENV{'GIT_DIR'} || '.git'
l!l
10
MC/DC0%0/1
$ENV{'GIT_DIR'} || '.git'
$ENV{'GIT_DIR'}
Truth table50%1/2
A
A= $ENV{'GIT_DIR'}
Aresult
11
00
75 1 ▶ -d $git_dir
Branch: 1 branch
BranchTrueFalseTotal
-d $git_dir or return 1 0 1 1
76 or return 1;
77 0 ▶ open my $fh, '-|', qw{ git remote --verbose } ## no critic (RequireBriefOpen)
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", ("git", "remote", "--verbose") or return 1 0 0 0
78 or return 1;
79 0 local $_ = undef; # while (<>) ... does not localize $_.
80 0 ▶ while ( <$fh> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
81 0 ▶ m< \b https://github\.com \b >smx
Branch: 1 branch
BranchTrueFalseTotal
m[ \b https://github\.com \b ]msx and return 0 0 0
82 and return;
83 }
84 0 return 1;
85 2 };
86  
87 2 ▶use constant USER_AGENT_CLASS => 'HTTP::Tiny';
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 # NOTE that Test::Builder->new() gets us a singleton. For this reason I
90 # use $Test::Builder::Level (localized) to get tests reported relative
91 # to the correct file and line, rather than setting the 'level'
92 # attribute.
93 2 my $TEST = Test::Builder->new();
94  
95 27 ▶sub new {
Subroutine new: called CC=2 SCAR=7.6
Pod documented
96 27 my ( $class, %arg ) = @_;
97 27 ▶ my $self = bless {}, ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0270
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
98 27 return _init( $self, %arg );
99 }
100  
101 {
102 2 my %dflt;
103 2 local $_ = undef;
104 2 foreach ( keys %Test::Pod::LinkCheck::Lite:: ) {
105 164 ▶ m/ \A _default_ ( .+ ) /smx
Branch: 1 branch
BranchTrueFalseTotal
/ \A _default_ ( .+ ) /msx and my $code = __PACKAGE__->can($_) or next 24 140 164
Condition66%2/3
/ \A _default_ ( .+ ) /msx and my $code = __PACKAGE__->can($_)
!ll&&!rl&&r
140024
MC/DC50%1/2
/ \A _default_ ( .+ ) /msx and my $code = __PACKAGE__->can($_)
/ \A _default_ ( .+ ) /msx my $code = __PACKAGE__->can($_)
Truth table66%2/3
A and B
A= / \A _default_ ( .+ ) /msxB= my $code = __PACKAGE__->can($_)
ABresult
0X0
100
111
106 and my $code = __PACKAGE__->can( $_ )
107 or next;
108 24 $dflt{$1} = $code;
109 }
110  
111 27 ▶ sub _init {
Subroutine _init: called CC=6 SCAR=19.2
112 27 my ( $self, %arg ) = @_;
113 27 foreach my $key ( keys %dflt ) {
114 exists $arg{$key}
115 324 ▶ or $arg{$key} = $dflt{$key}->();
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{$key} or $arg{$key} = $dflt{$key}->() 22 302 324
116 }
117 27 foreach my $name ( keys %arg ) {
118 324 ▶ if ( my $code = $self->can( "_init_$name" ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $code = $self->can("_init_$name")) { } 324 0 324
elsif (defined $arg{$name}) { } 0 0 0
119 324 $code->( $self, $name, $arg{$name} );
120 } elsif ( defined $arg{$name} ) {
121 0 Carp::croak( "Unknown argument $name" );
122 }
123 }
124 27 return $self;
125 }
126 }
127  
128 2 ▶sub _default_allow_man_spaces {
Subroutine _default_allow_man_spaces: called CC=1 SCAR=0.0
129 27 return 0;
130 }
131  
132 26 ▶sub _default_check_external_sections {
Subroutine _default_check_external_sections: called CC=1 SCAR=0.0
133 26 return 1;
134 }
135  
136 27 ▶sub _default_cache_url_response {
Subroutine _default_cache_url_response: called CC=1 SCAR=0.0
137 27 return 1;
138 }
139  
140 25 ▶sub _default_check_url {
Subroutine _default_check_url: called CC=1 SCAR=0.0
141 25 return 1;
142 }
143  
144 19 ▶sub _default_ignore_url {
Subroutine _default_ignore_url: called CC=1 SCAR=0.0
145 19 return [];
146 }
147  
148 {
149 2 my $checked;
150 2 my $rslt;
151  
152 26 ▶ sub _default_man {
Subroutine _default_man: called CC=4 SCAR=15.0
153 26 ▶ unless ( $checked ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($checked) 2 24 26
154 2 $checked = 1;
155 # I had hoped that just feeling around for an executable
156 # 'man' would be adequate, but ReactOS (which identifies
157 # itself as MSWin32) has a MAN.EXE that will not work. If
158 # the user has customized the system he or she can always
159 # specify man => 1. The hash is in case I find other OSes
160 # that have this problem. OpenVMS might end up here, but I
161 # have no access to it to see.
162 2 ▶ if ( {
Branch: 1 branch
BranchTrueFalseTotal
if ({'DOS', 1, 'MSWin32', 1}->{$^O}) { } 0 2 2
163 DOS => 1,
164 MSWin32 => 1,
165 }->{$^O}
166 ) {
167 0 $rslt = 0;
168 0 $TEST->diag( "Can not check man pages by default under $^O" );
169 } else {
170 2 ▶ $rslt = IPC::Cmd::can_run( 'man' )
Branch: 1 branch
BranchTrueFalseTotal
$rslt = IPC::Cmd::can_run("man") or $TEST->diag("Can not check man pages; 'man' not installed") 2 0 2
171 or $TEST->diag(
172 q<Can not check man pages; 'man' not installed> );
173 }
174 }
175 26 return $rslt;
176 }
177 }
178  
179 2 ▶sub _default_add_dir {
Subroutine _default_add_dir: called CC=2 SCAR=7.1
180 26 ▶ -d 'blib/script'
Branch: 1 branch
BranchTrueFalseTotal
-d "blib/script" and return ["blib/script"] 0 26 26
181 and return [ 'blib/script' ];
182 26 return [];
183 }
184  
185 25 ▶sub _default_module_index {
Subroutine _default_module_index: called CC=4 SCAR=13.9
186 25 my @handlers;
187 25 foreach ( keys %Test::Pod::LinkCheck::Lite:: ) {
188 2170 ▶ m/ \A _get_module_index_ ( .+ ) /smx
Branch: 1 branch
BranchTrueFalseTotal
/ \A _get_module_index_ ( .+ ) /msx and __PACKAGE__->can($_) or next 50 2120 2170
Condition66%2/3
/ \A _get_module_index_ ( .+ ) /msx and __PACKAGE__->can($_)
!ll&&!rl&&r
2120050
MC/DC50%1/2
/ \A _get_module_index_ ( .+ ) /msx and __PACKAGE__->can($_)
/ \A _get_module_index_ ( .+ ) /msx __PACKAGE__->can($_)
Truth table66%2/3
A and B
A= / \A _get_module_index_ ( .+ ) /msxB= __PACKAGE__->can($_)
ABresult
0X0
100
111
189 and __PACKAGE__->can( $_ )
190 or next;
191 50 push @handlers, $1;
192 }
193 25 @handlers = sort @handlers;
194 25 return \@handlers;
195 }
196  
197 23 ▶sub _default_prohibit_redirect {
Subroutine _default_prohibit_redirect: called CC=1 SCAR=0.0
198 23 return 0;
199 }
200  
201 26 ▶sub _default_require_installed {
Subroutine _default_require_installed: called CC=1 SCAR=0.0
202 26 return 0;
203 }
204  
205 25 ▶sub _default_skip_server_errors {
Subroutine _default_skip_server_errors: called CC=1 SCAR=0.0
206 25 return 1;
207 }
208  
209 27 ▶sub _default_user_agent {
Subroutine _default_user_agent: called CC=1 SCAR=0.0
210 27 return USER_AGENT_CLASS;
211 }
212  
213 27 ▶sub _init_add_dir {
Subroutine _init_add_dir: called CC=2 SCAR=6.9
214 27 my ( $self, $name, $value ) = @_;
215 27 ▶ $self->{$name} = [ grep { -d } ref $value ? @{ $value } : $value ];
Branch: 1 branch
BranchTrueFalseTotal
ref $value ? : 26 1 27
216 27 return;
217 }
218  
219 27 ▶sub _init_allow_man_spaces {
Subroutine _init_allow_man_spaces: called CC=2 SCAR=7.1
220 27 my ( $self, $name, $value ) = @_;
221 27 ▶ $self->{$name} = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 27 27
222 27 return;
223 }
224  
225 27 ▶sub _init_cache_url_response {
Subroutine _init_cache_url_response: called CC=2 SCAR=7.1
226 27 my ( $self, $name, $value ) = @_;
227 27 ▶ $self->{$name} = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 27 0 27
228 27 return;
229 }
230  
231 27 ▶sub _init_check_external_sections {
Subroutine _init_check_external_sections: called CC=2 SCAR=6.9
232 27 my ( $self, $name, $value ) = @_;
233 27 ▶ $self->{$name} = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 26 1 27
234 27 return;
235 }
236  
237 27 ▶sub _init_check_url {
Subroutine _init_check_url: called CC=2 SCAR=6.9
238 27 my ( $self, $name, $value ) = @_;
239 27 ▶ $self->{$name} = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 26 1 27
240 27 return;
241 }
242  
243 {
244 2 my %handler;
245  
246 %handler = (
247 22 ▶ ARRAY_REF, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
248 22 my ( $spec, $value ) = @_;
249 22 $handler{ ref $_ }->( $spec, $_ ) for @{ $value };
250 22 return;
251 },
252 2 ▶ CODE_REF, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
253 2 my ( $spec, $value ) = @_;
254 2 push @{ $spec->{ CODE_REF() } }, $value;
255 2 return;
256 },
257 1 ▶ HASH_REF, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
258 1 my ( $spec, $value ) = @_;
259 1 $spec->{ NON_REF() }{$_} = 1 for
260 2 grep { $value->{$_} } keys %{ $value };
261 1 return;
262 },
263 5 ▶ NON_REF, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
264 5 my ( $spec, $value ) = @_;
265 5 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or return 3 2 5
266 or return;
267 3 $spec->{ NON_REF() }->{$value} = 1;
268 3 return;
269 },
270 3 ▶ REGEXP_REF, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
271 3 my ( $spec, $value ) = @_;
272 3 push @{ $spec->{ REGEXP_REF() } }, $value;
273 3 return;
274 },
275 0 ▶ SCALAR_REF, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
276 0 my ( $spec, $value ) = @_;
277 0 $spec->{ NON_REF() }->{$$value} = 1;
278 0 return;
279 },
280 2 );
281  
282 27 ▶ sub _init_ignore_url {
Subroutine _init_ignore_url: called CC=2 SCAR=7.0
283 27 my ( $self, $name, $value ) = @_;
284  
285 27 my $spec = $self->{$name} = {};
286 27 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $handler{ref $value}($spec, $value); 1 } } or Carp::confess("Invalid ignore_url value '${value}': must be scalar, regexp, array ref, hash ref, code ref, or undef") 27 0 27
287 27 $handler{ ref $value }->( $spec, $value );
288 27 1;
289 } or Carp::confess(
290 "Invalid ignore_url value '$value': must be scalar, regexp, array ref, hash ref, code ref, or undef" );
291 27 return;
292 }
293 }
294  
295 2 ▶sub _init_man {
Subroutine _init_man: called CC=2 SCAR=7.0
296 27 my ( $self, $name, $value ) = @_;
297 27 ▶ $self->{$name} = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 27 0 27
298 27 return;
299 }
300  
301 27 ▶sub _init_module_index {
Subroutine _init_module_index: called CC=4 SCAR=13.9
302 27 my ( $self, $name, $value ) = @_;
303 52 ▶ my @val = map { split qr{ \s* , \s* }smx } ARRAY_REF eq ref $value ?
Branch: 1 branch
BranchTrueFalseTotal
'ARRAY' eq ref $value ? : 25 2 27
304 27 @{ $value } : $value;
305 27 my @handlers;
306 27 foreach my $mi ( @val ) {
307 52 ▶ my $code = $self->can( "_get_module_index_$mi" )
Branch: 1 branch
BranchTrueFalseTotal
my $code = $self->can("_get_module_index_$mi") or Carp::croak("Invalid module_index value '${mi}'") 52 0 52
308 or Carp::croak( "Invalid module_index value '$mi'" );
309 52 push @handlers, $code;
310 }
311 27 $self->{$name} = \@val;
312 27 $self->{"_$name"} = \@handlers;
313 27 return;
314 }
315  
316 27 ▶sub _init_prohibit_redirect {
Subroutine _init_prohibit_redirect: called CC=3 SCAR=11.0
317 27 my ( $self, $name, $value ) = @_;
318 27 ▶ if ( CODE_REF eq ref $value ) {
Branch: 2 branches
BranchTrueFalseTotal
if ('CODE' eq ref $value) { } 2 25 27
elsif ($value) { } 1 24 25
319 2 $self->{$name} = $self->{"_$name"} = $value;
320 } elsif ( $value ) {
321 1 $self->{$name} = 1;
322 2 ▶ $self->{"_$name"} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
323 2 my ( undef, $resp, $url ) = @_;
324 2 return $resp->{url} ne $url;
325 1 };
326 } else {
327 24 $self->{$name} = 0;
328 5 ▶ $self->{"_$name"} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
329 5 return 0;
330 24 };
331 }
332 27 return;
333 }
334  
335 27 ▶sub _init_require_installed {
Subroutine _init_require_installed: called CC=2 SCAR=6.9
336 27 my ( $self, $name, $value ) = @_;
337 27 ▶ $self->{$name} = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 1 26 27
338 27 return;
339 }
340  
341 27 ▶sub _init_skip_server_errors {
Subroutine _init_skip_server_errors: called CC=2 SCAR=6.9
342 27 my ( $self, $name, $value ) = @_;
343 27 ▶ $self->{$name} = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 26 1 27
344 27 return;
345 }
346  
347 27 ▶sub _init_user_agent {
Subroutine _init_user_agent: called CC=4 SCAR=14.6
348 27 my ( $self, $name, $value ) = @_;
349 27 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value or $value = "HTTP::Tiny" 27 0 27
350 or $value = USER_AGENT_CLASS;
351 27 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $value->isa("HTTP::Tiny") } } or Carp::confess("Invalid user_agent value '${value}': must be a subclass of HTTP::Tiny, or undef") 27 0 27
352 27 $value->isa( USER_AGENT_CLASS )
353 } or Carp::confess(
354 "Invalid user_agent value '$value': must be a subclass of HTTP::Tiny, or undef" );
355 27 $self->{$name} = $value;
356 27 ▶ if ( ref $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) { } 0 27 27
357 0 $self->{_user_agent} = $value;
358 } else {
359 # Probably unnecessary, but I'm paranoid.
360 27 delete $self->{_user_agent};
361 }
362 27 return;
363 }
364  
365 1 ▶sub agent {
Subroutine agent: called CC=2 SCAR=7.1
Pod documented
366 1 my ( $self ) = @_;
367 defined $self->{agent}
368 1 ▶ or $self->{agent} = $self->_user_agent()->agent();
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"agent"} or $self->{"agent"} = $self->_user_agent->agent 0 1 1
369 1 return $self->{agent};
370 }
371  
372 1 ▶sub all_pod_files_ok {
Subroutine all_pod_files_ok: called CC=3 SCAR=11.0
Pod documented
373 1 my ( $self, @dir ) = @_;
374  
375 @dir
376 1 ▶ or push @dir, 'blib';
Branch: 1 branch
BranchTrueFalseTotal
@dir or push @dir, "blib" 1 0 1
377  
378 my $note = sprintf 'all_pod_files_ok( %s )',
379 1 join ', ', map { "'$_'" } @dir;
380  
381 1 $TEST->note( "Begin $note" );
382  
383 1 my ( $fail, $pass, $skip ) = ( 0 ) x 3;
384  
385 File::Find::find( {
386 no_chdir => 1,
387 13 ▶ wanted => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
388 13 ▶ if ( $self->_is_perl_file( $_ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_perl_file($_)) 12 1 13
389 12 $TEST->note( "Checking POD links in $File::Find::name" );
390 12 my ( $f, $p, $s ) = $self->pod_file_ok( $_ );
391 12 $fail += $f;
392 12 $pass += $p;
393 12 $skip += $s;
394 }
395 13 return;
396 },
397 },
398 1 @dir,
399 );
400  
401 1 $TEST->note( "End $note" );
402  
403 1 ▶ return wantarray ? ( $fail, $pass, $skip ) : $fail;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
404 }
405  
406 1 ▶sub allow_man_spaces {
Subroutine allow_man_spaces: called CC=1 SCAR=0.0
Pod documented
407 1 my ( $self ) = @_;
408 return $self->{allow_man_spaces}
409 1 }
410  
411 14 ▶sub cache_url_response {
Subroutine cache_url_response: called CC=1 SCAR=0.0
Pod documented
412 14 my ( $self ) = @_;
413 return $self->{cache_url_response}
414 14 }
415  
416 12 ▶sub can_ssl {
Subroutine can_ssl: called CC=1 SCAR=0.0
Pod documented
417 12 my ( $self ) = @_;
418 12 return $self->{user_agent}->can_ssl();
419 }
420  
421 7 ▶sub check_external_sections {
Subroutine check_external_sections: called CC=1 SCAR=0.0
Pod documented
422 7 my ( $self ) = @_;
423 return $self->{check_external_sections}
424 7 }
425  
426 17 ▶sub check_url {
Subroutine check_url: called CC=1 SCAR=0.0
Pod documented
427 17 my ( $self ) = @_;
428 return $self->{check_url}
429 17 }
430  
431 1 ▶sub configuration {
Subroutine configuration: called CC=2 SCAR=6.9
Pod documented
432 1 my ( $self, $leader ) = @_;
433  
434 1 ▶ defined $leader
Branch: 1 branch
BranchTrueFalseTotal
defined $leader or $leader = "" 1 0 1
435 or $leader = '';
436 1 $leader =~ s/ (?<= \S ) \z / /smx;
437  
438 1 my ( $ignore_url ) = $TEST->explain( scalar $self->ignore_url() );
439 1 chomp $ignore_url;
440  
441 1 return <<"EOD";
442 1 ${leader}'agent' is '@{[ $self->agent() ]}'
443 1 ${leader}'allow_man_spaces' is @{[ _Boolean(
444 $self->allow_man_spaces() ) ]}
445 1 ${leader}'cache_url_response' is @{[ _Boolean(
446 $self->cache_url_response() ) ]}
447 1 ${leader}'check_external_sections' is @{[ _Boolean(
448 $self->check_external_sections() ) ]}
449 1 ${leader}'check_url' is @{[ _Boolean( $self->check_url() ) ]}
450 ${leader}'ignore_url' is $ignore_url
451 1 ${leader}'man' is @{[ _Boolean( $self->man() ) ]}
452 1 ${leader}'module_index' is ( @{[ join ', ', map { "'$_'" }
453 $self->module_index() ]} )
454 1 ${leader}'prohibit_redirect' is @{[ _Boolean( $self->prohibit_redirect() ) ]}
455 1 ${leader}'require_installed' is @{[ _Boolean( $self->require_installed() ) ]}
456 1 ${leader}'skip_server_errors' is @{[ _Boolean( $self->skip_server_errors() ) ]}
457 EOD
458 }
459  
460 8 ▶sub _Boolean {
Subroutine _Boolean: called CC=2 SCAR=6.9
461 8 my ( $value ) = @_;
462 8 ▶ return $value ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 5 3 8
463 }
464  
465 1 ▶sub ignore_url {
Subroutine ignore_url: called CC=5 SCAR=17.0
Pod documented
466 1 my ( $self ) = @_;
467 1 my $spec = $self->__ignore_url();
468 my @rslt = (
469 1 ▶ sort keys %{ $spec->{ ( NON_REF ) } || {} },
Condition50%1/2
$spec->{''} || {}
l!l
01
MC/DC0%0/1
$spec->{''} || {}
$spec->{''}
Truth table50%1/2
A
A= $spec->{''}
Aresult
11
00
470 1 ▶ @{ $spec->{ ( REGEXP_REF ) } || [] },
Condition50%1/2
$spec->{'Regexp'} || []
l!l
01
MC/DC0%0/1
$spec->{'Regexp'} || []
$spec->{'Regexp'}
Truth table50%1/2
A
A= $spec->{'Regexp'}
Aresult
11
00
471 1 ▶ @{ $spec->{ ( CODE_REF ) } || [] },
Condition50%1/2
$spec->{'CODE'} || []
l!l
01
MC/DC0%0/1
$spec->{'CODE'} || []
$spec->{'CODE'}
Truth table50%1/2
A
A= $spec->{'CODE'}
Aresult
11
00
472 );
473 1 ▶ return wantarray ? @rslt : \@rslt;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
474 }
475  
476 # This method returns the internal value of the ignore_url attribute. It
477 # is PRIVATE to this package, and may be changed or revoked at any time.
478 # If called with an argument, it returns a true value if that argument
479 # is a URL that is to be ignored, and false otherwise.
480 22 ▶sub __ignore_url {
Subroutine __ignore_url: called CC=7 SCAR=19.7
481 22 my ( $self, $url ) = @_;
482 @_ > 1
483 22 ▶ or return $self->{ignore_url};
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 or return $self->{"ignore_url"} 15 7 22
484 15 my $spec = $self->{ignore_url};
485 15 ▶ $spec->{ NON_REF() }{$url}
Branch: 1 branch
BranchTrueFalseTotal
$spec->{""}{$url} and return 1 0 15 15
486 and return 1;
487 15 foreach my $re ( @{ $spec->{ REGEXP_REF() } } ) {
488 1 ▶ $url =~ $re
Branch: 1 branch
BranchTrueFalseTotal
$url =~ /$re/ and return 1 1 0 1
489 and return 1;
490 }
491 14 local $_ = $url;
492 14 foreach my $code ( @{ $spec->{ CODE_REF() } } ) {
493 1 ▶ $code->()
Branch: 1 branch
BranchTrueFalseTotal
&$code() and return 1 1 0 1
494 and return 1;
495 }
496 13 return 0;
497 }
498  
499 4 ▶sub man {
Subroutine man: called CC=1 SCAR=0.0
Pod documented
500 4 my ( $self ) = @_;
501 4 return $self->{man};
502 }
503  
504 2 ▶sub module_index {
Subroutine module_index: called CC=2 SCAR=9.2
Pod documented
505 2 my ( $self ) = @_;
506 wantarray
507 2 ▶ and return @{ $self->{module_index} };
Branch: 1 branch
BranchTrueFalseTotal
wantarray and return @{$self->{"module_index"};} 2 0 2
508 0 local $" = ',';
509 0 return "@{ $self->{module_index} }";
510 }
511  
512 49 ▶sub pod_file_ok {
Subroutine pod_file_ok: called CC=11 SCAR=24.0
Pod documented
513 49 my ( $self, $file ) = @_;
514  
515 49 delete $self->{_section};
516 $self->{_test} = {
517 49 pass => 0,
518 fail => 0,
519 skip => 0,
520 };
521  
522 49 ▶ if ( SCALAR_REF eq ref $file ) {
Branch: 2 branches
BranchTrueFalseTotal
if ('SCALAR' eq ref $file) { } 1 48 49
elsif (-f $file) { } 47 1 48
523 1 ▶ $self->{_file_name} = ${ $file } =~ m/ \n /smx ?
Branch: 1 branch
BranchTrueFalseTotal
${$file;} =~ / \n /msx ? : 0 1 1
524 "String $file" :
525 1 "String '${ $file }'";
526 } elsif ( -f $file ) {
527 47 $self->{_file_name} = "File $file";
528 } else {
529 1 $self->{_file_name} = "File $file";
530 1 $self->_fail(
531 'does not exist, or is not a normal file' );
532 1 ▶ return wantarray ? ( 1, 0, 0 ) : 1;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 0 1
533 }
534  
535 48 ( $self->{_section}, $self->{_links} ) = My_Parser->new()->run(
536 $file, \&_any_errata_seen, $self );
537  
538 48 @{ $self->{_links} }
539 48 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
@{$self->{"_links"};} or do { $self->_pass; return wantarray ? (0, 1, 0) : 0 } 41 7 48
540 7 $self->_pass();
541 7 ▶ return wantarray ? ( 0, 1, 0 ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 4 7
542 };
543  
544 41 my $errors = 0;
545  
546 41 foreach my $link ( @{ $self->{_links} } ) {
547 48 ▶ my $code = $self->can( "_handle_$link->[1]{type}" )
Branch: 1 branch
BranchTrueFalseTotal
my $code = $self->can(qq[_handle_$link->[1]{"type"}]) or Carp::confess(qq[TODO - link type $link->[1]{"type"} not supported]) 48 0 48
548 or Carp::confess(
549 "TODO - link type $link->[1]{type} not supported" );
550 48 $errors += $code->( $self, $link );
551 }
552  
553 $errors
554 41 ▶ or $self->_pass();
Branch: 1 branch
BranchTrueFalseTotal
$errors or $self->_pass 9 32 41
555 return wantarray ?
556 15 ( @{ $self->{_test} }{ qw{ fail pass skip } } ) :
557 41 ▶ $self->{_test}{fail};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 15 26 41
558 }
559  
560 1 ▶sub prohibit_redirect {
Subroutine prohibit_redirect: called CC=1 SCAR=0.0
Pod documented
561 1 my ( $self ) = @_;
562 1 return $self->{prohibit_redirect};
563 }
564  
565 8 ▶sub require_installed {
Subroutine require_installed: called CC=1 SCAR=0.0
Pod documented
566 8 my ( $self ) = @_;
567 8 return $self->{require_installed};
568 }
569  
570 3 ▶sub skip_server_errors {
Subroutine skip_server_errors: called CC=1 SCAR=0.0
Pod documented
571 3 my ( $self ) = @_;
572 3 return $self->{skip_server_errors};
573 }
574  
575 # This is a private method, but because it had to be accessed (read:
576 # monkey-patched) to get badly-needed user functionality, it needs to
577 # fulfill its interface contract until March 1 2024 or one year after
578 # the release of version 0.011, whichever is later. That contract is:
579 # * Name: _user_agent
580 # * Arguments: none
581 # * Return: HTTP::Tiny object, which may be a subclass.
582 20 ▶sub _user_agent {
Subroutine _user_agent: called CC=3 SCAR=11.2
583 20 my ( $self ) = @_;
584 20 ▶ return( $self->{_user_agent} ||= do {
Condition66%2/3
$self->{"_user_agent"} ||= do { my @arg; defined $self->{"agent"} and push @arg, "agent", $self->{"agent"}; $self->{"user_agent"}->new(@arg) }
l!l&&r!l&&!r
6140
MC/DC0%0/2
$self->{"_user_agent"} ||= do { my @arg; defined $self->{"agent"} and push @arg, "agent", $self->{"agent"}; $self->{"user_agent"}->new(@arg) }
$self->{"_user_agent"} do { my @arg; defined $self->{"agent"} and push @arg, "agent", $self->{"agent"}; $self->{"user_agent"}->new(@arg) }
Truth table66%2/3
A ||= B
A= $self->{"_user_agent"}B= do { my @arg; defined $self->{"agent"} and push @arg, "agent", $self->{"agent"}; $self->{"user_agent"}->new(@arg) }
ABresult
1X1
011
000
585 14 my @arg;
586 defined $self->{agent}
587 14 ▶ and push @arg, agent => $self->{agent};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"agent"} and push @arg, "agent", $self->{"agent"} 0 14 14
588 14 $self->{user_agent}->new( @arg );
589 }
590 );
591 }
592  
593 39 ▶sub _pass {
Subroutine _pass: called CC=2 SCAR=7.0
594 39 my ( $self, @msg ) = @_;
595 @msg
596 39 ▶ or @msg = ( 'contains no broken links' );
Branch: 1 branch
BranchTrueFalseTotal
@msg or @msg = "contains no broken links" 0 39 39
597 39 local $Test::Builder::Level = _nest_depth();
598 39 $TEST->ok( 1, $self->__build_test_msg( @msg ) );
599 39 $self->{_test}{pass}++;
600 39 return 0;
601 }
602  
603 12 ▶sub _fail {
Subroutine _fail: called CC=1 SCAR=0.0
604 12 my ( $self, @msg ) = @_;
605 12 local $Test::Builder::Level = _nest_depth();
606 12 $TEST->ok( 0, $self->__build_test_msg( @msg ) );
607 12 $self->{_test}{fail}++;
608 12 return 1;
609 }
610  
611 4 ▶sub _skip {
Subroutine _skip: called CC=1 SCAR=0.0
612 4 my ( $self, @msg ) = @_;
613 4 local $Test::Builder::Level = _nest_depth();
614 4 $TEST->skip( $self->__build_test_msg( @msg ) );
615 4 $self->{_test}{skip}++;
616 4 return 0;
617 }
618  
619 0 ▶sub _any_errata_seen {
Subroutine _any_errata_seen: not called CC=2 SCAR=17.9
620 0 my ( $self, $file ) = @_;
621 0 ▶ $file = defined $file ? "File $file" : $self->{_file_name};
Branch: 1 branch
BranchTrueFalseTotal
defined $file ? : 0 0 0
622 0 $TEST->diag( "$file contains POD errors" );
623 0 return;
624 }
625  
626 # This method formats test messages. It is PRIVATE to this package, and
627 # can be changed or revoked without notice.
628 58 ▶sub __build_test_msg {
Subroutine __build_test_msg: called CC=4 SCAR=13.9
629 58 my ( $self, @msg ) = @_;
630 58 my @prefix = ( $self->{_file_name} );
631 58 ▶ if ( ARRAY_REF eq ref $msg[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("ARRAY" eq ref $msg[0]) 17 41 58
632 17 my $link = shift @msg;
633 my $text = defined $link->[1]{raw} ?
634 17 ▶ "link L<$link->[1]{raw}>" :
Branch: 1 branch
BranchTrueFalseTotal
defined $link->[1]{'raw'} ? : 17 0 17
635 'Link L<>';
636 defined $link->[1]{line_number}
637 17 ▶ and push @prefix, "line $link->[1]{line_number}";
Branch: 1 branch
BranchTrueFalseTotal
defined $link->[1]{"line_number"} and push @prefix, qq[line $link->[1]{"line_number"}] 16 1 17
638 17 push @prefix, $text;
639 }
640 58 return join ' ', @prefix, join '', @msg;
641 }
642  
643 # Get the information on installed documentation. If the doc is found
644 # the return is a reference to a hash containing key {file}, value the
645 # path name to the file containing the documentation. This works both
646 # for module documentation (whether in the .pm or a separate .pod), or
647 # regular .pod documentation (e.g. perldelta.pod).
648 13 ▶sub _get_installed_doc_info {
Subroutine _get_installed_doc_info: called CC=8 SCAR=21.6
649 13 my ( $self, $module ) = @_;
650  
651 # NOTE we have to do this by hand, because Pod::Perldoc searches
652 # Perl's bin/ BEFORE the contents of @INC.
653 13 ( my $file = $module ) =~ s(::)('/)g;
654 13 foreach my $dir ( @{ $self->{add_dir} } ) {
655 1 foreach my $ext ( '', qw{ .pod .pm } ) {
656 1 my $path = "$dir/$file$ext";
657 1 ▶ -e $path
Branch: 1 branch
BranchTrueFalseTotal
-e $path and -s _ and -T _ and return {"file", $path} 1 0 1
Condition33%2/6
-e $path and -s _ and -T _
!ll&&!rl&&r
001
-e $path and -s _
!ll&&!rl&&r
001
MC/DC0%0/3
-e $path and -s _ and -T _
-e $path -s _ -T _
Truth table25%1/4
A and B and C
A= -e $pathB= -s _C= -T _
ABCresult
0XX0
10X0
1100
1111
658 and -s _
659 and -T _
660 and return {
661 file => $path,
662 };
663 }
664 }
665  
666 12 my $pd = Pod::Perldoc->new();
667  
668 # Pod::Perldoc writes to STDERR if the module (or whatever) is not
669 # installed, so we localize STDERR and reopen it to the null device.
670 # The reopen of STDERR is unchecked because if it fails we still
671 # want to run the tests. They just may be noisy.
672 12 my $path;
673 {
674 12 local *STDERR;
675 12 open STDERR, '>', File::Spec->devnull(); ## no critic (RequireCheckedOpen)
676  
677 # NOTE that grand_search_init() is undocumented.
678 12 ( $path ) = $pd->grand_search_init( [ $module ] );
679 }
680  
681 12 ▶ defined $path
Branch: 1 branch
BranchTrueFalseTotal
defined $path and return {"file", $path} 5 7 12
682 and return {
683 file => $path,
684 };
685  
686 # See the comment above (just below where _get_installed_doc_info is
687 # called) for why this check is done.
688 7 ▶ Module::Load::Conditional::check_install( module => $module )
Branch: 1 branch
BranchTrueFalseTotal
Module::Load::Conditional::check_install("module", $module) and return {"file", $path, "undocumented", 1} 0 7 7
689 and return {
690 file => $path,
691 undocumented => 1,
692 };
693  
694 7 return;
695 }
696  
697 # POD link handlers
698  
699 # Handle a 'man' link.
700  
701 2 ▶sub _handle_man {
Subroutine _handle_man: called CC=10 SCAR=28.4
702 2 my ( $self, $link ) = @_;
703  
704 2 ▶ $self->man()
Branch: 1 branch
BranchTrueFalseTotal
$self->man or return $self->_skip($link, "not checked; man checks disabled") 2 0 2
705 or return $self->_skip( $link, 'not checked; man checks disabled' );
706  
707 $link->[1]{to}
708 2 ▶ or return $self->_fail( $link, 'no man page specified' );
Branch: 1 branch
BranchTrueFalseTotal
$link->[1]{"to"} or return $self->_fail($link, "no man page specified") 2 0 2
709  
710 2 ▶ my ( $page, $sect ) = $link->[1]{to} =~ m/
Branch: 1 branch
BranchTrueFalseTotal
() = $link->[1]{"to"} =~ / ( [^(]+ ) (?: [(] ( [^)]+ ) [)] )? /msx or return $self->_fail($link, "not recognized as man page spec") 2 0 2
711 ( [^(]+ ) (?: [(] ( [^)]+ ) [)] )? /smx
712 or return $self->_fail( $link, 'not recognized as man page spec' );
713  
714 2 $page =~ s/ \s+ \z //smx;
715  
716 2 ▶ $page =~ m/ \s /smx
Branch: 1 branch
BranchTrueFalseTotal
$page =~ / \s /msx and not $self->allow_man_spaces and return $self->_fail($link, "contains embedded spaces") 0 2 2
Condition33%1/3
$page =~ / \s /msx and not $self->allow_man_spaces
!ll&&!rl&&r
200
MC/DC0%0/2
$page =~ / \s /msx and not $self->allow_man_spaces
$page =~ / \s /msx not $self->allow_man_spaces
Truth table33%1/3
A and not(B)
A= $page =~ / \s /msxB= not $self->allow_man_spaces
ABresult
0X0
100
111
717 and not $self->allow_man_spaces()
718 and return $self->_fail( $link, 'contains embedded spaces' );
719  
720 2 ▶ my @pg = (
Branch: 1 branch
BranchTrueFalseTotal
$sect ? : 2 0 2
721 $sect ? $sect : (),
722 $page,
723 );
724  
725 2 ▶ ( $self->{_cache}{man}{"@pg"} ||= IPC::Cmd::run( COMMAND => [
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_cache"}{"man"}{join $", @pg} ||= IPC::Cmd::run("COMMAND", [("man", "-w"), @pg]) || 0 and return 0 2 0 2
Condition40%2/5
$self->{"_cache"}{"man"}{join $", @pg} ||= IPC::Cmd::run("COMMAND", [("man", "-w"), @pg]) || 0
l!l&&r!l&&!r
020
IPC::Cmd::run('COMMAND', [('man', '-w'), @pg]) || 0
l!l
20
MC/DC0%0/2
$self->{"_cache"}{"man"}{join $", @pg} ||= IPC::Cmd::run("COMMAND", [("man", "-w"), @pg]) || 0
$self->{"_cache"}{"man"}{join $", @pg} IPC::Cmd::run('COMMAND', [('man', '-w'), @pg])
Truth table33%1/3
A ||= B
A= $self->{"_cache"}{"man"}{join $", @pg}B= IPC::Cmd::run('COMMAND', [('man', '-w'), @pg])
ABresult
1X1
011
000
726 qw{ man -w }, @pg ] ) || 0 )
727 and return 0;
728  
729 0 return $self->_fail( $link, 'refers to unknown man page' );
730 }
731  
732 # Handle pod links. This is pretty much everything, except for 'man'
733 # (see above) or 'url' (see below).
734 30 ▶sub _handle_pod {
Subroutine _handle_pod: called CC=4 SCAR=13.9
735 30 my ( $self, $link ) = @_;
736  
737 30 ▶ if ( $link->[1]{to} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($link->[1]{'to'}) { } 20 10 30
elsif (my $section = $link->[1]{'section'}) { } 9 1 10
738 20 return $self->_check_external_pod_info( $link )
739  
740 } elsif ( my $section = $link->[1]{section} ) {
741 9 $section = "$section"; # Stringify object
742 # Internal links (no {to})
743 9 ▶ $self->{_section}{$section}
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_section"}{$section} and return 0 8 1 9
744 and return 0;
745  
746 # Before 3.24, Pod::Simple was too restrictive in parsing 'man'
747 # links, and they end up here. The regex is verbatim from
748 # Pod::Simple 3.24.
749 1 if ( NEED_MAN_FIX && $section =~ m{^[^/|]+[(][-a-zA-Z0-9]+[)]$}s ) {
750 # The misparse left the actual link text in {section}, but
751 # an honest-to-God Pod link has it in {to}.
752 $link->[1]{to} = delete $link->[1]{section};
753 # While we're at it, we might as well make it an actual
754 # 'man' link.
755 $link->[1]{type} = 'man';
756 goto &_handle_man;
757 }
758  
759 1 return $self->_fail( $link, 'links to unknown section' );
760  
761 } else {
762 # Links to nowhere: L<...|> or L<...|/>
763 1 return $self->_fail( $link, 'links to nothing' );
764 }
765 0 return 0;
766 }
767  
768 20 ▶sub _check_external_pod_info {
Subroutine _check_external_pod_info: called CC=14 SCAR=26.5
769 20 my ( $self, $link ) = @_;
770  
771 # Stringify overloaded objects
772 20 ▶ my $module = $link->[1]{to} ? "$link->[1]{to}" : undef;
Branch: 1 branch
BranchTrueFalseTotal
$link->[1]{'to'} ? : 20 0 20
773 20 ▶ my $section = $link->[1]{section} ? "$link->[1]{section}" : undef;
Branch: 1 branch
BranchTrueFalseTotal
$link->[1]{'section'} ? : 7 13 20
774  
775 # If there is no section info it might be a Perl builtin. Return
776 # success if it is.
777 20 ▶ unless ( $section ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($section) 13 7 20
778 13 ▶ $self->_is_perl_function( $module )
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_perl_function($module) and return 0 2 11 13
779 and return 0;
780 }
781  
782 # If it is installed, handle it
783 18 ▶ if ( my $data = $self->{_cache}{installed}{$module} ||=
Branch: 1 branch
BranchTrueFalseTotal
if (my $data = ($self->{"_cache"}{"installed"}{$module} ||= $self->_get_installed_doc_info($module))) 11 7 18
Condition100%3/3
$self->{"_cache"}{"installed"}{$module} ||= $self->_get_installed_doc_info($module)
l!l&&r!l&&!r
567
MC/DC100%2/2
$self->{"_cache"}{"installed"}{$module} ||= $self->_get_installed_doc_info($module)
$self->{"_cache"}{"installed"}{$module} $self->_get_installed_doc_info($module)
Truth table100%3/3
A ||= B
A= $self->{"_cache"}{"installed"}{$module}B= $self->_get_installed_doc_info($module)
ABresult
1X1
011
000
784 $self->_get_installed_doc_info( $module ) ) {
785  
786 # This check is the result of an Andreas J. König (ANDK) test
787 # failure under Perl 5.8.9. That version ships with Pod::Perldoc
788 # 3.14, which is undocumented. Previously the unfound
789 # documentation caused us to fall through to the 'uninstalled'
790 # code, which succeeded because all it was doing was looking for
791 # the existence of the module, and _assuming_ that it was
792 # documented.
793 $data->{undocumented}
794 11 ▶ and return $self->_fail( $link,
Branch: 1 branch
BranchTrueFalseTotal
$data->{"undocumented"} and return $self->_fail($link, "$module is installed but undocumented") 0 11 11
795 "$module is installed but undocumented" );
796  
797 # If we get this far it is an installed module with
798 # documentation. We can return success at this point unless the
799 # link specifies a section AND we are checking them. We test the
800 # link rather than the section name because the latter could be
801 # '0'.
802 $link->[1]{section}
803 11 ▶ and $self->check_external_sections()
Branch: 1 branch
BranchTrueFalseTotal
$link->[1]{"section"} and $self->check_external_sections or return 0 5 6 11
Condition100%3/3
$link->[1]{"section"} and $self->check_external_sections
!ll&&!rl&&r
515
MC/DC100%2/2
$link->[1]{"section"} and $self->check_external_sections
$link->[1]{"section"} $self->check_external_sections
Truth table100%3/3
A and B
A= $link->[1]{"section"}B= $self->check_external_sections
ABresult
0X0
100
111
804 or return 0;
805  
806 # Find and parse the section info if needed.
807 $data->{section} ||= My_Parser->new()->run( $data->{file},
808 5 ▶ \&_any_errata_seen, $self, "File $data->{file}" );
Condition66%2/3
$data->{"section"} ||= "My_Parser"->new->run($data->{"file"}, \&Test::Pod::LinkCheck::Lite::_any_errata_seen, $self, qq[File $data->{"file"}])
l!l&&r!l&&!r
140
MC/DC0%0/2
$data->{"section"} ||= "My_Parser"->new->run($data->{"file"}, \&Test::Pod::LinkCheck::Lite::_any_errata_seen, $self, qq[File $data->{"file"}])
$data->{"section"} "My_Parser"->new->run($data->{"file"}, \&Test::Pod::LinkCheck::Lite::_any_errata_seen, $self, qq[File $data->{"file"}])
Truth table66%2/3
A ||= B
A= $data->{"section"}B= "My_Parser"->new->run($data->{"file"}, \&Test::Pod::LinkCheck::Lite::_any_errata_seen, $self, qq[File $data->{"file"}])
ABresult
1X1
011
000
809  
810 5 ▶ $data->{section}{$section}
Branch: 1 branch
BranchTrueFalseTotal
$data->{"section"}{$section} and return 0 4 1 5
811 and return 0;
812  
813 1 return $self->_fail( $link, 'links to unknown section' );
814 }
815  
816 # If we're requiring links to be to installed modules, flunk now.
817 $self->require_installed()
818 7 ▶ and return $self->_fail( $link,
Branch: 1 branch
BranchTrueFalseTotal
$self->require_installed and return $self->_fail($link, "links to module that is not installed") 1 6 7
819 'links to module that is not installed' );
820  
821 # It's not installed on this system, but it may be out there
822 # somewhere
823  
824 6 ▶ $self->{_cache}{uninstalled} ||= $self->_get_module_index();
Condition66%2/3
$self->{"_cache"}{"uninstalled"} ||= $self->_get_module_index
l!l&&r!l&&!r
150
MC/DC0%0/2
$self->{"_cache"}{"uninstalled"} ||= $self->_get_module_index
$self->{"_cache"}{"uninstalled"} $self->_get_module_index
Truth table66%2/3
A ||= B
A= $self->{"_cache"}{"uninstalled"}B= $self->_get_module_index
ABresult
1X1
011
000
825  
826 6 return $self->{_cache}{uninstalled}->( $self, $link );
827  
828 }
829  
830 5 ▶sub _get_module_index {
Subroutine _get_module_index: called CC=2 SCAR=7.3
831 5 my ( $self ) = @_;
832 1 my @inxes = sort { $a->[1] <=> $b->[1] }
833 5 map { $_->( $self ) } @{ $self->{_module_index} };
834 5 ▶ if ( @inxes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@inxes) { } 5 0 5
835 5 my $modinx = $inxes[-1][0];
836 6 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=11.3
837 6 my ( $self, $link ) = @_;
838 6 my $module = $link->[1]{to};
839 6 ▶ $modinx->( $module )
Branch: 1 branch
BranchTrueFalseTotal
&$modinx($module) or return $self->_fail($link, "links to unknown module") 4 2 6
840 or return $self->_fail( $link, 'links to unknown module' );
841 $link->[1]{section}
842 4 ▶ or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$link->[1]{"section"} or return 0 0 4 4
843 0 return $self->_skip( $link, 'not checked; ',
844 'module exists, but unable to check sections of ',
845 'uninstalled modules' );
846 5 };
847 } else {
848 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
849 0 my ( $self, $link ) = @_;
850 0 return $self->_skip( $link, 'not checked; ',
851 'not found on this system' );
852 0 };
853 }
854 }
855  
856 # In all of the module index getters, the return is either nothing at
857 # all (for inability to use this indexing mechanism) or a refererence to
858 # an array. Element [0] of the array is a reference a piece of code that
859 # takes the module name as its only argument, and returns a true value
860 # if that module exists and a false value otherwise. Element [1] of the
861 # array is a Perl time that is characteristic of the information in the
862 # index (typically the revision date of the underlying file if that's
863 # the way the index works).
864  
865 # NOTE that Test::Pod::LinkCheck loads CPAN and then messes with it to
866 # try to prevent it from initializing itself. After trying this and
867 # thinking about it, I decided to go after the metadata directly.
868 4 ▶sub _get_module_index_cpan {
Subroutine _get_module_index_cpan: called CC=11 SCAR=25.4
869 # my ( $self ) = @_;
870  
871 # The following code reproduces
872 # CPAN::HandleConfig::cpan_home_dir_candidates()
873 # as of CPAN::HandleConfig version 5.5011.
874 4 my @dir_list;
875  
876 4 ▶ if ( _has_usable( 'File::HomeDir', 0.52 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_has_usable("File::HomeDir", "0.52")) 4 0 4
877 4 ON_DARWIN
878 or push @dir_list, File::HomeDir->my_data();
879 4 push @dir_list, File::HomeDir->my_home();
880 }
881  
882 $ENV{HOME}
883 4 ▶ and push @dir_list, $ENV{HOME};
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"HOME"} and push @dir_list, $ENV{"HOME"} 4 0 4
884 $ENV{HOMEDRIVE}
885 and $ENV{HOMEPATH}
886 and push @dir_list, File::Spec->catpath( $ENV{HOMEDRIVE},
887 4 ▶ $ENV{HOMEPATH} );
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"HOMEDRIVE"} and $ENV{"HOMEPATH"} and push @dir_list, "File::Spec"->catpath($ENV{"HOMEDRIVE"}, $ENV{"HOMEPATH"}) 0 4 4
Condition33%1/3
$ENV{"HOMEDRIVE"} and $ENV{"HOMEPATH"}
!ll&&!rl&&r
400
MC/DC0%0/2
$ENV{"HOMEDRIVE"} and $ENV{"HOMEPATH"}
$ENV{"HOMEDRIVE"} $ENV{"HOMEPATH"}
Truth table33%1/3
A and B
A= $ENV{"HOMEDRIVE"}B= $ENV{"HOMEPATH"}
ABresult
0X0
100
111
888 $ENV{USERPROFILE}
889 4 ▶ and push @dir_list, $ENV{USERPROFILE};
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"USERPROFILE"} and push @dir_list, $ENV{"USERPROFILE"} 0 4 4
890 $ENV{'SYS$LOGIN'}
891 4 ▶ and push @dir_list, $ENV{'SYS$LOGIN'};
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"SYS\$LOGIN"} and push @dir_list, $ENV{"SYS\$LOGIN"} 0 4 4
892  
893 # The preceding code reproduces
894 # CPAN::HandleConfig::cpan_home_dir_candidates()
895  
896 4 foreach my $dir ( @dir_list ) {
897 8 ▶ defined $dir
Branch: 1 branch
BranchTrueFalseTotal
defined $dir or next 8 0 8
898 or next;
899 8 my $path = File::Spec->catfile( $dir, $DOT_CPAN, 'Metadata' );
900 8 ▶ -e $path
Branch: 1 branch
BranchTrueFalseTotal
-e $path or next 2 6 8
901 or next;
902 2 my $rev = ( stat _ )[9];
903 2 ▶ my $hash = Storable::retrieve( $path )
Branch: 1 branch
BranchTrueFalseTotal
my $hash = Storable::retrieve($path) or return 2 0 2
904 or return;
905 2 $hash = $hash->{'CPAN::Module'};
906 return [
907 1 ▶ sub { return $hash->{$_[0]} },
Subroutine __ANON__: called CC=1 SCAR=0.0
908 2 $rev,
909 ];
910 }
911  
912 2 return;
913 }
914  
915 4 ▶sub _get_module_index_cpan_meta_db {
Subroutine _get_module_index_cpan_meta_db: called CC=1 SCAR=0.0
916 4 my ( $self ) = @_;
917  
918 4 my $user_agent = $self->_user_agent();
919  
920 4 my %hash;
921  
922 return [
923 5 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
924 exists $hash{$_[0]}
925 5 ▶ and return $hash{$_[0]};
Branch: 1 branch
BranchTrueFalseTotal
exists $hash{$_[0]} and return $hash{$_[0]} 1 4 5
926 4 my $resp = $user_agent->head(
927 "https://cpanmetadb.plackperl.org/v1.0/package/$_[0]" );
928 4 return ( $hash{$_[0]} = $resp->{success} );
929 },
930 4 time - 86400 * 7,
931 ];
932 }
933  
934 # Handle url links. This is something like L<http://...> or
935 # L<...|http://...>.
936 16 ▶sub _handle_url {
Subroutine _handle_url: called CC=14 SCAR=28.2
937 16 my ( $self, $link ) = @_;
938  
939 16 ▶ $self->check_url()
Branch: 1 branch
BranchTrueFalseTotal
$self->check_url or return $self->_skip($link, "not checked; url checks disabled") 15 1 16
940 or return $self->_skip( $link, 'not checked; url checks disabled' );
941  
942 15 my $user_agent = $self->_user_agent();
943  
944 15 ▶ my $url = "$link->[1]{to}" # Stringify object
Branch: 1 branch
BranchTrueFalseTotal
my $url = qq[$link->[1]{"to"}] or return $self->_fail($link, "contains no url") 15 0 15
945 or return $self->_fail( $link, 'contains no url' );
946  
947 15 ▶ if ( $url =~ m/ \A https : /smxi ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($url =~ / \A https : /imsx) 11 4 15
948 11 my ( $ok, $why ) = $self->can_ssl();
949 11 ▶ unless ( $ok ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 11 11
950 $self->{_ssl_warning}
951 0 ▶ or $TEST->diag( "Can not check https: links: $why" );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_ssl_warning"} or $TEST->diag("Can not check https: links: $why") 0 0 0
952 0 $self->{_ssl_warning} = 1;
953 0 return $self->_skip(
954 $link, 'not checked: https: checks unavailable' );
955 }
956 }
957  
958 15 ▶ $self->__ignore_url( $url )
Branch: 1 branch
BranchTrueFalseTotal
$self->__ignore_url($url) and return $self->_skip($link, "not checked; explicitly ignored") 2 13 15
959 and return $self->_skip( $link, 'not checked; explicitly ignored' );
960  
961 13 my $resp;
962 13 ▶ if ( $self->cache_url_response() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cache_url_response) { } 13 0 13
963 13 ▶ $resp = $self->{_cache_url_response}{$url} ||=
Condition33%1/3
$self->{"_cache_url_response"}{$url} ||= $user_agent->head($url)
l!l&&r!l&&!r
0130
MC/DC0%0/2
$self->{"_cache_url_response"}{$url} ||= $user_agent->head($url)
$self->{"_cache_url_response"}{$url} $user_agent->head($url)
Truth table33%1/3
A ||= B
A= $self->{"_cache_url_response"}{$url}B= $user_agent->head($url)
ABresult
1X1
011
000
964 $user_agent->head( $url );
965 } else {
966 0 $resp = $user_agent->head( $url );
967 }
968  
969 13 ▶ if ( $resp->{success} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resp->{'success'}) { } 11 2 13
970  
971 11 my $code = $self->{_prohibit_redirect};
972 11 ▶ while ( $code = $code->( $self, $resp, $url ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code = &$code($self, $resp, $url)) 6 7 13
973 6 ▶ CODE_REF eq ref $code
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref $code or return $self->_fail($link, qq[redirected to $resp->{"url"}]) 2 4 6
974 or return $self->_fail( $link, "redirected to $resp->{url}" );
975 }
976  
977 7 return 0;
978  
979 } else {
980  
981 $self->skip_server_errors()
982 2 ▶ and $resp->{status} =~ m/ \A 5 /smx
Branch: 1 branch
BranchTrueFalseTotal
$self->skip_server_errors and $resp->{"status"} =~ / \A 5 /msx and return $self->_skip($link, qq[not checked: server error $resp->{"status"} $resp->{"reason"}]) 1 1 2
Condition66%2/3
$self->skip_server_errors and $resp->{"status"} =~ / \A 5 /msx
!ll&&!rl&&r
101
MC/DC50%1/2
$self->skip_server_errors and $resp->{"status"} =~ / \A 5 /msx
$self->skip_server_errors $resp->{"status"} =~ / \A 5 /msx
Truth table66%2/3
A and B
A= $self->skip_server_errorsB= $resp->{"status"} =~ / \A 5 /msx
ABresult
0X0
100
111
983 and return $self->_skip( $link,
984 "not checked: server error $resp->{status} $resp->{reason}" );
985  
986 1 return $self->_fail( $link,
987 "broken: $resp->{status} $resp->{reason}" );
988  
989 }
990 }
991  
992 {
993 2 my %checked;
994  
995 4 ▶ sub _has_usable {
Subroutine _has_usable: called CC=5 SCAR=16.8
996 4 my ( $module, $version ) = @_;
997  
998 4 ▶ unless ( exists $checked{$module} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $checked{$module}) 1 3 4
999 1 local $@ = undef;
1000 1 ( my $fn = "$module.pm" ) =~ s| :: |/|smxg;
1001 eval {
1002 1 require $fn;
1003 1 $checked{$module} = 1;
1004 1 1;
1005 1 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require $fn; $checked{$module} = 1; 1 } } or do { $checked{$module} = 0 } 1 0 1
1006 0 $checked{$module} = 0;
1007 };
1008 }
1009  
1010 4 ▶ $checked{$module}
Branch: 1 branch
BranchTrueFalseTotal
$checked{$module} or return 4 0 4
1011 or return;
1012  
1013 4 ▶ if ( defined $version ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $version) 4 0 4
1014 4 my $rslt = 1;
1015 0 ▶ local $SIG{__DIE__} = sub { $rslt = undef };
Subroutine __ANON__: not called CC=1 SCAR=1.2
1016 4 $module->VERSION( $version );
1017 4 return $rslt;
1018 }
1019  
1020 0 return 1;
1021 }
1022 }
1023  
1024 2 ▶sub _is_perl_file {
Subroutine _is_perl_file: called CC=6 SCAR=18.0
1025 20 my ( undef, $path ) = @_;
1026 20 ▶ -e $path
Branch: 1 branch
BranchTrueFalseTotal
-e $path and -T _ or return 17 3 20
Condition100%3/3
-e $path and -T _
!ll&&!rl&&r
1217
MC/DC100%2/2
-e $path and -T _
-e $path -T _
Truth table100%3/3
A and B
A= -e $pathB= -T _
ABresult
0X0
100
111
1027 and -T _
1028 or return;
1029 17 ▶ $path =~ m/ [.] (?: (?i: pl ) | pm | pod | t ) \z /smx
Branch: 1 branch
BranchTrueFalseTotal
$path =~ / [.] (?: (?i: pl ) | pm | pod | t ) \z /msx and return 1 16 1 17
1030 and return 1;
1031 1 ▶ open my $fh, '<', $path
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $path or return 1 0 1
1032 or return;
1033 1 ▶ local $_ = <$fh> || '';
Condition50%1/2
readline $fh || ''
l!l
10
MC/DC0%0/1
readline $fh || ''
readline $fh
Truth table50%1/2
A
A= readline $fh
Aresult
11
00
1034 1 close $fh;
1035 1 return m/ perl /smx;
1036 }
1037  
1038 {
1039 2 my $bareword;
1040  
1041 13 ▶ sub _is_perl_function {
Subroutine _is_perl_function: called CC=2 SCAR=6.9
1042 13 my ( undef, $word ) = @_;
1043 $bareword ||= {
1044 13 ▶ map { $_ => 1 } @B::Keywords::Functions, @B::Keywords::Barewords };
Condition100%2/2
$bareword ||= {map({$_, 1;} @B::Keywords::Functions, @B::Keywords::Barewords)}
l!l
121
MC/DC100%1/1
$bareword ||= {map({$_, 1;} @B::Keywords::Functions, @B::Keywords::Barewords)}
$bareword
Truth table100%2/2
A
A= $bareword
Aresult
11
00
1045 13 return $bareword->{$word};
1046 }
1047 }
1048  
1049 {
1050 2 my %ignore;
1051 2 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
1052 2 %ignore = map { $_ => 1 } __PACKAGE__, qw{ DB File::Find };
1053 }
1054  
1055 55 ▶ sub _nest_depth {
Subroutine _nest_depth: called CC=3 SCAR=11.1
1056 55 my $nest = 0;
1057 55 ▶ $nest++ while $ignore{ caller( $nest ) || '' };
Branch: 1 branch
BranchTrueFalseTotal
$ignore{caller $nest or ""} and do { ++$nest } 191 55 246
Condition50%1/2
caller $nest || ''
l!l
2460
MC/DC0%0/1
caller $nest || ''
caller $nest
Truth table50%1/2
A
A= caller $nest
Aresult
11
00
1058 55 return $nest;
1059 }
1060 }
1061  
1062 2 package My_Parser; ## no critic (ProhibitMultiplePackages)
1063  
1064 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
1065 2 ▶use Pod::Simple::PullParser; # Core since 5.9.3 (part of Pod::Simple)
Subroutine BEGIN: called CC=1 SCAR=0.0
1066  
1067 2 @My_Parser::ISA = qw{ Pod::Simple::PullParser };
1068  
1069 2 my %section_tag = map { $_ => 1 } qw{ head1 head2 head3 head4 item-text };
1070  
1071 52 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
1072 52 my ( $class ) = @_;
1073 52 my $self = $class->SUPER::new();
1074 52 $self->preserve_whitespace( 1 );
1075 52 return $self;
1076 }
1077  
1078 52 ▶sub run {
Subroutine run: called CC=7 SCAR=19.9
1079 52 my ( $self, $source, $err, @err_arg ) = @_;
1080 52 ▶ defined $source
Branch: 1 branch
BranchTrueFalseTotal
defined $source and $self->set_source($source) 52 0 52
1081 and $self->set_source( $source );
1082 52 my $attr = $self->_attr();
1083 52 $attr->{ignore_tag} = [];
1084 52 $attr->{line} = 1;
1085 52 $attr->{links} = [];
1086 52 $attr->{source} = $source;
1087 52 $attr->{sections} = {};
1088 52 ▶ while ( my $token = $self->get_token() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $self->get_token) 791 52 843
1089 791 ▶ if ( my $code = $self->can( '__token_' . $token->type() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $self->can('__token_' . $token->type)) 791 0 791
1090 791 $code->( $self, $token );
1091 }
1092 }
1093 $err
1094 52 ▶ and $self->any_errata_seen()
Branch: 1 branch
BranchTrueFalseTotal
$err and $self->any_errata_seen and &$err(@err_arg) 0 52 52
Condition33%1/3
$err and $self->any_errata_seen
!ll&&!rl&&r
0520
MC/DC0%0/2
$err and $self->any_errata_seen
$err $self->any_errata_seen
Truth table33%1/3
A and B
A= $errB= $self->any_errata_seen
ABresult
0X0
100
111
1095 and $err->( @err_arg );
1096 return wantarray ?
1097 ( $attr->{sections}, $attr->{links} ) :
1098 52 ▶ $attr->{sections};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 48 4 52
1099 }
1100  
1101 843 ▶sub _attr {
Subroutine _attr: called CC=2 SCAR=6.9
1102 843 my ( $self ) = @_;
1103 843 ▶ return $self->{ ( __PACKAGE__ ) } ||= {};
Condition100%2/2
$self->{"My_Parser"} ||= {}
l!l
79152
MC/DC100%1/1
$self->{"My_Parser"} ||= {}
$self->{"My_Parser"}
Truth table100%2/2
A
A= $self->{"My_Parser"}
Aresult
11
00
1104 }
1105  
1106 90 ▶sub _normalize_text {
Subroutine _normalize_text: called CC=2 SCAR=7.0
1107 90 my ( $text ) = @_;
1108 90 ▶ defined $text
Branch: 1 branch
BranchTrueFalseTotal
defined $text or $text = "" 90 0 90
1109 or $text = '';
1110 90 $text =~ s/ \A \s+ //smx;
1111 90 $text =~ s/ \s+ \z //smx;
1112 90 $text =~ s/ \s+ / /smxg;
1113 90 return $text;
1114 }
1115  
1116 261 ▶sub __token_start {
Subroutine __token_start: called CC=7 SCAR=19.5
1117 261 my ( $self, $token ) = @_;
1118 261 my $attr = $self->_attr();
1119 261 ▶ if ( defined( my $line = $token->attr( 'start_line' ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = $token->attr("start_line"))) 180 81 261
1120 180 $attr->{line} = $line;
1121 }
1122 261 my $tag = $token->tag();
1123 261 ▶ if ( 'L' eq $tag ) {
Branch: 3 branches
BranchTrueFalseTotal
if ('L' eq $tag) { } 48 213 261
elsif ('X' eq $tag) { } 2 211 213
elsif ($section_tag{$tag}) { } 36 175 211
1124 48 $token->attr( line_number => $self->{My_Parser}{line} );
1125 48 foreach my $name ( qw{ section to } ) {
1126 96 ▶ my $sect = $token->attr( $name )
Branch: 1 branch
BranchTrueFalseTotal
my $sect = $token->attr($name) or next 54 42 96
1127 or next;
1128 54 my $norm = _normalize_text( "$sect" );
1129 54 splice @{ $sect }, 2;
1130 54 push @{ $sect }, $norm;
1131 }
1132 48 push @{ $attr->{links} }, [ @{ $token }[ 1 .. $#$token ] ];
1133 } elsif ( 'X' eq $tag ) {
1134 2 push @{ $attr->{ignore_tag} }, $tag;
1135 } elsif ( $section_tag{$tag} ) {
1136 36 $attr->{text} = '';
1137 }
1138 261 return;
1139 }
1140  
1141 269 ▶sub __token_text {
Subroutine __token_text: called CC=2 SCAR=6.9
1142 269 my ( $self, $token ) = @_;
1143 269 my $attr = $self->_attr();
1144 269 ▶ return if @{ $attr->{ignore_tag} };
Branch: 1 branch
BranchTrueFalseTotal
if @{$attr->{"ignore_tag"};} 2 267 269
1145 267 my $text = $token->text();
1146 267 $attr->{line} += $text =~ tr/\n//;
1147 267 $attr->{text} .= $text;
1148 267 return;
1149 }
1150  
1151 261 ▶sub __token_end {
Subroutine __token_end: called CC=4 SCAR=13.9
1152 261 my ( $self, $token ) = @_;
1153 261 my $attr = $self->_attr();
1154 261 my $tag = $token->tag();
1155 261 ▶ if ( $section_tag{$tag} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($section_tag{$tag}) { } 36 225 261
elsif (@{$attr->{'ignore_tag'};} and $tag eq $attr->{'ignore_tag'}[-1]) { } 2 446 448
1156 36 $attr->{sections}{ _normalize_text( delete $attr->{text} ) } = 1;
1157 225 ▶ } elsif( @{ $attr->{ignore_tag} } && $tag eq $attr->{ignore_tag}[-1] ) {
Condition66%2/3
@{$attr->{"ignore_tag"};} and $tag eq $attr->{"ignore_tag"}[-1]
!ll&&!rl&&r
22302
MC/DC50%1/2
@{$attr->{"ignore_tag"};} and $tag eq $attr->{"ignore_tag"}[-1]
@{$attr->{"ignore_tag"};} $tag eq $attr->{"ignore_tag"}[-1]
Truth table66%2/3
A and B
A= @{$attr->{"ignore_tag"};}B= $tag eq $attr->{"ignore_tag"}[-1]
ABresult
0X0
100
111
1158 2 pop @{ $attr->{ignore_tag} };
1159 }
1160 261 return;
1161 }
1162  
1163 2 1;
1164  
1165 __END__
↑ Summary