blib/lib/DB/Skip.pm

filter: Statementstmt 25.0% 13 / 52 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 50.0% 3 / 6 Podpod 100% 1 / 1 totaltotal 16.6% 17 / 102 CC 19 SCAR 46.8
CC
19
Cov
15%
__ANON__
182.0
import
36.3
old_db
6.0
CRAP 108.3
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package DB::Skip;
5  
6 # ABSTRACT: make the perl debugger skip statements in given packages or subs
7 1 our $VERSION = '1.132980'; # VERSION
8  
9  
10 {
11 1 my $old_db;
12  
13 0 ▶ sub old_db {
Subroutine old_db: not called CC=2 SCAR=17.9
Pod documented
14 0 my ( $class, $ref ) = @_;
15 0 ▶ $old_db = $ref if $ref;
Branch: 1 branch
BranchTrueFalseTotal
if $ref 0 0 0
16 0 return $old_db;
17 }
18 }
19  
20 1 ▶sub import {
Subroutine import: not called CC=6 SCAR=35.9
21 0 my ( $class, %opts ) = @_;
22  
23 0 ▶ $opts{$_} ||= [] for qw( pkgs subs );
Condition0%0/2
$opts{$_} ||= []
l!l
00
MC/DC0%0/1
$opts{$_} ||= []
$opts{$_}
Truth table0%0/2
A
A= $opts{$_}
Aresult
11
00
24  
25 0 ▶ my @pkg_regex = grep { ref and ref eq "Regexp" } @{ $opts{pkgs} };
Condition0%0/3
ref $_ && ref $_ eq 'Regexp'
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ && ref $_ eq 'Regexp'
ref $_ ref $_ eq 'Regexp'
Truth table0%0/3
A && B
A= ref $_B= ref $_ eq 'Regexp'
ABresult
0X0
100
111
26 0 ▶ my @sub_regex = grep { ref and ref eq "Regexp" } @{ $opts{subs} };
Condition0%0/3
ref $_ && ref $_ eq 'Regexp'
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ && ref $_ eq 'Regexp'
ref $_ ref $_ eq 'Regexp'
Truth table0%0/3
A && B
A= ref $_B= ref $_ eq 'Regexp'
ABresult
0X0
100
111
27  
28 0 my %pkg_skip = map { $_ => 1 } grep { !ref } @{ $opts{pkgs} };
29 0 my %sub_skip = map { $_ => 1 } grep { !ref } @{ $opts{subs} };
30  
31 0 ▶ $class->old_db( \&DB::DB ) if !$class->old_db;
Branch: 1 branch
BranchTrueFalseTotal
unless $class->old_db 0 0 0
32  
33 0 ▶ my $new_DB = sub {
Subroutine __ANON__: not called CC=13 SCAR=52.0
34 0 my $lvl = 0;
35 0 ▶ while ( my ( $pkg ) = caller( $lvl++ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($pkg) = caller $lvl++) 0 0 0
36 0 ▶ return if $pkg eq "DB" or $pkg =~ /^DB::/;
Branch: 1 branch
BranchTrueFalseTotal
if $pkg eq "DB" or $pkg =~ /^DB::/ 0 0 0
Condition0%0/3
$pkg eq "DB" or $pkg =~ /^DB::/
l!l&&r!l&&!r
000
MC/DC0%0/2
$pkg eq "DB" or $pkg =~ /^DB::/
$pkg eq "DB" $pkg =~ /^DB::/
Truth table0%0/3
A or B
A= $pkg eq "DB"B= $pkg =~ /^DB::/
ABresult
1X1
011
000
37 }
38  
39 0 my ( $pkg ) = caller;
40 0 ▶ return if $pkg_skip{$pkg};
Branch: 1 branch
BranchTrueFalseTotal
if $pkg_skip{$pkg} 0 0 0
41  
42 0 my ( undef, undef, undef, $sub ) = caller( 1 );
43 0 ▶ return if $sub and $sub_skip{$sub};
Branch: 1 branch
BranchTrueFalseTotal
if $sub and $sub_skip{$sub} 0 0 0
Condition0%0/3
$sub and $sub_skip{$sub}
!ll&&!rl&&r
000
MC/DC0%0/2
$sub and $sub_skip{$sub}
$sub $sub_skip{$sub}
Truth table0%0/3
A and B
A= $subB= $sub_skip{$sub}
ABresult
0X0
100
111
44  
45 0 for my $pkg_re ( @pkg_regex ) {
46 0 ▶ next if !$pkg_re;
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg_re 0 0 0
47 0 ▶ return if $pkg =~ $pkg_re;
Branch: 1 branch
BranchTrueFalseTotal
if $pkg =~ /$pkg_re/ 0 0 0
48 }
49  
50 0 for my $sub_re ( @sub_regex ) {
51 0 ▶ next if !$sub_re;
Branch: 1 branch
BranchTrueFalseTotal
unless $sub_re 0 0 0
52 0 ▶ return if $sub =~ $sub_re;
Branch: 1 branch
BranchTrueFalseTotal
if $sub =~ /$sub_re/ 0 0 0
53 }
54  
55 0 goto &{ $class->old_db };
56 0 };
57  
58 {
59 0 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.2
60 0 *DB::DB = $new_DB;
61 }
62  
63 0 return;
64 }
65  
66 1 1;
67  
68 __END__
↑ Summary