Bencher/Role/FieldMunger.pm

filter: Statementstmt 23.1% 16 / 69 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 15.0% 20 / 133 CC 26 SCAR 52.3
CC
26
Cov
14%
add_field
272.0
delete_fields
132.0
BEGIN
1.0
CRAP 187.4
« Bencher/Backend.pm ↑ Summary Bencher/Formatter/ScaleSize.pm »
1 package Bencher::Role::FieldMunger;
2  
3 8 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10 8 our $DATE = '2023-07-08'; # DATE
11 8 our $DIST = 'Bencher-Backend'; # DIST
12 8 our $VERSION = '1.063'; # VERSION
13  
14 0 ▶sub add_field {
Subroutine add_field: not called CC=16 SCAR=56.1
Pod undocumented
15 0 my ($self, $envres, $name, $opts, $code) = @_;
16  
17 0 $code->();
18  
19 0 my $fs = $envres->[3]{'table.fields'};
20 0 my $fu = $envres->[3]{'table.field_units'};
21 0 my $fa = $envres->[3]{'table.field_aligns'};
22 0 my $ff = $envres->[3]{'table.field_formats'};
23  
24 0 my $pos = 0;
25 0 for my $i (0..$#{$fs}) {
26 0 ▶ if ($opts->{after} && $fs->[$i] eq $opts->{after}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"after"} and $fs->[$i] eq $opts->{"after"}) 0 0 0
Condition0%0/3
$opts->{"after"} and $fs->[$i] eq $opts->{"after"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"after"} and $fs->[$i] eq $opts->{"after"}
$opts->{"after"} $fs->[$i] eq $opts->{"after"}
Truth table0%0/3
A and B
A= $opts->{"after"}B= $fs->[$i] eq $opts->{"after"}
ABresult
0X0
100
111
27 0 $pos = $i+1;
28 0 last;
29 }
30 0 ▶ if ($opts->{before} && $fs->[$i] eq $opts->{before}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"before"} and $fs->[$i] eq $opts->{"before"}) 0 0 0
Condition0%0/3
$opts->{"before"} and $fs->[$i] eq $opts->{"before"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"before"} and $fs->[$i] eq $opts->{"before"}
$opts->{"before"} $fs->[$i] eq $opts->{"before"}
Truth table0%0/3
A and B
A= $opts->{"before"}B= $fs->[$i] eq $opts->{"before"}
ABresult
0X0
100
111
31 0 $pos = $i;
32 0 last;
33 }
34 }
35  
36 0 splice @$fs, $pos, 0, $name;
37 0 ▶ if ($fu) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fu) 0 0 0
38 0 my $unit;
39 0 ▶ if ($opts->{unit}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts->{'unit'}) { } 0 0 0
elsif ($opts->{'unit_of'}) { } 0 0 0
40 0 $unit = $opts->{unit};
41 } elsif ($opts->{unit_of}) {
42 0 for my $i (0..$#{$ff}) {
43 0 ▶ if (($ff->[$i] // '') eq $opts->{unit_of}) {
Branch: 1 branch
BranchTrueFalseTotal
if (($ff->[$i] // "") eq $opts->{"unit_of"}) 0 0 0
Condition0%0/2
$ff->[$i] // ""
l!l
00
MC/DC0%0/1
$ff->[$i] // ""
$ff->[$i]
Truth table0%0/2
A
A= $ff->[$i]
Aresult
11
00
44 0 $unit = $fu->[$i];
45 0 last;
46 }
47 }
48 }
49 0 splice @$fu, $pos, 0, $unit;
50 }
51 0 ▶ if ($fa) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fa) 0 0 0
52 0 my $align;
53 0 ▶ if ($opts->{align}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"align"}) 0 0 0
54 0 $align = $opts->{align};
55 }
56 0 splice @$fa, $pos, 0, $align;
57 }
58 0 ▶ if ($ff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ff) 0 0 0
59 0 my $format;
60 0 ▶ if ($opts->{format}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"format"}) 0 0 0
61 0 $format = $opts->{format};
62 }
63 0 splice @$ff, $pos, 0, $format;
64 }
65 }
66  
67 0 ▶sub delete_fields {
Subroutine delete_fields: not called CC=11 SCAR=48.8
Pod undocumented
68 0 my ($self, $envres, @names) = @_;
69  
70 0 for my $name (@names) {
71 0 for my $row (@{$envres->[2]}) {
72 0 delete $row->{$name};
73 }
74 }
75  
76 0 my $fs = $envres->[3]{'table.fields'};
77 0 my $fu = $envres->[3]{'table.field_units'};
78 0 my $fa = $envres->[3]{'table.field_aligns'};
79 0 my $ff = $envres->[3]{'table.field_formats'};
80  
81 0 for my $i (reverse 0..$#{$fs}) {
82 0 ▶ if (grep {$fs->[$i] eq $_} @names) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$fs->[$i] eq $_;} @names) 0 0 0
83 0 splice @$fs, $i, 1;
84 0 ▶ splice @$fu, $i, 1 if $fu && @$fu > $i;
Branch: 1 branch
BranchTrueFalseTotal
if $fu and @$fu > $i 0 0 0
Condition0%0/3
$fu and @$fu > $i
!ll&&!rl&&r
000
MC/DC0%0/2
$fu and @$fu > $i
$fu @$fu > $i
Truth table0%0/3
A and B
A= $fuB= @$fu > $i
ABresult
0X0
100
111
85 0 ▶ splice @$fa, $i, 1 if $fa && @$fa > $i;
Branch: 1 branch
BranchTrueFalseTotal
if $fa and @$fa > $i 0 0 0
Condition0%0/3
$fa and @$fa > $i
!ll&&!rl&&r
000
MC/DC0%0/2
$fa and @$fa > $i
$fa @$fa > $i
Truth table0%0/3
A and B
A= $faB= @$fa > $i
ABresult
0X0
100
111
86 0 ▶ splice @$ff, $i, 1 if $ff && @$ff > $i;
Branch: 1 branch
BranchTrueFalseTotal
if $ff and @$ff > $i 0 0 0
Condition0%0/3
$ff and @$ff > $i
!ll&&!rl&&r
000
MC/DC0%0/2
$ff and @$ff > $i
$ff @$ff > $i
Truth table0%0/3
A and B
A= $ffB= @$ff > $i
ABresult
0X0
100
111
87 }
88 }
89 }
90  
91 8 1;
92 # ABSTRACT: Field munger role
93  
94 __END__
« Bencher/Backend.pm ↑ Summary Bencher/Formatter/ScaleSize.pm »