IsDev/Result.pm

filter: Statementstmt 91.4% 43 / 47 Branchbran 58.3% 7 / 12 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 90.9% 10 / 11 Podpod 100% 2 / 2 totaltotal 84.0% 63 / 75 CC 8 SCAR 10.8
CC
8
Cov
84%
add_reason
5.2
BUILD
4.3
_croak
2.0
CRAP 2.9
« IsDev/Role/Matcher/Child/Exists/Any.pm ↑ Summary IsDev.pm »
1 12 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Path::IsDev::Result;
7  
8 12 our $VERSION = '1.001003';
9  
10 # ABSTRACT: Result container
11  
12 12 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44 12 ▶use Class::Tiny 'path', 'result', { reasons => sub { [] }, };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
45  
46 2 ▶sub _path { require Path::Tiny; goto &Path::Tiny::path }
Subroutine _path: called CC=1 SCAR=0.0
47 0 ▶sub _croak { require Carp; goto &Carp::croak }
Subroutine _croak: not called CC=1 SCAR=6.9
48 ## no critic (Subroutines::ProhibitCallsToUnexportedSubs)
49 216 ▶sub _debug { require Path::IsDev; shift; goto &Path::IsDev::debug }
Subroutine _debug: called CC=1 SCAR=0.0
50  
51  
52  
53  
54  
55 16 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=14.6
Pod documented
56 16 my ( $self, ) = @_;
57 16 ▶ if ( not $self->path ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->path) 0 16 16
58 0 return _croak(q[<path> is a mandatory parameter]);
59 }
60 16 ▶ if ( not ref $self->path ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self->path) 2 14 16
61 2 $self->path( _path( $self->path ) );
62 }
63 16 ▶ if ( not -e $self->path ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $self->path) 0 16 16
64 0 return _croak(q[<path> parameter must exist for heuristics to be performed]);
65 }
66 16 $self->path( $self->path->absolute );
67 16 return $self;
68 }
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101 216 ▶sub add_reason {
Subroutine add_reason: called CC=5 SCAR=16.4
Pod documented
102 216 my ( $self, $heuristic_name, $heuristic_result, $summary, $context ) = @_;
103 216 my $name = $heuristic_name;
104 216 ▶ if ( $name->can('name') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name->can("name")) 216 0 216
105 216 $name = $name->name;
106 }
107 216 $self->_debug("$name => $heuristic_result : $summary ");
108  
109 # $self->_debug( " > " . $_) for _pp($context);
110 216 my ($heuristic_type);
111  
112 216 ▶ if ( $heuristic_name->can(q[heuristic_type]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($heuristic_name->can("heuristic_type")) 216 0 216
113 216 $heuristic_type = $heuristic_name->heuristic_type;
114 }
115  
116 my $reason = {
117 heuristic => $heuristic_name,
118 result => $heuristic_result,
119 ( defined $heuristic_type ? ( type => $heuristic_type ) : () ),
120 216 ▶ %{ $context || {} },
Branch: 1 branch
BranchTrueFalseTotal
defined $heuristic_type ? : 216 0 216
Condition50%1/2
$context || {}
l!l
2160
MC/DC0%0/1
$context || {}
$context
Truth table50%1/2
A
A= $context
Aresult
11
00
121 };
122 216 push @{ $self->reasons }, $reason;
123 216 return $self;
124 }
125  
126 12 1;
127  
128 __END__
« IsDev/Role/Matcher/Child/Exists/Any.pm ↑ Summary IsDev.pm »