MorningMusume.pm

filter: Statementstmt 71.9% 41 / 57 Branchbran 44.4% 8 / 18 Conditioncond 83.3% 5 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 70.0% 7 / 10 Podpod 100% 4 / 4 totaltotal 68.3% 67 / 98 CC 13 SCAR 19.0
CC
13
Cov
67%
sort
12.0
select
12.0
members
8.1
CRAP 6.7
↑ Summary MorningMusume/Base.pm »
1 package Acme::MorningMusume;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our $VERSION = '0.20';
10  
11 3 my @members = qw(
12 FukudaAsuka
13 NakazawaYuko
14 IidaKaori
15 AbeNatsumi
16 IshiguroAya
17 IchiiSayaka
18 YaguchiMari
19 YasudaKei
20 GotohMaki
21 IshikawaRika
22 YoshizawaHitomi
23 TsujiNozomi
24 KagoAi
25 TakahashiAi
26 KonnoAsami
27 OgawaMakoto
28 NiigakiRisa
29 KameiEri
30 TanakaReina
31 MichishigeSayumi
32 FujimotoMiki
33 KusumiKoharu
34 MitsuiAika
35 LiChun
36 QianLin
37 SuzukiKanon
38 IkutaErina
39 FukumuraMizuki
40 SayashiRiho
41 IikuboHaruna
42 IshidaAyumi
43 SatohMasaki
44 KudohHaruka
45 OdaSakura
46 OgataHaruna
47 NonakaMiki
48 MakinoMaria
49 HagaAkane
50 );
51  
52 my @date_joined = map {
53 3 my ($year, $month, $day) = ($_ =~ /(\d{4})-(\d{2})-(\d{2})/);
54 36 DateTime->new(
55 year => $year,
56 month => $month,
57 day => $day,
58 );
59 } qw(
60 1997-09-07
61 1998-05-03
62 1999-08-04
63 2000-04-16
64 2001-08-26
65 2003-01-19
66 2005-05-01
67 2006-12-10
68 2011-01-02
69 2011-09-29
70 2012-09-14
71 2014-09-30
72 );
73 3 unshift @date_joined, undef;
74  
75 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
76 2 my $class = shift;
77 2 my $self = bless {members => []}, $class;
78  
79 2 $self->_initialize;
80  
81 2 return $self;
82 }
83  
84 5 ▶sub members {
Subroutine members: called CC=8 SCAR=20.9
Pod documented
85 5 my ($self, $type, @members) = @_;
86 5 ▶ @members = @{$self->{members}} unless @members;
Branch: 1 branch
BranchTrueFalseTotal
unless @members 5 0 5
87  
88 5 ▶ return @members unless $type;
Branch: 1 branch
BranchTrueFalseTotal
unless $type 2 3 5
89  
90 3 ▶ if ($type eq 'active') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'active') { } 1 2 3
elsif ($type eq 'graduate') { } 1 1 2
elsif ($type->isa('DateTime')) { } 1 0 1
91 1 return grep {!$_->graduate_date} @members;
92 }
93 elsif ($type eq 'graduate') {
94 1 return grep {$_->graduate_date} @members;
95 }
96 elsif ($type->isa('DateTime')) {
97 return grep {
98 1 ▶ $date_joined[$_->class] <= $type and
Condition83%5/6
$date_joined[$_->class] <= $type && (!$_->graduate_date || $type <= $_->graduate_date)
!ll&&!rl&&r
25310
not $_->graduate_date or $type <= $_->graduate_date
l!l&&r!l&&!r
0103
MC/DC66%2/3
$date_joined[$_->class] <= $type && (!$_->graduate_date || $type <= $_->graduate_date)
$date_joined[$_->class] <= $type not $_->graduate_date $type <= $_->graduate_date
Truth table75%3/4
A && not(B) or C
A= $date_joined[$_->class] <= $typeB= not $_->graduate_dateC= $type <= $_->graduate_date
ABCresult
0XX0
1000
11X1
1011
99 (!$_->graduate_date or $type <= $_->graduate_date)
100 } @members;
101 }
102 }
103  
104 0 ▶sub sort {
Subroutine sort: not called CC=3 SCAR=24.8
Pod documented
105 0 my ($self, $type, $order, @members) = @_;
106 0 ▶ @members = $self->members unless @members;
Branch: 1 branch
BranchTrueFalseTotal
unless @members 0 0 0
107  
108 # order by desc if $order is true
109 0 ▶ if ($order) {
Branch: 1 branch
BranchTrueFalseTotal
if ($order) { } 0 0 0
110 0 return sort {$b->$type <=> $a->$type} @members;
111 }
112 else {
113 0 return sort {$a->$type <=> $b->$type} @members;
114 }
115 }
116  
117 0 ▶sub select {
Subroutine select: not called CC=3 SCAR=24.8
Pod documented
118 0 my ($self, $type, $number, $operator, @members) = @_;
119  
120 $self->_die('invalid operator was passed in')
121 0 ▶ unless grep {$operator eq $_} qw(== >= <= > <);
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$operator eq $_;} "==", ">=", "<=", ">", "<" 0 0 0
122  
123 0 ▶ @members = $self->members unless @members;
Branch: 1 branch
BranchTrueFalseTotal
unless @members 0 0 0
124 0 my $compare = eval "(sub { \$number $operator \$_[0] })";
125  
126 0 return grep { $compare->($_->$type) } @members;
127 }
128  
129 2 ▶sub _initialize {
Subroutine _initialize: called CC=2 SCAR=6.9
130 2 my $self = shift;
131  
132 2 for my $member (@members) {
133 76 my $module_name = 'Acme::MorningMusume::'.$member;
134  
135 76 eval qq|require $module_name;|;
136 76 push @{$self->{members}}, $module_name->new;
137 }
138  
139 2 return 1;
140 }
141  
142 0 ▶sub _die {
Subroutine _die: not called CC=1 SCAR=6.9
143 0 my ($self, $message) = @_;
144 0 Carp::croak($message);
145 }
146  
147 3 1;
148  
149 __END__
↑ Summary MorningMusume/Base.pm »