DBIx/Class/Carp.pm

filter: Statementstmt 98.1% 53 / 54 Branchbran 96.4% 27 / 28 Conditioncond 86.9% 20 / 23 MC/DCmcdc 41.6% 5 / 12 Subroutinesub 90.9% 10 / 11 Podpod n/a totaltotal 89.8% 115 / 128 CC 23 SCAR 23.7
CC
23
Cov
95%
__find_caller
18.1
__ANON__
3.0
import
2.0
CRAP 10.7
« DBIx/Class/Relationship/ManyToMany.pm ↑ Summary DBIx/Class/Storage/DBI/InterBase.pm »
1 package # hide from pause
2 DBIx::Class::Carp;
3  
4 390 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 390 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # load Carp early to prevent tickling of the ::Internal stash being
8 # interpreted as "Carp is already loaded" by some braindead loader
9 390 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 390 $Carp::Internal{ (__PACKAGE__) }++;
11  
12 3348 ▶sub __find_caller {
Subroutine __find_caller: called CC=18 SCAR=28.9
13 3348 my ($skip_pattern, $class) = @_;
14  
15 3348 ▶ my $skip_class_data = $class->_skip_namespace_frames
Branch: 1 branch
BranchTrueFalseTotal
if $class and $class->can("_skip_namespace_frames") 3313 35 3348
Condition66%2/3
$class and $class->can("_skip_namespace_frames")
!ll&&!rl&&r
0353313
MC/DC50%1/2
$class and $class->can("_skip_namespace_frames")
$class $class->can("_skip_namespace_frames")
Truth table66%2/3
A and B
A= $classB= $class->can("_skip_namespace_frames")
ABresult
0X0
100
111
16 if ($class and $class->can('_skip_namespace_frames'));
17  
18 3348 ▶ $skip_pattern = qr/$skip_pattern|$skip_class_data/
Branch: 1 branch
BranchTrueFalseTotal
if $skip_class_data 3313 35 3348
19 if $skip_class_data;
20  
21 3348 my $fr_num = 1; # skip us and the calling carp*
22  
23 3348 my (@f, $origin);
24 3348 ▶ while (@f = caller($fr_num++)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@f = caller $fr_num++) 35849 11 35860
25  
26 next if
27 35849 ▶ ( $f[3] eq '(eval)' or $f[3] =~ /::__ANON__$/ );
Branch: 1 branch
BranchTrueFalseTotal
if $f[3] eq "(eval)" or $f[3] =~ /::__ANON__$/ 4078 31771 35849
Condition100%3/3
$f[3] eq "(eval)" or $f[3] =~ /::__ANON__$/
l!l&&r!l&&!r
2515156331771
MC/DC100%2/2
$f[3] eq "(eval)" or $f[3] =~ /::__ANON__$/
$f[3] eq "(eval)" $f[3] =~ /::__ANON__$/
Truth table100%3/3
A or B
A= $f[3] eq "(eval)"B= $f[3] =~ /::__ANON__$/
ABresult
1X1
011
000
28  
29 $origin ||= (
30 $f[3] =~ /^ (.+) :: ([^\:]+) $/x
31 and
32 31771 ▶ ! $Carp::Internal{$1}
Branch: 1 branch
BranchTrueFalseTotal
$f[3] =~ /^ (.+) :: ([^\:]+) $/x && !$Carp::Internal{$1} && !($1 =~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/x) && !($2 =~ /^(?: throw_exception | carp | carp_unique | carp_once | dbh_do | txn_do | with_deferred_fk_checks)$/x) ? : 3156 9635 12791
Condition91%11/12
$origin ||= $f[3] =~ /^ (.+) :: ([^\:]+) $/x && !$Carp::Internal{$1} && !($1 =~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/x) && !($2 =~ /^(?: throw_exception | carp | carp_unique | carp_once | dbh_do | txn_do | with_deferred_fk_checks)$/x) ? $f[3] : undef
l!l&&r!l&&!r
1898031569635
$f[3] =~ /^ (.+) :: ([^\:]+) $/x and not $Carp::Internal{$1} and not $1 =~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/x and not $2 =~ /^(?: throw_exception | carp | carp_unique | carp_once | dbh_do | txn_do | with_deferred_fk_checks)$/x
!ll&&!rl&&r
355660793156
$f[3] =~ /^ (.+) :: ([^\:]+) $/x and not $Carp::Internal{$1} and not $1 =~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/x
!ll&&!rl&&r
31144429235
$f[3] =~ /^ (.+) :: ([^\:]+) $/x and not $Carp::Internal{$1}
!ll&&!rl&&r
031149677
MC/DC0%0/5
$origin ||= $f[3] =~ /^ (.+) :: ([^\:]+) $/x && !$Carp::Internal{$1} && !($1 =~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/x) && !($2 =~ /^(?: throw_exception | carp | carp_unique | carp_once | dbh_do | txn_do | with_deferred_fk_checks)$/x) ? $f[3] : undef
$origin $f[3] =~ /^ (.+) :: ([^\:]+) $/x not $Carp::Internal{$1} not $1 =~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/x not $2 =~ /^(?: throw_exception | carp | carp_unique | carp_once | dbh_do | txn_do | with_deferred_fk_checks)$/x
Truth table0%0/6
A ||= B and not(C) and not(D) and not(E)
A= $originB= $f[3] =~ /^ (.+) :: ([^\:]+) $/xC= not $Carp::Internal{$1}D= not $1 =~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/xE= not $2 =~ /^(?: throw_exception | carp | carp_unique | carp_once | dbh_do | txn_do | with_deferred_fk_checks)$/x
ABCDEresult
1XXXX1
011111
00XXX0
010XX0
0110X0
011100
33 and
34 #############################
35 # Need a way to parameterize this for Carp::Skip
36 $1 !~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/x
37 and
38 $2 !~ /^(?: throw_exception | carp | carp_unique | carp_once | dbh_do | txn_do | with_deferred_fk_checks)$/x
39 #############################
40 ) ? $f[3] : undef;
41  
42 31771 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($f[0]->can("_skip_namespace_frames") and my $extra_skip = $f[0]->_skip_namespace_frames) 21798 9973 31771
Condition66%2/3
$f[0]->can("_skip_namespace_frames") and my $extra_skip = $f[0]->_skip_namespace_frames
!ll&&!rl&&r
9973021798
MC/DC50%1/2
$f[0]->can("_skip_namespace_frames") and my $extra_skip = $f[0]->_skip_namespace_frames
$f[0]->can("_skip_namespace_frames") my $extra_skip = $f[0]->_skip_namespace_frames
Truth table66%2/3
A and B
A= $f[0]->can("_skip_namespace_frames")B= my $extra_skip = $f[0]->_skip_namespace_frames
ABresult
0X0
100
111
43 $f[0]->can('_skip_namespace_frames')
44 and
45 my $extra_skip = $f[0]->_skip_namespace_frames
46 ) {
47 21798 $skip_pattern = qr/$skip_pattern|$extra_skip/;
48 }
49  
50 31771 ▶ last if $f[0] !~ $skip_pattern;
Branch: 1 branch
BranchTrueFalseTotal
unless $f[0] =~ /$skip_pattern/x 3337 28434 31771
51 }
52  
53 3348 ▶ my $site = @f # if empty - nothing matched - full stack
Branch: 1 branch
BranchTrueFalseTotal
@f ? : 3337 11 3348
54 ? "at $f[1] line $f[2]"
55 : Carp::longmess()
56 ;
57 3348 ▶ $origin ||= '{UNKNOWN}';
Condition100%2/2
$origin ||= "{UNKNOWN}"
l!l
3156192
MC/DC100%1/1
$origin ||= "{UNKNOWN}"
$origin
Truth table100%2/2
A
A= $origin
Aresult
11
00
58  
59 return (
60 3348 ▶ $site,
Branch: 1 branch
BranchTrueFalseTotal
$origin =~ /::/ ? : 3156 192 3348
61 $origin =~ /::/ ? "$origin(): " : "$origin: ", # cargo-cult from Carp::Clan
62 );
63 };
64  
65 222 ▶my $warn = sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
66 222 my ($ln, @warn) = @_;
67 222 ▶ @warn = "Warning: something's wrong" unless @warn;
Branch: 1 branch
BranchTrueFalseTotal
unless @warn 0 222 222
68  
69 # back-compat with Carp::Clan - a warning ending with \n does
70 # not include caller info
71 222 ▶ warn (
Branch: 1 branch
BranchTrueFalseTotal
$warn[-1] =~ /\n$/ ? : 12 210 222
72 @warn,
73 $warn[-1] =~ /\n$/ ? '' : " $ln\n"
74 );
75 390 };
76  
77 6258 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
78 6258 my (undef, $skip_pattern) = @_;
79 6258 my $into = caller;
80  
81 6258 ▶ $skip_pattern = $skip_pattern
Branch: 1 branch
BranchTrueFalseTotal
$skip_pattern ? : 771 5487 6258
82 ? qr/ ^ $into $ | $skip_pattern /x
83 : qr/ ^ $into $ /x
84 ;
85  
86 390 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 6258 ▶ *{"${into}::carp"} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
89 172 $warn->(
90 __find_caller($skip_pattern, $into),
91 @_
92 );
93 6258 };
94  
95 6258 my $fired = {};
96 6258 ▶ *{"${into}::carp_once"} = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
97 13 ▶ return if $fired->{$_[0]};
Branch: 1 branch
BranchTrueFalseTotal
if $$fired{$_[0]} 4 9 13
98 9 $fired->{$_[0]} = 1;
99  
100 9 $warn->(
101 __find_caller($skip_pattern, $into),
102 @_,
103 );
104 6258 };
105  
106 6258 my $seen;
107 6258 ▶ *{"${into}::carp_unique"} = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
108 63 my ($ln, $calling) = __find_caller($skip_pattern, $into);
109 63 my $msg = join ('', $calling, @_);
110  
111 # unique carping with a hidden caller makes no sense
112 63 $msg =~ s/\n+$//;
113  
114 63 ▶ return if $seen->{$ln}{$msg};
Branch: 1 branch
BranchTrueFalseTotal
if $seen->{$ln}{$msg} 22 41 63
115 41 $seen->{$ln}{$msg} = 1;
116  
117 41 $warn->(
118 $ln,
119 $msg,
120 );
121 6258 };
122 }
123  
124 0 ▶sub unimport {
Subroutine unimport: not called CC=1 SCAR=6.9
125 0 die (__PACKAGE__ . " does not implement unimport yet\n");
126 }
127  
128 390 1;
129  
130 __END__
« DBIx/Class/Relationship/ManyToMany.pm ↑ Summary DBIx/Class/Storage/DBI/InterBase.pm »