Role/Scope.pm

filter: Statementstmt 94.5% 35 / 37 Branchbran 70.0% 7 / 10 Conditioncond 60.0% 3 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 50.0% 1 / 2 totaltotal 84.6% 55 / 65 CC 7 SCAR 10.6
CC
7
Cov
87%
close
5.1
DEMOLISH
3.6
BEGIN
1.0
CRAP 2.9
↑ Summary Role/Tracer.pm »
1 package OpenTracing::Role::Scope;
2  
3 10 our $VERSION = 'v0.86.1';
4  
5 10 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use MooX::Should;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use OpenTracing::Types qw/Span/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Types::Standard qw/Bool CodeRef Maybe/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 10 has span => (
13 is => 'ro',
14 should => Span,
15 reader => 'get_span',
16 );
17  
18 10 has finish_span_on_close => (
19 is => 'ro',
20 should => Bool,
21 );
22  
23 10 has closed => (
24 is => 'rwp',
25 should => Bool,
26 init_arg => undef,
27 default => !!undef,
28 );
29  
30 10 has on_close => (
31 is => 'ro',
32 should => Maybe[CodeRef],
33 predicate => 1,
34 );
35  
36 7 ▶sub close {
Subroutine close: called CC=5 SCAR=16.4
Pod documented
37 7 my $self = shift;
38
39 7 ▶ carp "Can't close an already closed scope" and return $self
Branch: 1 branch
BranchTrueFalseTotal
if $self->closed 1 6 7
Condition60%3/5
$self->closed && (carp(q[Can't close an already closed scope]) && (return $self))
!ll&&!rl&&r
610
carp("Can't close an already closed scope") and return $self
!ll
01
MC/DC0%0/2
$self->closed && (carp(q[Can't close an already closed scope]) && (return $self))
$self->closed carp("Can't close an already closed scope")
Truth table33%1/3
A && B
A= $self->closedB= carp("Can't close an already closed scope")
ABresult
0X0
100
111
40 if $self->closed;
41
42 6 $self->_set_closed( !undef );
43
44 6 ▶ $self->get_span->finish
Branch: 1 branch
BranchTrueFalseTotal
if $self->finish_span_on_close 0 6 6
45 if $self->finish_span_on_close;
46
47 6 ▶ $self->on_close->( $self )
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_on_close 1 5 6
48 if $self->has_on_close;
49
50 # return $self->get_scope_manager()->deactivate_scope( $self );
51
52 6 return $self
53
54 };
55  
56 5 ▶sub DEMOLISH {
Subroutine DEMOLISH: called CC=3 SCAR=12.7
Pod undocumented
57 5 my $self = shift;
58 5 my $in_global_destruction = shift;
59
60 5 ▶ return if $self->closed;
Branch: 1 branch
BranchTrueFalseTotal
if $self->closed 3 2 5
61
62 2 croak "Scope not programmatically closed before being demolished";
63 #
64 # below might be appreciated behaviour, but you should close yourself
65 #
66 0 ▶ $self->close( )
Branch: 1 branch
BranchTrueFalseTotal
unless $in_global_destruction 0 0 0
67 unless $in_global_destruction;
68
69 return
70 0 }
71  
72  
73  
74 10 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
75 10 ▶ use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 10 with 'OpenTracing::Interface::Scope'
77 }
78  
79  
80  
81 10 1;
↑ Summary Role/Tracer.pm »