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

filter: Statementstmt 21.6% 13 / 60 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 12.6% 17 / 134 CC 22 SCAR 51.1
CC
22
Cov
12%
process
306.0
optimize
20.0
operate
6.0
CRAP 166.1
« blib/lib/WWW/Shopify/Liquid/Tag/For.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Tag/Increment.pm »
1 #!/usr/bin/perl
2  
3 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 30 ▶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 30 ▶use base 'WWW::Shopify::Liquid::Operator';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 30 ▶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 sub operate {
15 0 ▶ my ($self, $hash, $action, @ops) = @_;
Subroutine operate: not called CC=2 SCAR=17.9
Pod undocumented
16 0 $ops[$_] = '' for (grep { !defined $ops[$_] } 0..$#ops);
17
18 0 return join("", grep { defined $_ } @ops);
19 }
20  
21 sub process {
22 0 ▶ my ($self, $hash, $action, $pipeline) = @_;
Subroutine process: not called CC=17 SCAR=57.2
Pod undocumented
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 && defined $exp && blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control');
Branch: 1 branch
BranchTrueFalseTotal
if $idx > 0 and defined $exp and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control") 0 0 0
Condition0%0/9
$idx > 0 and defined $exp and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
!ll&&!rl&&r
000
$idx > 0 and defined $exp and builtin::blessed($exp)
!ll&&!rl&&r
000
$idx > 0 and defined $exp
!ll&&!rl&&r
000
MC/DC0%0/4
$idx > 0 and defined $exp and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
$idx > 0 defined $exp builtin::blessed($exp) $exp->isa("WWW::Shopify::Liquid::Exception::Control")
Truth table0%0/5
A and B and C and D
A= $idx > 0B= defined $expC= builtin::blessed($exp)D= $exp->isa("WWW::Shopify::Liquid::Exception::Control")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
31 0 die $exp;
32 }
33 }
34
35 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
36 0 my $result;
37 my @new_ops;
38 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
39 0 ▶ if ($self->is_processed($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_processed($_)) { } 0 0 0
40 0 ▶ $result .= $_ if defined $_;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 0 0 0
41 } else {
42 0 push(@new_ops, $result);
43 0 $result = '';
44 0 push(@new_ops, $_);
45 }
46
47 }
48 0 ▶ push(@new_ops, $result) if $result ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $result ne "" 0 0 0
49 0 $self->{operands} = \@new_ops;
50 0 return $self;
51 }
52
53 0 return $self->operate($hash, $action, @ops);
54 }
55  
56 sub optimize {
57 0 ▶ my ($self, $optimizer, $hash) = @_;
Subroutine optimize: not called CC=4 SCAR=30.0
Pod undocumented
58 0 my $result = $self->SUPER::optimize($optimizer, $hash);
59 0 ▶ $self->{operands} = [grep { !$self->is_processed($_) || (defined $_ && $_ ne '') } @{$self->{operands}}];
Branch: 1 branch
BranchTrueFalseTotal
not $self->is_processed($_) or defined $_ and $_ ne "" 0 0 0
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
60 0 ▶ return $self->{operands}->[0] if int(@{$self->{operands}}) == 1;
Branch: 1 branch
BranchTrueFalseTotal
if int @{$self->{"operands"};} == 1 0 0 0
61 0 return $result;
62 }
63  
64 sub new {
65 0 ▶ my $package = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
66 0 my $line = shift;
67 0 my $core = shift;
68 0 my $self = bless { line => $line, core => $core, operands => undef }, $package;
69 0 ▶ $self->{operands} = [@_] if int(@_) >= 1;
Branch: 1 branch
BranchTrueFalseTotal
if int @_ >= 1 0 0 0
70 0 return $self;
71 }
72  
73 30 1;
« blib/lib/WWW/Shopify/Liquid/Tag/For.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Tag/Increment.pm »