lib/WWW/Shopify/Liquid/Operator/Concatenate.pm

filter: Statementstmt 20.9% 13 / 62 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 12.4% 17 / 137 CC 24 SCAR 53.7
CC
24
Cov
12%
process
380.0
optimize
20.0
operate
6.0
CRAP 215.7
« lib/WWW/Shopify/Liquid/Tag/Capture.pm ↑ Summary lib/WWW/Shopify/Liquid/Pipeline.pm »
1 #!/usr/bin/perl
2  
3 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Used in our AST to keep things simple; represents the concatenation of text and other stuff.
7 # Making this a many-dimensional operator, so that we avoid going too far down the callstack rabbithole.
8 package WWW::Shopify::Liquid::Operator::Concatenate;
9 38 ▶use base 'WWW::Shopify::Liquid::Operator';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 38 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 0 ▶sub symbol { return ('~'); }
Subroutine symbol: not called CC=1 SCAR=6.9
Pod undocumented
12 0 ▶sub arity { return "nary"; }
Subroutine arity: not called CC=1 SCAR=6.9
Pod undocumented
13 0 ▶sub priority { return 9; }
Subroutine priority: not called CC=1 SCAR=6.9
Pod undocumented
14 0 ▶sub operate {
Subroutine operate: not called CC=2 SCAR=17.9
Pod undocumented
15 0 my ($self, $hash, $action, @ops) = @_;
16 0 $ops[$_] = '' for (grep { !defined $ops[$_] } 0..$#ops);
17
18 0 return join("", grep { defined $_ } @ops);
19 }
20  
21 0 ▶sub process {
Subroutine process: not called CC=19 SCAR=59.4
Pod undocumented
22 0 my ($self, $hash, $action, $pipeline) = @_;
23 0 my @ops = @{$self->{operands}};
24 0 for my $idx (0..$#ops) {
25 0 eval {
26 0 ▶ $ops[$idx] = $ops[$idx]->$action($pipeline, $hash) unless $self->is_processed($ops[$idx]);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_processed($ops[$idx]) 0 0 0
27 0 ▶ $self->{operands}->[$idx] = $ops[$idx] if $action eq "optimize";
Branch: 1 branch
BranchTrueFalseTotal
if $action eq "optimize" 0 0 0
28 };
29 0 ▶ if (my $exp = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $exp = $@) 0 0 0
30 0 ▶ $exp->initial_render(@ops[0..($idx-1)]) if $idx > 0 && blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control');
Branch: 1 branch
BranchTrueFalseTotal
if $idx > 0 and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control") 0 0 0
Condition0%0/6
$idx > 0 and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
!ll&&!rl&&r
000
$idx > 0 and builtin::blessed($exp)
!ll&&!rl&&r
000
MC/DC0%0/3
$idx > 0 and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
$idx > 0 builtin::blessed($exp) $exp->isa("WWW::Shopify::Liquid::Exception::Control")
Truth table0%0/4
A and B and C
A= $idx > 0B= builtin::blessed($exp)C= $exp->isa("WWW::Shopify::Liquid::Exception::Control")
ABCresult
0XX0
10X0
1100
1111
31 0 ▶ if (blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control::Pause')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")) 0 0 0
Condition0%0/3
builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
builtin::blessed($exp) $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
Truth table0%0/3
A and B
A= builtin::blessed($exp)B= $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
ABresult
0X0
100
111
32 0 $exp->register_value($self->{operands}->[$_], $ops[$_]) for (0..($idx-1));
33 }
34 0 die $exp;
35 }
36 }
37
38 0 ▶ if (int(grep { !$self->is_processed($_) } @ops) > 0 && $action eq "optimize") {
Branch: 1 branch
BranchTrueFalseTotal
if (int grep({not $self->is_processed($_);} @ops) > 0 and $action eq "optimize") 0 0 0
Condition0%0/3
int grep({not $self->is_processed($_);} @ops) > 0 and $action eq "optimize"
!ll&&!rl&&r
000
MC/DC0%0/2
int grep({not $self->is_processed($_);} @ops) > 0 and $action eq "optimize"
int grep({not $self->is_processed($_);} @ops) > 0 $action eq "optimize"
Truth table0%0/3
A and B
A= int grep({not $self->is_processed($_);} @ops) > 0B= $action eq "optimize"
ABresult
0X0
100
111
39 0 my $result;
40 my @new_ops;
41 0 ▶ for (map { blessed($_) && $_->isa('WWW::Shopify::Liquid::Operator::Concatenate') ? (@{$_->{operands}}) : ($_) } @ops) {
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_) && $_->isa('WWW::Shopify::Liquid::Operator::Concatenate') ? : 0 0 0
Condition0%0/3
builtin::blessed($_) and $_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($_) and $_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
builtin::blessed($_) $_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
Truth table0%0/3
A and B
A= builtin::blessed($_)B= $_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
ABresult
0X0
100
111
42 0 ▶ if ($self->is_processed($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_processed($_)) { } 0 0 0
43 0 ▶ $result .= $_ if defined $_;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 0 0 0
44 } else {
45 0 push(@new_ops, $result);
46 0 $result = '';
47 0 push(@new_ops, $_);
48 }
49
50 }
51 0 ▶ push(@new_ops, $result) if $result ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $result ne "" 0 0 0
52 0 $self->{operands} = \@new_ops;
53 0 return $self;
54 }
55
56 0 return $self->operate($hash, $action, @ops);
57 }
58  
59 0 ▶sub optimize {
Subroutine optimize: not called CC=4 SCAR=30.0
Pod undocumented
60 0 my ($self, $optimizer, $hash) = @_;
61 0 my $result = $self->SUPER::optimize($optimizer, $hash);
62 0 ▶ $self->{operands} = [grep { !$self->is_processed($_) || (defined $_ && $_ ne '') } @{$self->{operands}}];
Condition0%0/6
!$self->is_processed($_) || defined $_ && $_ ne ''
l!l&&r!l&&!r
000
defined $_ and $_ ne ""
!ll&&!rl&&r
000
MC/DC0%0/3
!$self->is_processed($_) || defined $_ && $_ ne ''
!$self->is_processed($_) defined $_ $_ ne ""
Truth table0%0/4
not(A) || B and C
A= !$self->is_processed($_)B= defined $_C= $_ ne ""
ABCresult
1XX1
0111
00X0
0100
63 0 ▶ return $self->{operands}->[0] if int(@{$self->{operands}}) == 1;
Branch: 1 branch
BranchTrueFalseTotal
if int @{$self->{"operands"};} == 1 0 0 0
64 0 return $result;
65 }
66  
67 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
68 0 my $package = shift;
69 0 my $line = shift;
70 0 my $core = shift;
71 0 my $self = bless { line => $line, core => $core, operands => undef }, $package;
72 0 ▶ $self->{operands} = [@_] if int(@_) >= 1;
Branch: 1 branch
BranchTrueFalseTotal
if int @_ >= 1 0 0 0
73 0 return $self;
74 }
75  
76 38 1;
« lib/WWW/Shopify/Liquid/Tag/Capture.pm ↑ Summary lib/WWW/Shopify/Liquid/Pipeline.pm »