blib/lib/Acme/AtIncPolice.pm

filter: Statementstmt 77.2% 68 / 88 Branchbran 40.6% 26 / 64 Conditioncond 11.5% 3 / 26 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 52.4% 107 / 204 CC 44 SCAR 43.7
CC
44
Cov
54%
__ANON__
109.0
__ANON__
86.8
__ANON__
3.0
CRAP 79.1
↑ Summary Build »
1 package Acme::AtIncPolice;
2 2 ▶use 5.008001;
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 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = "0.01";
8  
9 BEGIN {
10 2 ▶ use Tie::Trace qw/watch/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 *Tie::Trace::_output_message = sub {
14 2 ▶ my ($self, $class, $value, $args) = @_;
Subroutine __ANON__: called CC=23 SCAR=44.6
15 2 ▶ if (!$value) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value) 1 1 2
16 1 return;
17 }
18  
19 1 my ($msg, @msg) = ('');
20  
21 1 my $caller = $self->{options}->{caller};
22 1 my $_caller_n = 1;
23 1 ▶ while (my $c = (caller $_caller_n)[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = (caller $_caller_n)[0]) 3 0 3
24 3 ▶ if (not $c) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $c) { } 0 3 3
elsif (not $c =~ /^Tie::Trace/) { } 1 2 3
25 0 last;
26 } elsif ($c !~ /^Tie::Trace/) {
27 1 last;
28 }
29 2 $_caller_n++;
30 }
31  
32 1 ▶ my @caller = map $_ + $_caller_n, ref $caller ? @{$caller} : $caller;
Branch: 1 branch
BranchTrueFalseTotal
ref $caller ? : 0 1 1
33 1 my(@filename, @line);
34 1 foreach(@caller){
35 1 my($f, $l) = (caller($_))[1, 2];
36 1 ▶ next unless $f and $l;
Branch: 1 branch
BranchTrueFalseTotal
unless $f and $l 0 1 1
Condition33%1/3
$f and $l
!ll&&!rl&&r
001
MC/DC0%0/2
$f and $l
$f $l
Truth table33%1/3
A and B
A= $fB= $l
ABresult
0X0
100
111
37  
38 1 push @filename, $f;
39 1 push @line, $l;
40  
41 }
42  
43 1 ▶ my $location = @line == 1 ? " at $filename[0] line $line[0]." :
Branch: 1 branch
BranchTrueFalseTotal
@line == 1 ? : 1 0 1
44 join "\n", map " at $filename[$_] line $line[$_].", (0 .. $#filename);
45 1 my($_p, $p) = ($self, $self->parent);
46 1 ▶ while($p){
Branch: 1 branch
BranchTrueFalseTotal
if ($p) 0 1 1
47 0 my $s_type = ref $p->{storage};
48 0 my $s = $p->{storage};
49 0 ▶ if($s_type eq 'HASH'){
Branch: 2 branches
BranchTrueFalseTotal
if ($s_type eq 'HASH') { } 0 0 0
elsif ($s_type eq 'ARRAY') { } 0 0 0
50 0 push @msg, "{$_p->{__key}}";
51 }elsif($s_type eq 'ARRAY'){
52 0 push @msg, "[$_p->{__point}]";
53 }
54 0 $_p = $p;
55 0 ▶ last if ! ref $p or ! ($p = $p->parent);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p and $p = $p->parent 0 0 0
Condition0%0/3
ref $p and $p = $p->parent
!ll&&!rl&&r
000
MC/DC0%0/2
ref $p and $p = $p->parent
ref $p $p = $p->parent
Truth table0%0/3
A and B
A= ref $pB= $p = $p->parent
ABresult
0X0
100
111
56 }
57 1 ▶ $msg = @msg > 0 ? ' => ' . join "", reverse @msg : "";
Branch: 1 branch
BranchTrueFalseTotal
@msg > 0 ? : 0 1 1
58  
59  
60 1 ▶ $value = '' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 1 1
61 1 ▶ if ($class eq 'Scalar') {
Branch: 3 branches
BranchTrueFalseTotal
if ($class eq 'Scalar') { } 0 1 1
elsif ($class eq 'Array') { } 1 0 1
elsif ($class eq 'Hash') { } 0 0 0
62 0 return("${msg} => $value$location");
63 } elsif ($class eq 'Array') {
64 1 ▶ unless(defined $args->{point}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{'point'}) { } 0 1 1
65 1 $msg =~ s/^( => )(.+)$/$1\@\{$2\}/;
66 1 return("$msg => $value$location");
67 }else{
68 0 return("${msg}[$args->{point}] => $value$location");
69 }
70 } elsif ($class eq 'Hash') {
71 0 ▶ return("${msg}" . (! $self->{options}->{pkg} || @msg ? "" : " => "). "{$args->{key}} => $value$location");
Branch: 1 branch
BranchTrueFalseTotal
!$self->{'options'}{'pkg'} || @msg ? : 0 0 0
Condition0%0/3
not $self->{"options"}{"pkg"} or @msg
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->{"options"}{"pkg"} or @msg
not $self->{"options"}{"pkg"} @msg
Truth table0%0/3
not(A) or B
A= not $self->{"options"}{"pkg"}B= @msg
ABresult
1X1
011
000
72 }
73 2 ▶ };
Subroutine BEGIN: called CC=1 SCAR=1.4
74  
75  
76 *Tie::Trace::_carpit = sub {
77 2 ▶ my ($self, %args) = @_;
Subroutine __ANON__: called CC=20 SCAR=46.9
78 2 ▶ return if $Tie::Trace::QUIET;
Branch: 1 branch
BranchTrueFalseTotal
if $Tie::Trace::QUIET 0 2 2
79
80 2 my $class = (split /::/, ref $self)[2];
81 2 ▶ my $op = $self->{options} || {};
Condition50%1/2
$self->{'options'} || {}
l!l
20
MC/DC0%0/1
$self->{'options'} || {}
$self->{'options'}
Truth table50%1/2
A
A= $self->{'options'}
Aresult
11
00
82
83 # key/value checking
84 2 ▶ if ($op->{key} or $op->{value}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->{"key"} or $op->{"value"}) 0 2 2
Condition33%1/3
$op->{"key"} or $op->{"value"}
l!l&&r!l&&!r
002
MC/DC0%0/2
$op->{"key"} or $op->{"value"}
$op->{"key"} $op->{"value"}
Truth table33%1/3
A or B
A= $op->{"key"}B= $op->{"value"}
ABresult
1X1
011
000
85 0 my $key = $self->_matching($self->{options}->{key}, $args{key});
86 0 my $value = $self->_matching($self->{options}->{value}, $args{value});
87 0 ▶ if (($args{key} and $op->{key}) and $op->{value}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($args{'key'} and $op->{'key'} and $op->{'value'}) { } 0 0 0
elsif ($args{'key'} and $op->{'key'}) { } 0 0 0
elsif ($op->{'value'}) { } 0 0 0
Condition0%0/6
$args{"key"} and $op->{"key"} and $op->{"value"}
!ll&&!rl&&r
000
$args{"key"} and $op->{"key"}
!ll&&!rl&&r
000
MC/DC0%0/3
$args{"key"} and $op->{"key"} and $op->{"value"}
$args{"key"} $op->{"key"} $op->{"value"}
Truth table0%0/4
A and B and C
A= $args{"key"}B= $op->{"key"}C= $op->{"value"}
ABCresult
0XX0
10X0
1100
1111
88 0 ▶ return unless $key or $value;
Branch: 1 branch
BranchTrueFalseTotal
unless $key or $value 0 0 0
Condition0%0/3
$key or $value
l!l&&r!l&&!r
000
MC/DC0%0/2
$key or $value
$key $value
Truth table0%0/3
A or B
A= $keyB= $value
ABresult
1X1
011
000
89 ▶ } elsif($args{key} and $op->{key}) {
Condition0%0/3
$args{"key"} and $op->{"key"}
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"key"} and $op->{"key"}
$args{"key"} $op->{"key"}
Truth table0%0/3
A and B
A= $args{"key"}B= $op->{"key"}
ABresult
0X0
100
111
90 0 ▶ return unless $key;
Branch: 1 branch
BranchTrueFalseTotal
unless $key 0 0 0
91 } elsif($op->{value}) {
92 0 ▶ return unless $value;
Branch: 1 branch
BranchTrueFalseTotal
unless $value 0 0 0
93 }
94 }
95
96 # debug type
97 2 my $value = $self->_debug_message($args{value}, $op->{debug}, $args{filter});
98 # debug_value checking
99 2 ▶ return unless $self->_matching($self->{options}->{debug_value}, $value);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_matching($self->{"options"}{"debug_value"}, $value) 0 2 2
100 # use scalar/array/hash ?
101 2 ▶ return unless grep lc($class) eq lc($_) , @{$op->{use}};
Branch: 1 branch
BranchTrueFalseTotal
unless grep((lc $class eq lc $_), @{$$op{"use"};}) 0 2 2
102 # create warning message
103 2 my $watch_msg = '';
104 2 my $msg = $self->_output_message($class, $value, \%args);
105 2 ▶ if(defined $self->{options}->{pkg}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'options'}{'pkg'}) { } 0 2 2
106 0 $watch_msg = sprintf("%s:: %s", @{$self->{options}}{qw/pkg var/});
107 } else {
108 2 ▶ $msg =~ s/^ => // if $msg;
Branch: 1 branch
BranchTrueFalseTotal
if $msg 1 1 2
109 }
110 2 ▶ if ($msg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($msg) 1 1 2
111 1 croak $watch_msg . $msg . "\n";
112 }
113 2 };
114  
115 watch @INC, (
116 debug => sub {
117 2 ▶ my ($self, $things) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
118 2 for my $thing (@$things) {
119 2 my $ref = ref($thing);
120 2 ▶ if ($ref) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref) 1 1 2
121 1 return "Acme::AtIncPolice does not allow contamination of \@INC";
122 }
123 }
124 },
125 2 r => 0,
126 );
127 };
128  
129  
130 2 1;
131 __END__
↑ Summary Build »