NHANES_2000.pm

filter: Statementstmt 97.2% 70 / 72 Branchbran 96.6% 29 / 30 Conditioncond 77.7% 14 / 18 MC/DCmcdc 60.0% 6 / 10 Subroutinesub 100% 12 / 12 Podpod 100% 4 / 4 totaltotal 92.4% 135 / 146 CC 22 SCAR 25.5
CC
22
Cov
94%
measure_class_name_for
20.1
have_measure_class_for
3.0
BEGIN
1.0
CRAP 12.8
↑ Summary NHANES_2000/Base.pm »
1 #!/usr/bin/env perl
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 package Medical::Growth::NHANES_2000;
8  
9 1 our ($VERSION) = '1.10';
10  
11 1 ▶use Moo::Lax; # Vanilla Moo considered harmful
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Module::Runtime;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 use Module::Pluggable
16 1 ▶ require => 1,
Subroutine BEGIN: called CC=1 SCAR=0.0
17 search_path => 'Medical::Growth::NHANES_2000',
18 1 except => 'Medical::Growth::NHANES_2000::Base';
19  
20 1 ▶sub measure_classes {
Subroutine measure_classes: called CC=1 SCAR=0.0
Pod documented
21 1 shift->plugins;
22 }
23  
24 31 ▶sub measure_class_name_for {
Subroutine measure_class_name_for: called CC=20 SCAR=30.0
Pod documented
25 31 my ( $self, %criteria ) = @_;
26 31 my ( $measure, $norm, $ages, $sex, $class );
27  
28 31 ▶ $criteria{age_group} //= $criteria{age} if exists $criteria{age};
Branch: 1 branch
BranchTrueFalseTotal
if exists $criteria{"age"} 2 29 31
Condition33%1/3
$criteria{"age_group"} //= $criteria{"age"}
l!l&&r!l&&!r
020
MC/DC0%0/2
$criteria{"age_group"} //= $criteria{"age"}
$criteria{"age_group"} $criteria{"age"}
Truth table33%1/3
A //= B
A= $criteria{"age_group"}B= $criteria{"age"}
ABresult
1X1
011
000
29 croak('Need to specify measure, age_group, and sex')
30 unless exists $criteria{measure}
31 and exists $criteria{age_group}
32 31 ▶ and exists $criteria{sex};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $criteria{"measure"} and exists $criteria{"age_group"} and exists $criteria{"sex"} 3 28 31
Condition100%6/6
exists $criteria{"measure"} and exists $criteria{"age_group"} and exists $criteria{"sex"}
!ll&&!rl&&r
2128
exists $criteria{"measure"} and exists $criteria{"age_group"}
!ll&&!rl&&r
1129
MC/DC100%3/3
exists $criteria{"measure"} and exists $criteria{"age_group"} and exists $criteria{"sex"}
exists $criteria{"measure"} exists $criteria{"age_group"} exists $criteria{"sex"}
Truth table100%4/4
A and B and C
A= exists $criteria{"measure"}B= exists $criteria{"age_group"}C= exists $criteria{"sex"}
ABCresult
0XX0
10X0
1100
1111
33  
34 28 ▶ if ( $criteria{measure} =~ /^(\w+)(?:\s+|_)(?:for|by)(?:\s+|_)(\w+)/i
Branch: 3 branches
BranchTrueFalseTotal
if ($criteria{'measure'} =~ /^(\w+)(?:\s+|_)(?:for|by)(?:\s+|_)(\w+)/i or $criteria{'measure'} =~ /^(Head Circumference)(?:\s+|_)(?:for|by)(?:\s+|_)(Age)/i) { } 9 19 28
elsif ($criteria{'measure'} =~ /(\w+)\s+(\w+)/i) { } 2 17 19
elsif ($criteria{'measure'} =~ /^(Weight|Wg?t|Height|Hg?t|Stature|Stat|Length|Len|BMI|Head|HC|OFC) (Age|Height|Hg?t|Length|Len)/xi) { } 16 1 17
Condition100%3/3
$criteria{"measure"} =~ /^(\w+)(?:\s+|_)(?:for|by)(?:\s+|_)(\w+)/i or $criteria{"measure"} =~ /^(Head Circumference)(?:\s+|_)(?:for|by)(?:\s+|_)(Age)/i
l!l&&r!l&&!r
8119
MC/DC100%2/2
$criteria{"measure"} =~ /^(\w+)(?:\s+|_)(?:for|by)(?:\s+|_)(\w+)/i or $criteria{"measure"} =~ /^(Head Circumference)(?:\s+|_)(?:for|by)(?:\s+|_)(Age)/i
$criteria{"measure"} =~ /^(\w+)(?:\s+|_)(?:for|by)(?:\s+|_)(\w+)/i $criteria{"measure"} =~ /^(Head Circumference)(?:\s+|_)(?:for|by)(?:\s+|_)(Age)/i
Truth table100%3/3
A or B
A= $criteria{"measure"} =~ /^(\w+)(?:\s+|_)(?:for|by)(?:\s+|_)(\w+)/iB= $criteria{"measure"} =~ /^(Head Circumference)(?:\s+|_)(?:for|by)(?:\s+|_)(Age)/i
ABresult
1X1
011
000
35 or $criteria{measure} =~
36 /^(Head Circumference)(?:\s+|_)(?:for|by)(?:\s+|_)(Age)/i )
37 {
38 9 ( $measure, $norm ) = ( $1, $2 );
39 }
40 elsif ( $criteria{measure} =~ /(\w+)\s+(\w+)/i ) {
41 2 ( $measure, $norm ) = ( $1, $2 );
42 }
43 elsif (
44 $criteria{measure} =~
45 /^(Weight|Wg?t|Height|Hg?t|Stature|Stat|Length|Len|BMI|Head|HC|OFC)
46 (Age|Height|Hg?t|Length|Len)/ix
47 )
48 {
49 16 ( $measure, $norm ) = ( $1, $2 );
50 }
51 else {
52 1 croak "Don't understand measure spec '$criteria{measure}'";
53 }
54  
55 27 ▶ if ( $criteria{age_group} =~ /^(?:infant|toddler|recumbent|neonat)/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($criteria{'age_group'} =~ /^(?:infant|toddler|recumbent|neonat)/i) { } 14 13 27
elsif ($criteria{'age_group'} =~ /^(?:child|school|adol)/i) { } 10 3 13
elsif ($criteria{'age_group'} =~ /^[0-9.]+$/ and $criteria{'age_group'} eq '0' || $criteria{'age_group'} > 0) { } 2 1 3
56 14 $ages = 'Infant';
57 }
58 elsif ( $criteria{age_group} =~ /^(?:child|school|adol)/i ) {
59 10 $ages = 'Child';
60 }
61 ▶ elsif ( $criteria{age_group} =~ /^[0-9.]+$/
Condition66%4/6
$criteria{"age_group"} =~ /^[0-9.]+$/ and $criteria{"age_group"} eq 0 || $criteria{"age_group"} > 0
!ll&&!rl&&r
102
$criteria{"age_group"} eq 0 or $criteria{"age_group"} > 0
l!l&&r!l&&!r
110
MC/DC33%1/3
$criteria{"age_group"} =~ /^[0-9.]+$/ and $criteria{"age_group"} eq 0 || $criteria{"age_group"} > 0
$criteria{"age_group"} =~ /^[0-9.]+$/ $criteria{"age_group"} eq 0 $criteria{"age_group"} > 0
Truth table75%3/4
A and B or C
A= $criteria{"age_group"} =~ /^[0-9.]+$/B= $criteria{"age_group"} eq 0C= $criteria{"age_group"} > 0
ABCresult
0XX0
1000
11X1
1011
62 and ( $criteria{age_group} eq '0' or $criteria{age_group} > 0 ) )
63 {
64 2 ▶ $ages = $criteria{age_group} >= 24 ? 'Child' : 'Infant';
Branch: 1 branch
BranchTrueFalseTotal
$criteria{'age_group'} >= 24 ? : 1 1 2
65 }
66 else {
67 1 croak "Don't understand age group '$criteria{age_group}'";
68 }
69  
70 # Sigh - 5.18 makes this warn
71 1 ▶ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
Subroutine BEGIN: called CC=1 SCAR=0.0
72  
73 26 given ($measure) {
74 26 when (/^W/i) { $measure = 'Weight'; }
75 20 when (/^O|^Hea|^HC/i) { $measure = 'HC'; }
76 17 ▶ when (/^[HLS]/i) { $measure = $ages eq 'Infant' ? 'Length' : 'Height'; }
Branch: 1 branch
BranchTrueFalseTotal
$ages eq 'Infant' ? : 5 3 8
77 9 when (/^B/i) { $measure = 'BMI'; }
78 0 default {
79 0 croak "Don't understand measure name '$measure' in "
80 . "'$criteria{measure}'";
81 }
82 }
83  
84 26 given ($norm) {
85 26 when (/^A/i) { $norm = 'Age'; }
86 3 ▶ when (/^[HL]/i) { $norm = $ages eq 'Infant' ? 'Length' : 'Height'; }
Branch: 1 branch
BranchTrueFalseTotal
$ages eq 'Infant' ? : 1 1 2
87 1 default {
88 1 croak "Don't understand norm name in " . "'$criteria{measure}'";
89 }
90 }
91  
92 25 ▶ if ( $criteria{sex} =~ /^[MB1]/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($criteria{'sex'} =~ /^[MB1]/i) { } 15 10 25
elsif ($criteria{'sex'} =~ /^[FG2]/i) { } 9 1 10
93 15 $sex = 'Male';
94 }
95 elsif ( $criteria{sex} =~ /^[FG2]/i ) {
96 9 $sex = 'Female';
97 }
98 else {
99 1 croak "Don't understand sex '$criteria{sex}'";
100 }
101  
102 24 $class =
103 'Medical::Growth::NHANES_2000::'
104 . $measure . '_for_'
105 . $norm . '::'
106 . $ages . '::'
107 . $sex;
108 24 return $class;
109 }
110  
111 2 ▶sub have_measure_class_for {
Subroutine have_measure_class_for: called CC=3 SCAR=11.0
Pod documented
112 2 my $self = shift;
113 2 my $class = $self->measure_class_name_for(@_);
114 2 ▶ return unless $class; # Never happens in this class; just kind to subclasses
Branch: 1 branch
BranchTrueFalseTotal
unless $class 0 2 2
115 2 ▶ eval { Module::Runtime::use_module($class) } or undef;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { &Module::Runtime::use_module($class) } } or undef 1 1 2
116 }
117  
118 19 ▶sub measure_class_for {
Subroutine measure_class_for: called CC=1 SCAR=0.0
Pod documented
119 19 my $self = shift;
120 19 my $class = $self->measure_class_name_for(@_);
121 19 Module::Runtime::use_module($class)->new;
122 }
123  
124 1 1;
125  
126 __END__
↑ Summary NHANES_2000/Base.pm »