| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 38 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 38 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package WWW::Shopify::Liquid::Element; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | ▶ | sub verify { return 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub subelements { qw(); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subelements: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tokens: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | return ($self, map { $self->is_processed($_) ? $_ : $_->tokens } map { ref($_) eq 'ARRAY' ? @$_ : $_ } map { $self->{$_} } $self->subelements); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub operate { return $_[0]; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
operate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub render_subelement($$$\$) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_subelement: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my ($self, $renderer, $hash, $element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if (ref($element) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | $value = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | push(@$value, $self->is_processed($_) ? $_ : ($renderer->state && $renderer->state->{values}->{$_} ? delete $renderer->state->{values}->{$_} : $_->render($renderer, $hash))) for (@$element); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$renderer->state and $renderer->state->{"values"}{$_}
MC/DC0%0/2
$renderer->state and $renderer->state->{"values"}{$_}
$renderer->state
$renderer->state->{"values"}{$_}
Truth table0%0/3
A and B
A= $renderer->stateB= $renderer->state->{"values"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if (my $exp = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $exp->value($element, $value) if blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control::Pause'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
MC/DC0%0/2
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
&blessed($exp)
$exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
Truth table0%0/3
A and B
A= &blessed($exp)B= $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $value = !$self->is_processed($$element) ? ($$element)->render($renderer, $hash) : $$element; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub optimize_subelement($$$\$) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optimize_subelement: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my ($self, $optimizer, $hash, $element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if (ref($element) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | for my $idx (0..(int(@$element)-1)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $inner = $element->[$idx]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if (!$self->is_processed($inner)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $inner = $inner->optimize($optimizer, $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $element->[$idx] = $inner | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $value = !$self->is_processed($$element) ? ($$element)->optimize($optimizer, $hash) : $$element; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $$element = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $element = $$element; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | return $element; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub process_subelement { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_subelement: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my ($self, $hash, $action, $pipeline, $element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $action .= "_subelement"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return $self->$action($pipeline, $hash, $element); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub process_subelements { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_subelements: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my ($self, $hash, $action, $pipeline) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return map { $self->process_subelement($hash, $action, $pipeline, ref($self->{$_}) eq 'ARRAY' ? $self->{$_} : (\$self->{$_})) } $self->subelements; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub render { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $renderer = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | return delete $renderer->state->{values}->{$self} if $renderer->state && exists $renderer->state->{values}->{$self}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$renderer->state and exists $renderer->state->{"values"}{$self}
MC/DC0%0/2
$renderer->state and exists $renderer->state->{"values"}{$self}
$renderer->state
exists $renderer->state->{"values"}{$self}
Truth table0%0/3
A and B
A= $renderer->stateB= exists $renderer->state->{"values"}{$self}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $return = eval { $self->process(@_, "render", $renderer); }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $exp = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($exp) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | die $exp if (blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control')); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
MC/DC0%0/2
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
&blessed($exp)
$exp->isa("WWW::Shopify::Liquid::Exception::Control")
Truth table0%0/3
A and B
A= &blessed($exp)B= $exp->isa("WWW::Shopify::Liquid::Exception::Control")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($renderer->{silence_exceptions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } elsif ($renderer->{wrap_exceptions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | die $exp if blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Renderer::Wrapped'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
MC/DC0%0/2
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
&blessed($exp)
$exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
Truth table0%0/3
A and B
A= &blessed($exp)B= $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | die new WWW::Shopify::Liquid::Exception::Renderer::Wrapped($self, $exp); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } elsif ($renderer->{print_exceptions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | return blessed($exp) && $exp->can('english') ? $exp->english : "$exp"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&blessed($exp) and $exp->can("english")
MC/DC0%0/2
&blessed($exp) and $exp->can("english")
&blessed($exp)
$exp->can("english")
Truth table0%0/3
A and B
A= &blessed($exp)B= $exp->can("english")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | return undef if $exp || !$self->is_processed($return) || !defined $return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$exp or not $self->is_processed($return) or not defined $return
$exp or not $self->is_processed($return)
MC/DC0%0/3
$exp or not $self->is_processed($return) or not defined $return
$exp
not $self->is_processed($return)
not defined $return
Truth table0%0/4
A or not(B) or not(C)
A= $expB= not $self->is_processed($return)C= not defined $return
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub get_parameter { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_parameter: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my ($self, $name, @arguments) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my ($arg) = grep { ref($_) && ref($_) eq 'HASH' && int(keys(%$_)) == 1 && exists $_->{$name} } @arguments; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
ref $_ && ref $_ eq 'HASH' && int keys %$_ == 1 && exists $_->{$name}
ref $_ and ref $_ eq "HASH" and int keys %$_ == 1
ref $_ and ref $_ eq "HASH"
MC/DC0%0/4
ref $_ && ref $_ eq 'HASH' && int keys %$_ == 1 && exists $_->{$name}
ref $_
ref $_ eq "HASH"
int keys %$_ == 1
exists $_->{$name}
Truth table0%0/5
A and B and C && D
A= ref $_B= ref $_ eq "HASH"C= int keys %$_ == 1D= exists $_->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | return $arg ? $arg->{$name} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub optimize { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optimize: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $optimizer = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | die new WWW::Shopify::Liquid::Exception($self, "Cannot optimize without a valid optimizer.") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$optimizer and &blessed($optimizer) and $optimizer->isa("WWW::Shopify::Liquid::Optimizer")
$optimizer and &blessed($optimizer)
MC/DC0%0/3
$optimizer and &blessed($optimizer) and $optimizer->isa("WWW::Shopify::Liquid::Optimizer")
$optimizer
&blessed($optimizer)
$optimizer->isa("WWW::Shopify::Liquid::Optimizer")
Truth table0%0/4
A and B and C
A= $optimizerB= &blessed($optimizer)C= $optimizer->isa("WWW::Shopify::Liquid::Optimizer")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | unless $optimizer && blessed($optimizer) && $optimizer->isa('WWW::Shopify::Liquid::Optimizer'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return $self->process(@_, "optimize", $optimizer); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub process { return $_[0]; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Determines whether or not the element is part of the strict subset of liquid that Shopify uses. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub is_strict { return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_strict: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 38 | ▶ | use Scalar::Util qw(looks_like_number blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub is_processed { return WWW::Shopify::Liquid::Pipeline->is_processed($_[1]); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_processed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub ensure_numerical { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_numerical: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return $_[1] if defined $_[1] && looks_like_number($_[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[1] and &looks_like_number($_[1])
MC/DC0%0/2
defined $_[1] and &looks_like_number($_[1])
defined $_[1]
&looks_like_number($_[1])
Truth table0%0/3
A and B
A= defined $_[1]B= &looks_like_number($_[1])
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return $_[1] if ref($_[1]) && ref($_[1]) eq "DateTime"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[1] and ref $_[1] eq "DateTime"
MC/DC0%0/2
ref $_[1] and ref $_[1] eq "DateTime"
ref $_[1]
ref $_[1] eq "DateTime"
Truth table0%0/3
A and B
A= ref $_[1]B= ref $_[1] eq "DateTime"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 38 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||