| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $self->{operands}->[$idx] = $ops[$idx] if $action eq "optimize"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if (my $exp = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/9
$idx > 0 and defined $exp and builtin::blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
$idx > 0 and defined $exp and builtin::blessed($exp)
$idx > 0 and defined $exp
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if (int(grep { !$self->is_processed($_) } @ops) > 0 && $action eq "optimize") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
int grep({not $self->is_processed($_);} @ops) > 0 and $action eq "optimize"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | my @new_ops; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | for (map { blessed($_) && $_->isa('WWW::Shopify::Liquid::Operator::Concatenate') ? (@{$_->{operands}}) : ($_) } @ops) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($_) and $_->isa("WWW::Shopify::Liquid::Operator::Concatenate")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ($self->is_processed($_)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $result .= $_ if defined $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
!$self->is_processed($_) || defined $_ && $_ ne ''
defined $_ and $_ ne ""
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 ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return $self->{operands}->[0] if int(@{$self->{operands}}) == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 30 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||