Tabular/Row/Function.pm

filter: Statementstmt 78.5% 55 / 70 Branchbran 73.3% 22 / 30 Conditioncond 65.0% 13 / 20 MC/DCmcdc 30.0% 3 / 10 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 5 totaltotal 69.2% 99 / 143 CC 24 SCAR 27.0
CC
24
Cov
75%
cells
20.6
extra_column
12.0
new
3.1
CRAP 14.9
« Tabular/Table/Extra.pm ↑ Summary Tabular/Config/Output.pm »
1 # Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 package
5 Data::Tabular::Row::Function;
6  
7 3 ▶use base 'Data::Tabular::Row';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use Carp qw(croak carp);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub new
12 20 ▶{
Subroutine new: called CC=3 SCAR=11.3
Pod undocumented
13 20 my $class = shift;
14 20 my $self = $class->SUPER::new(@_);
15  
16 20 ▶ die unless $self->table;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->table 0 20 20
17 20 ▶ die "Need sum_list" unless $self->{sum_list};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sum_list"} 0 20 20
18  
19 20 $self;
20 }
21  
22 sub cells
23 20 ▶{
Subroutine cells: called CC=20 SCAR=30.2
Pod undocumented
24 20 my $self = shift;
25 20 my @ret = ();
26 20 my @headers = $self->headers();
27  
28 20 my $offset = 0;
29 20 my $hash;
30 20 ▶ for my $x ( @{$self->{sum_list} || []} ) {
Condition50%1/2
$self->{'sum_list'} || []
l!l
200
MC/DC0%0/1
$self->{'sum_list'} || []
$self->{'sum_list'}
Truth table50%1/2
A
A= $self->{'sum_list'}
Aresult
11
00
31 94 $hash->{$x} = { sum => 1 };
32 }
33  
34 20 my $start;
35 20 my $x = 0;
36 20 my $state = 0;
37 20 my $cols = 1;
38 20 ▶ while (my $column_name = shift @headers) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $column_name = shift @headers) 222 20 242
39 222 ▶ if ($state == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state == 0) 30 192 222
40 30 ▶ if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($column_name and $hash->{$column_name} and $hash->{$column_name}{'sum'}) { } 10 20 30
Condition66%4/6
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
!ll&&!rl&&r
20010
$column_name and $hash->{$column_name}
!ll&&!rl&&r
02010
MC/DC33%1/3
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name $hash->{$column_name} $hash->{$column_name}{"sum"}
Truth table50%2/4
A and B and C
A= $column_nameB= $hash->{$column_name}C= $hash->{$column_name}{"sum"}
ABCresult
0XX0
10X0
1100
1111
41 10 push(@ret,
42 Data::Tabular::Cell->new(
43 row => $self,
44 cell => $column_name,
45 colspan => 1,
46 id => $x,
47 ),
48 );
49 } else {
50 20 $state++;
51 }
52 }
53 222 ▶ if ($state == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state == 1) 80 142 222
54 80 ▶ if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($column_name and $hash->{$column_name} and $hash->{$column_name}{'sum'}) { } 20 60 80
Condition66%4/6
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
!ll&&!rl&&r
60020
$column_name and $hash->{$column_name}
!ll&&!rl&&r
06020
MC/DC33%1/3
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name $hash->{$column_name} $hash->{$column_name}{"sum"}
Truth table50%2/4
A and B and C
A= $column_nameB= $hash->{$column_name}C= $hash->{$column_name}{"sum"}
ABCresult
0XX0
10X0
1100
1111
55 20 push(@ret,
56 Data::Tabular::Cell->new(
57 row => $self,
58 cell => '_description',
59 colspan => $cols - 1,
60 id => $x - ($cols - 1),
61 ),
62 );
63 20 $cols = 1;
64 20 $state++;
65 } else {
66 60 $cols++;
67 }
68 }
69 222 ▶ if ($state == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state == 2) 152 70 222
70 152 ▶ if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($column_name and $hash->{$column_name} and $hash->{$column_name}{'sum'}) { } 84 68 152
Condition66%4/6
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
!ll&&!rl&&r
68084
$column_name and $hash->{$column_name}
!ll&&!rl&&r
06884
MC/DC33%1/3
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name $hash->{$column_name} $hash->{$column_name}{"sum"}
Truth table50%2/4
A and B and C
A= $column_nameB= $hash->{$column_name}C= $hash->{$column_name}{"sum"}
ABCresult
0XX0
10X0
1100
1111
71 84 ▶ if ($cols > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cols > 1) 18 66 84
72 18 push(@ret,
73 Data::Tabular::Cell->new(
74 row => $self,
75 cell => '_filler',
76 colspan => $cols - 1,
77 id => $x,
78 ),
79 );
80 18 $cols = 1;
81 }
82 84 push(@ret,
83 Data::Tabular::Cell->new(
84 row => $self,
85 cell => $column_name,
86 colspan => $cols,
87 id => $x,
88 ),
89 );
90 84 $cols = 1;
91 } else {
92 68 $cols++;
93 }
94 }
95 222 ▶ die if ($state >= 3);
Branch: 1 branch
BranchTrueFalseTotal
if $state >= 3 0 222 222
96 222 $x++;
97 }
98 20 ▶ if ($cols > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cols > 1) 2 18 20
99 2 push(@ret,
100 Data::Tabular::Cell->new(
101 row => $self,
102 cell => '_filler',
103 colspan => $cols,
104 id => $x - 1,
105 ),
106 );
107 2 $cols = 1;
108 }
109 20 ▶die $cols if $cols > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $cols > 1 0 20 20
110 20 @ret;
111 }
112  
113 sub sum_list
114 114 ▶{
Subroutine sum_list: called CC=1 SCAR=0.0
Pod undocumented
115 114 my $self = shift;
116  
117 114 $self->{sum_list};
118 }
119  
120 sub get_column
121 0 ▶{
Subroutine get_column: not called CC=1 SCAR=6.9
Pod undocumented
122 0 die 'Virtual';
123 }
124  
125 sub extra_column
126 0 ▶{
Subroutine extra_column: not called CC=3 SCAR=24.8
Pod undocumented
127 0 my $self = shift;
128 0 my $row = shift;
129 0 my $key = shift;
130 0 die "EXTRA";
131 0 my $extra = $self->{extra}->{columns};
132  
133 0 my $ret = undef;
134  
135 0 my $x = $self->extra_package->new(row => $row, table => $self);
136  
137 0 ▶ if (ref($extra->{$key}) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $extra->{$key} eq 'CODE') { } 0 0 0
138 0 eval {
139 0 $ret = $extra->{$key}->($x);
140 };
141 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
142 0 die $@;
143 }
144 } else {
145 0 die 'only know how to deal with code';
146 }
147
148 0 $ret;
149 }
150  
151 3 1;
152 __END__
« Tabular/Table/Extra.pm ↑ Summary Tabular/Config/Output.pm »