StrictConstructor/Role/BuildAll.pm

filter: Statementstmt 100% 29 / 29 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 86.0% 37 / 43 CC 4 SCAR 9.3
CC
4
Cov
89%
__ANON__
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.5
↑ Summary StrictConstructor.pm »
1 2 ▶use strict; # redundant, but quiets perlcritic
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package MooX::StrictConstructor::Role::BuildAll;
4  
5 2 our $VERSION = '0.013';
6  
7 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 has _constructor_generator => (
10 is => 'rw',
11 weaken => 1,
12 );
13  
14 1 ▶around buildall_body_for => sub {
Subroutine __ANON__: called CC=4 SCAR=14.1
15 1 my ($orig, $self, $into, $me, $args, @extra) = @_;
16  
17 1 my $con = $self->_constructor_generator;
18 1 my $fake_BUILD = $con->can('_fake_BUILD');
19 1 my $real_build = ! do {
20 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶ defined &{"${into}::BUILD"} && \&{"${into}::BUILD"} == $fake_BUILD;
Condition33%1/3
defined &{"${into}::BUILD";} && \&{"${into}::BUILD";} == $fake_BUILD
!ll&&!rl&&r
010
MC/DC0%0/2
defined &{"${into}::BUILD";} && \&{"${into}::BUILD";} == $fake_BUILD
defined &{"${into}::BUILD";} \&{"${into}::BUILD";} == $fake_BUILD
Truth table33%1/3
A && B
A= defined &{"${into}::BUILD";}B= \&{"${into}::BUILD";} == $fake_BUILD
ABresult
0X0
100
111
22 };
23  
24 1 my $code = '';
25 1 ▶ if ($real_build) {
Branch: 1 branch
BranchTrueFalseTotal
if ($real_build) 1 0 1
26 1 $code .= $self->$orig($into, $me, $args, @extra);
27 }
28 1 ▶ my $arg = $args =~ /^\$\w+(?:\[[0-9]+\])?$/ ? $args : "($args)[0]";
Branch: 1 branch
BranchTrueFalseTotal
$args =~ /^\$\w+(?:\[[0-9]+\])?$/ ? : 1 0 1
29 1 $code .= "do {\n" . $con->_cap_call($con->_check_strict($con->all_attribute_specs, $arg)) . "},\n";
30 1 return $code;
31 2 };
32  
33 2 1;
34  
35 __END__
↑ Summary StrictConstructor.pm »