ExceptionLocator.pm

filter: Statementstmt 80.9% 34 / 42 Branchbran 40.0% 4 / 10 Conditioncond 27.2% 3 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 64.1% 50 / 78 CC 11 SCAR 25.4
CC
11
Cov
65%
__ANON__
23.8
BEGIN
2.4
set_document_locator
2.0
CRAP 12.7
↑ Summary Chucker.pm »
1 package XML::Filter::ExceptionLocator;
2 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = '1.01';
6  
7 2 ▶use base 'XML::SAX::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # from XML::Filter::XInclude
10 1 ▶sub set_document_locator {
Subroutine set_document_locator: called CC=2 SCAR=7.0
Pod documented
11 1 my ($self, $locator) = @_;
12 1 ▶ push @{$self->{locators} ||= []}, $locator;
Condition50%1/2
$self->{"locators"} ||= []
l!l
01
MC/DC0%0/1
$self->{"locators"} ||= []
$self->{"locators"}
Truth table50%1/2
A
A= $self->{"locators"}
Aresult
11
00
13
14 1 $self->SUPER::set_document_locator($locator);
15 }
16  
17 # install handler for all SAX methods
18 2 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=8.9
19 2 for my $method (qw(start_document end_document start_element
20 end_element processing_instruction comment
21 skipped_entity ignorable_whitespace end_entity
22 start_entity entity_reference
23 s tart_cdata end_cdata)) {
24 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
25 28 my $super_meth = "SUPER::$method";
26 28 *{__PACKAGE__ . "::$method"} =
27 4 ▶ sub {
Subroutine __ANON__: called CC=9 SCAR=31.7
28 4 my $self = shift;
29  
30 # call method in expected context
31 4 my $wantarray = wantarray;
32 4 my (@ret, $ret);
33 4 ▶ if ($wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wantarray) { } 0 4 4
34 0 eval { @ret = $self->$super_meth(@_); };
35 } else {
36 4 eval { $ret = $self->$super_meth(@_); };
37 }
38  
39 # handle errors
40 4 my $err = $@;
41 4 ▶ if ($err and ref($err) and $err->isa('XML::SAX::Exception')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($err and ref $err and $err->isa('XML::SAX::Exception')) { } 0 4 4
elsif ($err) { } 0 4 4
Condition33%2/6
$err and ref $err and $err->isa("XML::SAX::Exception")
!ll&&!rl&&r
400
$err and ref $err
!ll&&!rl&&r
400
MC/DC0%0/3
$err and ref $err and $err->isa("XML::SAX::Exception")
$err ref $err $err->isa("XML::SAX::Exception")
Truth table25%1/4
A and B and C
A= $errB= ref $errC= $err->isa("XML::SAX::Exception")
ABCresult
0XX0
10X0
1100
1111
42 # it's showtime, add in Line/Col
43 0 ▶ if ($self->{locators} and @{$self->{locators}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"locators"} and @{$self->{"locators"};}) 0 0 0
Condition0%0/3
$self->{"locators"} and @{$self->{"locators"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"locators"} and @{$self->{"locators"};}
$self->{"locators"} @{$self->{"locators"};}
Truth table0%0/3
A and B
A= $self->{"locators"}B= @{$self->{"locators"};}
ABresult
0X0
100
111
44 0 $err->{LineNumber} = $self->{locators}[-1]->{LineNumber};
45 0 $err->{ColumnNumber} = $self->{locators}[-1]->{ColumnNumber};
46 }
47 0 die $err;
48 } elsif ($err) {
49 0 die $err;
50 }
51  
52 4 ▶ return @ret if $wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if $wantarray 0 4 4
53 4 return $ret;
54 }
55 28 }
56 }
57  
58 2 1;
59 __END__
↑ Summary Chucker.pm »