Go/Relation/Single.pm

filter: Statementstmt 94.1% 64 / 68 Branchbran 72.2% 13 / 18 Conditioncond 62.5% 10 / 16 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 5 totaltotal 80.1% 101 / 126 CC 22 SCAR 18.7
CC
22
Cov
85%
recommended
12.2
advantage
6.0
invalid
4.6
CRAP 6.5
« Go/Relation/Dual.pm ↑ Summary Go/Skill.pm »
1 package Data::Pokemon::Go::Relation::Single;
2 7 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 with 'Data::Pokemon::Go::Role::Types';
9  
10 # accessor methods ========================================================
11  
12 7 subtype 'Types' => as 'ArrayRef[Type]';
13 coerce 'Types'
14 => from 'Type'
15 65043 ▶ => via {[$_]};
Subroutine __ANON__: called CC=1 SCAR=0.0
16 7 has types => ( is => 'ro', isa => 'Types', coerce => 1, required => 1 );
17  
18 7 __PACKAGE__->meta->make_immutable;
19 7 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 7 my $relations = $Data::Pokemon::Go::Role::Types::Relations;
22 7 my $ref_advantage = $Data::Pokemon::Go::Role::Types::Ref_Advantage;
23  
24 # subroutine ==============================================================
25  
26 46513 ▶sub effective {
Subroutine effective: called CC=3 SCAR=11.8
Pod undocumented
27 46513 my $self = shift;
28 46513 my $type = $self->types()->[0];
29 46513 my $data = $relations->{$type};
30 46513 ▶ return @{ $data->{effective} || [] } if $data->{effective};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"effective"} 46513 0 46513
Condition50%1/2
$data->{'effective'} || []
l!l
465130
MC/DC0%0/1
$data->{'effective'} || []
$data->{'effective'}
Truth table50%1/2
A
A= $data->{'effective'}
Aresult
11
00
31 0 return;
32 }
33  
34 196530 ▶sub invalid {
Subroutine invalid: called CC=4 SCAR=15.2
Pod undocumented
35 196530 my $self = shift;
36 196530 my $type = $self->types()->[0];
37 196530 my $data = $relations->{$type};
38 196530 ▶ my @list = @{ $data->{invalid} || [] };
Condition50%1/2
$data->{'invalid'} || []
l!l
1965300
MC/DC0%0/1
$data->{'invalid'} || []
$data->{'invalid'}
Truth table50%1/2
A
A= $data->{'invalid'}
Aresult
11
00
39 0 ▶ unshift @list, @{ $data->{void} } if $data->{void};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"void"} 0 196530 196530
40 196530 ▶ return @list if @list;
Branch: 1 branch
BranchTrueFalseTotal
if @list 196530 0 196530
41 0 return;
42 }
43  
44 51930 ▶sub advantage {
Subroutine advantage: called CC=6 SCAR=17.9
Pod undocumented
45 51930 my $self = shift;
46 51930 my $type = $self->types()->[0];
47 51930 my $data = $ref_advantage->{$type};
48 51930 ▶ my @list = @{ $data->{invalid} || [] };
Condition50%1/2
$data->{'invalid'} || []
l!l
519300
MC/DC0%0/1
$data->{'invalid'} || []
$data->{'invalid'}
Truth table50%1/2
A
A= $data->{'invalid'}
Aresult
11
00
49 51930 ▶ unshift @list, @{ $data->{void} || [] };
Condition100%2/2
$data->{'void'} || []
l!l
2151330417
MC/DC100%1/1
$data->{'void'} || []
$data->{'void'}
Truth table100%2/2
A
A= $data->{'void'}
Aresult
11
00
50 51930 my $i = 0;
51 51930 foreach my $value (@list) {
52 168692 foreach my $type ( $self->invalid() ){
53 640912 ▶ splice @list, $i, 1 if $type eq $value;
Branch: 1 branch
BranchTrueFalseTotal
if $type eq $value 35781 605131 640912
54 }
55 168692 $i++;
56 }
57 51930 return @list;
58 }
59  
60 51902 ▶sub disadvantage {
Subroutine disadvantage: called CC=2 SCAR=6.9
Pod undocumented
61 51902 my $self = shift;
62 51902 my $type = $self->types()->[0];
63 51902 my $data = $ref_advantage->{$type};
64 51902 ▶ return @{ $data->{effective} || [] };
Condition100%2/2
$data->{'effective'} || []
l!l
499581944
MC/DC100%1/1
$data->{'effective'} || []
$data->{'effective'}
Truth table100%2/2
A
A= $data->{'effective'}
Aresult
11
00
65 }
66  
67 752 ▶sub recommended {
Subroutine recommended: called CC=11 SCAR=25.0
Pod undocumented
68 752 my $self = shift;
69 752 my @recommended = ();
70 752 foreach my $type1 ( $self->effective() ){
71 1922 foreach my $type2 ( $self->advantage() ){
72 6568 ▶ push @recommended, $type1 if $type1 && $type2 and $type1 eq $type2;
Branch: 1 branch
BranchTrueFalseTotal
if $type1 and $type2 and $type1 eq $type2 1104 5464 6568
Condition50%3/6
$type1 and $type2 and $type1 eq $type2
!ll&&!rl&&r
054641104
$type1 and $type2
!ll&&!rl&&r
006568
MC/DC33%1/3
$type1 and $type2 and $type1 eq $type2
$type1 $type2 $type1 eq $type2
Truth table50%2/4
A and B and C
A= $type1B= $type2C= $type1 eq $type2
ABCresult
0XX0
10X0
1100
1111
73 }
74 }
75 752 ▶ return @recommended if @recommended;
Branch: 1 branch
BranchTrueFalseTotal
if @recommended 634 118 752
76  
77 118 @recommended = $self->effective(), $self->advantage();
78 118 ▶ for( my $i = 0; $i <= @recommended; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= @recommended) 236 118 354
79 236 ▶ next unless $recommended[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless $recommended[$i] 118 118 236
80 118 foreach my $type ( $self->disadvantage() ) {
81 0 ▶ splice @recommended, $i, 1 if $type eq $recommended[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $type eq $recommended[$i] 0 0 0
82 }
83 }
84 118 return @recommended;
85 }
86  
87 7 1;
88 __END__
« Go/Relation/Dual.pm ↑ Summary Go/Skill.pm »