FindApp/Utils/Debug.pm

filter: Statementstmt 48.0% 75 / 156 Branchbran 12.9% 7 / 54 Conditioncond 7.8% 3 / 38 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 58.0% 18 / 31 Podpod 100% 10 / 10 totaltotal 36.1% 113 / 313 CC 44 SCAR 21.4
CC
44
Cov
34%
ENTER_TRACE_1
12.1
ENTER_TRACE_4
12.1
ENTER_TRACE_5
12.1
CRAP 8.5
« FindApp/Object/State/Group/Behavior.pm ↑ Summary FindApp/Object/Class.pm »
1 package FindApp::Utils::Debug;
2  
3 6 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 6 ▶use Carp qw(carp croak cluck confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use File::Spec qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 ▶use FindApp::Vars qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use FindApp::Utils::Assert qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 ▶use FindApp::Utils::Syntax qw( function );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use FindApp::Utils::Foreign qw( abs2rel );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use FindApp::Utils::Objects qw( class_prune );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 #################################################################
18  
19 6 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 our $VERSION = 1.0;
21 2 our @EXPORT_OK = (
22 <ENTER_TRACE{,_{1,2,3,4,5}}>,
23 qw(
24 debug
25 debugging
26 tracing
27 ),
28 );
29 2 our %EXPORT_TAGS = (
30 all => \@EXPORT_OK,
31 );
32  
33 #################################################################
34  
35 sub debug ;
36 sub debugging ;
37 sub hail_mary ;
38 sub safety_net ;
39 sub tracing ;
40  
41 sub ENTER_TRACE ;
42 sub ENTER_TRACE_1 ;
43 sub ENTER_TRACE_2 ;
44 sub ENTER_TRACE_3 ;
45 sub ENTER_TRACE_4 ;
46 sub ENTER_TRACE_5 ;
47  
48 #################################################################
49  
50 0 ▶sub tracing {
Subroutine tracing: not called CC=3 SCAR=22.6
Pod documented
51 0 ▶ my $self = shift;
Subroutine tracing: not called CC=3 SCAR=22.6
Pod documented
52 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) 0 0 0
if (@_) 0 0 0
53 0 $Tracing = shift;
54 0 ▶ safety_net($Debugging || $Tracing);
Condition0%0/6
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
l!l&&r!l&&!r
000
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
l!l&&r!l&&!r
000
MC/DC0%0/2
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
$FindApp::Utils::Debug::Debugging $FindApp::Utils::Debug::Tracing
MC/DC0%0/2
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
$FindApp::Utils::Debug::Debugging $FindApp::Utils::Debug::Tracing
Truth table0%0/3
A || B
A= $FindApp::Utils::Debug::DebuggingB= $FindApp::Utils::Debug::Tracing
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $FindApp::Utils::Debug::DebuggingB= $FindApp::Utils::Debug::Tracing
ABresult
1X1
011
000
55 }
56 0 return $Tracing;
57 }
58  
59 24 ▶sub debug {
Subroutine debug: called CC=3 SCAR=14.9
Pod documented
60 24 ▶ return unless $Debugging;
Subroutine debug: not called CC=3 SCAR=14.9
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
unless $FindApp::Utils::Debug::Debugging 24 0 24
unless $FindApp::Utils::Debug::Debugging 0 0 0
61 0 my($pack, $file, $line, $sub) = caller(0);
62 0 $file = abs2rel($file);
63 6 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 0 ▶ my $suffix = $Debugging > 1 && " at $file line $line";
Condition0%0/5
$FindApp::Utils::Debug::Debugging > 1 && " at $file line $line"
!ll
00
$FindApp::Utils::Debug::Debugging > 1 && " at $file line $line"
!ll
000
MC/DC0%0/1
$FindApp::Utils::Debug::Debugging > 1 && " at $file line $line"
$FindApp::Utils::Debug::Debugging > 1
MC/DC0%0/1
$FindApp::Utils::Debug::Debugging > 1 && " at $file line $line"
$FindApp::Utils::Debug::Debugging > 1
Truth table0%0/2
A
A= $FindApp::Utils::Debug::Debugging > 1
Aresult
00
11
Truth table0%0/2
A
A= $FindApp::Utils::Debug::Debugging > 1
Aresult
00
11
65 0 local @SIG{<__{WARN,DIE}__>};
66 0 print STDERR "@_$suffix\n";
67 }
68  
69 0 ▶sub safety_net {
Subroutine safety_net: not called CC=2 SCAR=13.0
Pod documented
70 0 ▶ my($enable) = @_;
Subroutine safety_net: not called CC=2 SCAR=13.0
Pod documented
71 0 ▶ $SIG{__DIE__} = $enable ? \&hail_mary : undef;
Branch: 2 branches
BranchTrueFalseTotal
$enable ? : 0 0 0
$enable ? : 0 0 0
72 }
73  
74 0 ▶sub debugging {
Subroutine debugging: not called CC=3 SCAR=24.8
Pod documented
75 0 ▶ my $self = shift;
Subroutine debugging: not called CC=3 SCAR=24.8
Pod documented
76 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) 0 0 0
if (@_) 0 0 0
77 0 $Debugging = shift;
78 0 ▶ safety_net($Debugging || $Tracing);
Condition0%0/6
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
l!l&&r!l&&!r
000
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
l!l&&r!l&&!r
000
MC/DC0%0/2
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
$FindApp::Utils::Debug::Debugging $FindApp::Utils::Debug::Tracing
MC/DC0%0/2
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
$FindApp::Utils::Debug::Debugging $FindApp::Utils::Debug::Tracing
Truth table0%0/3
A || B
A= $FindApp::Utils::Debug::DebuggingB= $FindApp::Utils::Debug::Tracing
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $FindApp::Utils::Debug::DebuggingB= $FindApp::Utils::Debug::Tracing
ABresult
1X1
011
000
79 }
80 0 return $Debugging;
81 }
82  
83 0 ▶sub hail_mary {
Subroutine hail_mary: not called CC=2 SCAR=17.9
Pod documented
84 0 ▶ return if $^S;
Subroutine hail_mary: not called CC=2 SCAR=17.9
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $^S 0 0 0
if $^S 0 0 0
85 0 local @SIG{<__{WARN,DIE}__>};
86 0 confess "caught exception: @_";
87 }
88  
89 #################################################################
90  
91 2 for my $func (<debugging tracing>) {
92 6 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
93 4 my $var = ucfirst $func;
94 4 ▶ $func->($$var) if $$var;
Branch: 1 branch
BranchTrueFalseTotal
if $$var 0 4 4
95 }
96  
97 2 for my $LEVEL (1 .. 5) {
98 485 ▶ function "ENTER_TRACE_${LEVEL}" => sub {
Subroutine ENTER_TRACE_5: called CC=4 SCAR=25.0
Subroutine __ANON__: called CC=4 SCAR=25.0
Subroutine ENTER_TRACE_4: called CC=4 SCAR=25.0
Subroutine ENTER_TRACE_1: not called CC=4 SCAR=25.0
99 0 ▶ return unless $Tracing && $Tracing >= $LEVEL;
Subroutine ENTER_TRACE_2: not called CC=4 SCAR=25.0
Subroutine ENTER_TRACE_4: not called CC=4 SCAR=25.0
Subroutine ENTER_TRACE_3: not called CC=4 SCAR=25.0
Branch: 8 branches
BranchTrueFalseTotal
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 485 0 485
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 1052 0 1052
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 6 6
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 0 0
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 0 0
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 0 0
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 0 0
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 0 0
Condition14%3/21
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
48500
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
105200
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
46400
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
000
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
000
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
000
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
000
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
Truth table33%1/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
100 0 my($pack, $file, $line, $sub) = caller(1);
101 0 $file = abs2rel($file);
102 6 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 0 local @SIG{<__{WARN,DIE}__>};
104 0 ▶ my @safe_args = map { defined() ? $_ : "(undef)" } @_;
Branch: 8 branches
BranchTrueFalseTotal
defined $_ ? : 0 0 0
defined $_ ? : 0 0 0
defined $_ ? : 464 0 464
defined $_ ? : 0 2 2
defined $_ ? : 0 0 0
defined $_ ? : 0 0 0
defined $_ ? : 0 0 0
defined $_ ? : 0 0 0
105 0 print STDERR class_prune "$sub @safe_args\n";
106 }
107 10 }
108  
109 2 *ENTER_TRACE = \&ENTER_TRACE_1;
110  
111 2 1;
112  
113 =encoding utf8
114  
115 =head1 NAME
116  
117 FindApp::Utils::Debug - FIXME
118  
119 =head1 SYNOPSIS
120  
121 use FindApp::Utils::Debug;
122  
123 =head1 DESCRIPTION
124  
125 =head2 Exports
126  
127 =over
128  
129 =item ENTER_TRACE
130  
131 =item ENTER_TRACE_1
132  
133 =item ENTER_TRACE_2
134  
135 =item ENTER_TRACE_3
136  
137 =item ENTER_TRACE_4
138  
139 =item ENTER_TRACE_5
140  
141 =item debug
142  
143 =item debugging
144  
145 =item hail_mary
146  
147 =item safety_net
148  
149 =item tracing
150  
151 =back
152  
153 =head1 EXAMPLES
154  
155 =head1 ENVIRONMENT
156  
157 =head1 SEE ALSO
158  
159 =over
160  
161 =item L<FindApp>
162  
163 =back
164  
165 =head1 CAVEATS AND PROVISOS
166  
167 =head1 BUGS AND LIMITATIONS
168  
169 =head1 HISTORY
170  
171 =head1 AUTHOR
172  
173 Tom Christiansen << <tchrist@perl.com> >>
174  
175 =head1 LICENCE AND COPYRIGHT
176  
177 Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>.
178 All Rights Reserved.
179  
180 This module is free software; you can redistribute it and/or
181 modify it under the same terms as Perl itself. See L<perlartistic>.
182  
183 =cut
184  
« FindApp/Object/State/Group/Behavior.pm ↑ Summary FindApp/Object/Class.pm »