Kavorka/TraitFor/Sub/fresh.pm

filter: Statementstmt 100% 41 / 41 Branchbran 71.4% 10 / 14 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 91.4% 64 / 70 CC 9 SCAR 14.7
CC
9
Cov
91%
__ANON__
8.2
__ANON__
2.1
BEGIN
1.0
CRAP 4.3
« Kavorka/MethodModifier.pm ↑ Summary Kavorka/TraitFor/Parameter/locked.pm »
1 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Kavorka::TraitFor::Sub::fresh;
6  
7 1 our $AUTHORITY = 'cpan:TOBYINK';
8 1 our $VERSION = '0.039';
9  
10 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Types::Standard qw(Any);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Sub::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 3 ▶my $stash_name = sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
17 3 ▶ Sub::Util::subname($_[0]) =~ m/^(.+)::(.+?)$/ ? $1 : undef;
Branch: 1 branch
BranchTrueFalseTotal
Sub::Util::subname($_[0]) =~ /^(.+)::(.+?)$/u ? : 3 0 3
18 1 };
19  
20 before install_sub => sub
21 4 ▶{
Subroutine __ANON__: called CC=8 SCAR=21.1
22 4 my $self = shift;
23
24 4 ▶ croak("The 'fresh' trait cannot be applied to lexical methods")
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_lexical 0 4 4
25 if $self->is_lexical;
26
27 4 ▶ croak("The 'fresh' trait cannot be applied to anonymous methods")
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_anonymous 0 4 4
28 if $self->is_anonymous;
29
30 4 ▶ croak("The 'fresh' trait may only be applied to methods")
Branch: 1 branch
BranchTrueFalseTotal
if $self->invocation_style ne "method" 0 4 4
31 if $self->invocation_style ne 'method';
32
33 4 my ($pkg, $name) = ($self->qualified_name =~ /^(.+)::(\w+)$/);
34 4 ▶ my $existing = $pkg->can($name) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $existing = $pkg->can($name) or return 3 1 4
35 3 my $existing_source = $stash_name->($existing);
36
37 3 ▶ if ($pkg->isa($existing_source) or $existing_source eq 'UNIVERSAL')
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg->isa($existing_source) or $existing_source eq "UNIVERSAL") 1 2 3
Condition66%2/3
$pkg->isa($existing_source) or $existing_source eq "UNIVERSAL"
l!l&&r!l&&!r
102
MC/DC50%1/2
$pkg->isa($existing_source) or $existing_source eq "UNIVERSAL"
$pkg->isa($existing_source) $existing_source eq "UNIVERSAL"
Truth table66%2/3
A or B
A= $pkg->isa($existing_source)B= $existing_source eq "UNIVERSAL"
ABresult
1X1
011
000
38 {
39 1 croak("Method '$name' is inherited from '$existing_source'; not fresh");
40 }
41
42 2 ▶ if ($pkg->DOES($existing_source))
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg->DOES($existing_source)) 1 1 2
43 {
44 1 croak("Method '$name' is provided by role '$existing_source'; not fresh");
45 }
46
47 1 croak("Method '$name' already exists in inheritance hierarchy; possible namespace pollution; not fresh");
48 1 };
49  
50 1 1;
« Kavorka/MethodModifier.pm ↑ Summary Kavorka/TraitFor/Parameter/locked.pm »