lib/WWW/Shopify/Liquid/Exception.pm

filter: Statementstmt 58.2% 109 / 187 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 38 MC/DCmcdc 0.0% 0 / 21 Subroutinesub 48.0% 36 / 75 Podpod 0.0% 0 / 6 totaltotal 39.3% 145 / 369 CC 36 SCAR 29.5
CC
36
Cov
41%
english
90.0
new
72.0
value
42.0
CRAP 19.0
« lib/WWW/Shopify/Liquid/Filter/Date.pm ↑ Summary lib/WWW/Shopify/Liquid/Filter/Sort.pm »
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::Exception;
6 38 ▶use Devel::StackTrace;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 38 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 use overload
9 38 ▶ fallback => 1,
Subroutine BEGIN: called CC=1 SCAR=4.3
10 0 ▶ '""' => sub { return $_[0]->english . ($_[0]->error && (!ref($_[0]->error) || blessed($_[0]->error)) ? ": " . $_[0]->error : "") . ($_[0]->line ? " on line " . $_[0]->line . ", character " . $_[0]->{line}->[1] . ($_[0]->{line}->[3] ? ", file " . $_[0]->{line}->[3] : '') : ''); };
Subroutine __ANON__: not called CC=6 SCAR=32.3
Branch: 3 branches
BranchTrueFalseTotal
$_[0]->error && (!ref($_[0]->error) || builtin::blessed($_[0]->error)) ? : 0 0 0
$_[0]->line ? : 0 0 0
$_[0]{'line'}[3] ? : 0 0 0
Condition0%0/6
$_[0]->error and !ref($_[0]->error) || builtin::blessed($_[0]->error)
!ll&&!rl&&r
000
not ref $_[0]->error or builtin::blessed($_[0]->error)
l!l&&r!l&&!r
000
MC/DC0%0/3
$_[0]->error and !ref($_[0]->error) || builtin::blessed($_[0]->error)
$_[0]->error not ref $_[0]->error builtin::blessed($_[0]->error)
Truth table0%0/4
A and not(B) or C
A= $_[0]->errorB= not ref $_[0]->errorC= builtin::blessed($_[0]->error)
ABCresult
0XX0
1000
11X1
1011
11 0 ▶sub line { return $_[0]->{line} ? (ref($_[0]->{line}) && ref($_[0]->{line}) eq "ARRAY" ? $_[0]->{line}->[0] : $_[0]->{line}) : undef; }
Subroutine line: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
$_[0]{'line'} ? : 0 0 0
ref $_[0]{'line'} && ref $_[0]{'line'} eq 'ARRAY' ? : 0 0 0
Condition0%0/3
ref $_[0]{"line"} and ref $_[0]{"line"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[0]{"line"} and ref $_[0]{"line"} eq "ARRAY"
ref $_[0]{"line"} ref $_[0]{"line"} eq "ARRAY"
Truth table0%0/3
A and B
A= ref $_[0]{"line"}B= ref $_[0]{"line"} eq "ARRAY"
ABresult
0X0
100
111
12 0 ▶sub column { return $_[0]->{line} && ref($_[0]->{line}) && ref($_[0]->{line}) eq "ARRAY" ? $_[0]->{line}->[1] : undef; }
Subroutine column: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'line'} && ref $_[0]{'line'} && ref $_[0]{'line'} eq 'ARRAY' ? : 0 0 0
Condition0%0/6
$_[0]{"line"} and ref $_[0]{"line"} and ref $_[0]{"line"} eq "ARRAY"
!ll&&!rl&&r
000
$_[0]{"line"} and ref $_[0]{"line"}
!ll&&!rl&&r
000
MC/DC0%0/3
$_[0]{"line"} and ref $_[0]{"line"} and ref $_[0]{"line"} eq "ARRAY"
$_[0]{"line"} ref $_[0]{"line"} ref $_[0]{"line"} eq "ARRAY"
Truth table0%0/4
A and B and C
A= $_[0]{"line"}B= ref $_[0]{"line"}C= ref $_[0]{"line"} eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
13 0 ▶sub stack { return $_[0]->{stack}; }
Subroutine stack: not called CC=1 SCAR=6.9
Pod undocumented
14 0 ▶sub english { return $_[0]->{error} ? $_[0]->{error} : "Unknown Error"; }
Subroutine english: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'error'} ? : 0 0 0
15 0 ▶sub error { return $_[0]->{error}; }
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
16  
17 38 ▶use Devel::StackTrace;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 38 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 0 ▶sub new {
Subroutine new: not called CC=8 SCAR=42.8
Pod undocumented
21 0 my ($package, $line, $message) = @_;
22 0 my $self = bless {
23 error => $message,
24 stack => Devel::StackTrace->new,
25 }, $package;
26 0 ▶ if (blessed($line)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($line)) 0 0 0
27 0 ▶ if ($line->isa('WWW::Shopify::Liquid::Tag') || $line->isa('WWW::Shopify::Liquid::Token') || $line->isa('WWW::Shopify::Liquid::Operator') || $line->isa('WWW::Shopify::Liquid::Filter')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line->isa("WWW::Shopify::Liquid::Tag") or $line->isa("WWW::Shopify::Liquid::Token") or $line->isa("WWW::Shopify::Liquid::Operator") or $line->isa("WWW::Shopify::Liquid::Filter")) 0 0 0
Condition0%0/9
$line->isa("WWW::Shopify::Liquid::Tag") or $line->isa("WWW::Shopify::Liquid::Token") or $line->isa("WWW::Shopify::Liquid::Operator") or $line->isa("WWW::Shopify::Liquid::Filter")
l!l&&r!l&&!r
000
$line->isa("WWW::Shopify::Liquid::Tag") or $line->isa("WWW::Shopify::Liquid::Token") or $line->isa("WWW::Shopify::Liquid::Operator")
l!l&&r!l&&!r
000
$line->isa("WWW::Shopify::Liquid::Tag") or $line->isa("WWW::Shopify::Liquid::Token")
l!l&&r!l&&!r
000
MC/DC0%0/4
$line->isa("WWW::Shopify::Liquid::Tag") or $line->isa("WWW::Shopify::Liquid::Token") or $line->isa("WWW::Shopify::Liquid::Operator") or $line->isa("WWW::Shopify::Liquid::Filter")
$line->isa("WWW::Shopify::Liquid::Tag") $line->isa("WWW::Shopify::Liquid::Token") $line->isa("WWW::Shopify::Liquid::Operator") $line->isa("WWW::Shopify::Liquid::Filter")
Truth table0%0/5
A or B or C or D
A= $line->isa("WWW::Shopify::Liquid::Tag")B= $line->isa("WWW::Shopify::Liquid::Token")C= $line->isa("WWW::Shopify::Liquid::Operator")D= $line->isa("WWW::Shopify::Liquid::Filter")
ABCDresult
1XXX1
01XX1
001X1
00011
00000
28 0 $self->{token} = $line;
29 0 $line = $line->{line};
30 }
31 }
32 0 ▶ if (defined $line && ref($line) ne "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $line and ref $line ne "ARRAY") 0 0 0
Condition0%0/3
defined $line and ref $line ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $line and ref $line ne "ARRAY"
defined $line ref $line ne "ARRAY"
Truth table0%0/3
A and B
A= defined $lineB= ref $line ne "ARRAY"
ABresult
0X0
100
111
33 0 $self->{error} = $line;
34 0 return $self;
35 }
36 0 $self->{line} = $line;
37 0 return $self;
38 }
39  
40 package WWW::Shopify::Liquid::Exception::Timeout;
41 38 ▶use base 'WWW::Shopify::Liquid::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 package WWW::Shopify::Liquid::Exception::Control;
44 38 ▶use base 'WWW::Shopify::Liquid::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
45 0 ▶sub english { return "Control exception"; }
Subroutine english: not called CC=1 SCAR=6.9
46  
47 0 ▶sub initial_render { my $self = shift; $self->{initial_render} = \@_ if int(@_) > 0; return $self->{initial_render}; }
Subroutine initial_render: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if int @_ > 0 0 0 0
48  
49 package WWW::Shopify::Liquid::Exception::Control::Continue;
50 38 ▶use base 'WWW::Shopify::Liquid::Exception::Control';
Subroutine BEGIN: called CC=1 SCAR=0.0
51 0 ▶sub english { return "Continue exception"; }
Subroutine english: not called CC=1 SCAR=6.9
52  
53 package WWW::Shopify::Liquid::Exception::Control::Break;
54 38 ▶use base 'WWW::Shopify::Liquid::Exception::Control';
Subroutine BEGIN: called CC=1 SCAR=0.0
55 0 ▶sub english { return "Break exception"; }
Subroutine english: not called CC=1 SCAR=6.9
56  
57 package WWW::Shopify::Liquid::Exception::Control::Pause;
58 38 ▶use base 'WWW::Shopify::Liquid::Exception::Control';
Subroutine BEGIN: called CC=1 SCAR=0.0
59 0 ▶sub english { return "Pause exception"; }
Subroutine english: not called CC=1 SCAR=6.9
60  
61 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
62 0 my $self = shift->SUPER::new;
63 0 $self->{hash} = $_[1];
64 0 $self->{values} = {};
65 0 $self->register_value($_[0], $_[2]);
66 0 return $self;
67 }
68  
69 38 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
70 0 ▶sub register_value {
Subroutine register_value: not called CC=2 SCAR=17.9
71 0 my ($self, $element, $value) = @_;
72 0 ▶ $self->{values}->{$element} = $value if !$element->isa('WWW::Shopify::Liquid::Token');
Branch: 1 branch
BranchTrueFalseTotal
if not $element->isa("WWW::Shopify::Liquid::Token") 0 0 0
73 }
74  
75 0 ▶sub value {
Subroutine value: not called CC=6 SCAR=37.4
76 0 my ($self, $element, $value) = @_;
77 0 ▶ if ((ref($element) || '') eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $element || '') eq 'ARRAY') { } 0 0 0
Condition0%0/2
ref $element || ''
l!l
00
MC/DC0%0/1
ref $element || ''
ref $element
Truth table0%0/2
A
A= ref $element
Aresult
11
00
78 0 ▶ if (@_ > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) 0 0 0
79 0 for my $idx (0..(int(@$value)-1)) {
80 0 $self->register_value($element->[$idx], $value->[$idx]);
81 }
82 }
83 0 return [map { $self->{values}->{$_} } @$element];
84 } else {
85 0 ▶ $self->register_value($element, $value) if @_ > 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 2 0 0 0
86 0 return $self->{values}->{$element};
87 }
88 }
89  
90 package WWW::Shopify::Liquid::Exception::Lexer;
91 38 ▶use base 'WWW::Shopify::Liquid::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
92 0 ▶sub english { return "Lexer exception"; }
Subroutine english: not called CC=1 SCAR=6.9
93  
94 package WWW::Shopify::Liquid::Exception::Lexer::UnbalancedBrace;
95 38 ▶use base 'WWW::Shopify::Liquid::Exception::Lexer';
Subroutine BEGIN: called CC=1 SCAR=0.0
96 0 ▶sub english { return "Unbalanced brace found"; }
Subroutine english: not called CC=1 SCAR=6.9
97  
98 package WWW::Shopify::Liquid::Exception::Lexer::UnbalancedSingleQuote;
99 38 ▶use base 'WWW::Shopify::Liquid::Exception::Lexer';
Subroutine BEGIN: called CC=1 SCAR=0.0
100 0 ▶sub english { return "Unbalanced single quote found"; }
Subroutine english: not called CC=1 SCAR=6.9
101  
102 package WWW::Shopify::Liquid::Exception::Lexer::UnbalancedDoubleQuote;
103 38 ▶use base 'WWW::Shopify::Liquid::Exception::Lexer';
Subroutine BEGIN: called CC=1 SCAR=0.0
104 0 ▶sub english { return "Unbalanced double quote found"; }
Subroutine english: not called CC=1 SCAR=6.9
105  
106 package WWW::Shopify::Liquid::Exception::Lexer::UnbalancedControlTag;
107 38 ▶use base 'WWW::Shopify::Liquid::Exception::Lexer';
Subroutine BEGIN: called CC=1 SCAR=0.0
108 0 ▶sub english {
Subroutine english: not called CC=2 SCAR=17.9
109 0 my ($self) = @_;
110 0 ▶ return "Unbalanced control tag '" . $self->{token}->stringify . "' found" if $self->{token};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"token"} 0 0 0
111 0 return "Unbalanced control tag found";
112 }
113  
114 package WWW::Shopify::Liquid::Exception::Lexer::UnbalancedOutputTag;
115 38 ▶use base 'WWW::Shopify::Liquid::Exception::Lexer';
Subroutine BEGIN: called CC=1 SCAR=0.0
116 0 ▶sub english { return "Unbalanced output tag found"; }
Subroutine english: not called CC=1 SCAR=6.9
117  
118 package WWW::Shopify::Liquid::Exception::Lexer::UnbalancedLexingHalt;
119 38 ▶use base 'WWW::Shopify::Liquid::Exception::Lexer';
Subroutine BEGIN: called CC=1 SCAR=0.0
120 0 ▶sub english { return "Unbalanced lexing halter found"; }
Subroutine english: not called CC=1 SCAR=6.9
121  
122 package WWW::Shopify::Liquid::Exception::Lexer::InvalidSeparator;
123 38 ▶use base 'WWW::Shopify::Liquid::Exception::Lexer';
Subroutine BEGIN: called CC=1 SCAR=0.0
124 0 ▶sub english { return "Invalid separator during array/hash construction."; }
Subroutine english: not called CC=1 SCAR=6.9
125  
126 package WWW::Shopify::Liquid::Exception::Lexer::Tag;
127 38 ▶use base 'WWW::Shopify::Liquid::Exception::Lexer';
Subroutine BEGIN: called CC=1 SCAR=0.0
128 0 ▶sub english { return "Malformed tag " . $_[0]->{message}; }
Subroutine english: not called CC=1 SCAR=6.9
129  
130  
131 package WWW::Shopify::Liquid::Exception::Parser;
132 38 ▶use base 'WWW::Shopify::Liquid::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
133 0 ▶sub english { return "Parser exception"; }
Subroutine english: not called CC=1 SCAR=6.9
134  
135 package WWW::Shopify::Liquid::Exception::Parser::NoClose;
136 38 ▶use base 'WWW::Shopify::Liquid::Exception::Parser';
Subroutine BEGIN: called CC=1 SCAR=0.0
137 0 ▶sub english { return "Unable to find closing tag for '" . $_[0]->{token}->stringify . "'"; }
Subroutine english: not called CC=1 SCAR=6.9
138  
139 package WWW::Shopify::Liquid::Exception::Parser::Operands;
140 38 ▶use base 'WWW::Shopify::Liquid::Exception::Parser';
Subroutine BEGIN: called CC=1 SCAR=0.0
141  
142 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
143 0 my $package = shift;
144 0 my $self = $package->SUPER::new(@_);
145 0 my ($token, $op1, $op, $op2) = @_;
146 0 $self->{operands} = [$op1, $op, $op2];
147 0 return $self;
148 }
149  
150 0 ▶sub english { return "All operands inside an expression must be joined by operators, under most conditions."; }
Subroutine english: not called CC=1 SCAR=6.9
151  
152 package WWW::Shopify::Liquid::Exception::Parser::NoOpen;
153 38 ▶use base 'WWW::Shopify::Liquid::Exception::Parser';
Subroutine BEGIN: called CC=1 SCAR=0.0
154 0 ▶sub english { return "Unable to find opening tag for '" . $_[0]->{token}->stringify . "'"; }
Subroutine english: not called CC=1 SCAR=6.9
155  
156 package WWW::Shopify::Liquid::Exception::Parser::Arguments;
157 38 ▶use base 'WWW::Shopify::Liquid::Exception::Parser';
Subroutine BEGIN: called CC=1 SCAR=0.0
158 0 ▶sub english {
Subroutine english: not called CC=9 SCAR=45.0
159 0 my ($self) = @_;
160 0 ▶ if ($self->error && ref($self->error) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error and ref $self->error eq 'ARRAY') { } 0 0 0
Condition0%0/3
$self->error and ref $self->error eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->error and ref $self->error eq "ARRAY"
$self->error ref $self->error eq "ARRAY"
Truth table0%0/3
A and B
A= $self->errorB= ref $self->error eq "ARRAY"
ABresult
0X0
100
111
161 0 my ($count, $min, $max) = @{$self->error};
162 0 ▶ return "Received $count arguments for '" . $_[0]->{token}->stringify . "', expected " . (defined $max ? ($min == $max ? "exactly $min" : "between $min and $max") : "at least $min") . " arguments" if $_[0]->{token} && $_[0]->{token}->can('stringify');
Branch: 3 branches
BranchTrueFalseTotal
if $_[0]{"token"} and $_[0]{"token"}->can("stringify") 0 0 0
defined $max ? : 0 0 0
$min == $max ? : 0 0 0
Condition0%0/3
$_[0]{"token"} and $_[0]{"token"}->can("stringify")
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0]{"token"} and $_[0]{"token"}->can("stringify")
$_[0]{"token"} $_[0]{"token"}->can("stringify")
Truth table0%0/3
A and B
A= $_[0]{"token"}B= $_[0]{"token"}->can("stringify")
ABresult
0X0
100
111
163 0 return "Invalid arguments.";
164 } else {
165 0 ▶ return "Invalid arguments for '" . $_[0]->{token}->stringify . "'" if $_[0]->{token} && $_[0]->{token}->can('stringify');
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"token"} and $_[0]{"token"}->can("stringify") 0 0 0
Condition0%0/3
$_[0]{"token"} and $_[0]{"token"}->can("stringify")
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0]{"token"} and $_[0]{"token"}->can("stringify")
$_[0]{"token"} $_[0]{"token"}->can("stringify")
Truth table0%0/3
A and B
A= $_[0]{"token"}B= $_[0]{"token"}->can("stringify")
ABresult
0X0
100
111
166 0 return "Invalid arguments.";
167 }
168 }
169  
170 package WWW::Shopify::Liquid::Exception::Parser::UnknownTag;
171 38 ▶use base 'WWW::Shopify::Liquid::Exception::Parser';
Subroutine BEGIN: called CC=1 SCAR=0.0
172 0 ▶sub english { return "Unknown tag '" . $_[0]->{token}->stringify . "'"; }
Subroutine english: not called CC=1 SCAR=6.9
173  
174 package WWW::Shopify::Liquid::Exception::Parser::NakedInnerTag;
175 38 ▶use base 'WWW::Shopify::Liquid::Exception::Parser';
Subroutine BEGIN: called CC=1 SCAR=0.0
176 0 ▶sub english { return "Inner tag " . $_[0]->{token}->stringify . " found without enclosing statement"; }
Subroutine english: not called CC=1 SCAR=6.9
177  
178 package WWW::Shopify::Liquid::Exception::Parser::UnknownFilter;
179 38 ▶use base 'WWW::Shopify::Liquid::Exception::Parser';
Subroutine BEGIN: called CC=1 SCAR=0.0
180 0 ▶sub english { return "Unknown filter '" . $_[0]->{token}->stringify . "'"; }
Subroutine english: not called CC=1 SCAR=6.9
181  
182 package WWW::Shopify::Liquid::Exception::Optimizer;
183 38 ▶use base 'WWW::Shopify::Liquid::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
184 0 ▶sub english { return "Optimizer exception"; }
Subroutine english: not called CC=1 SCAR=6.9
185  
186 package WWW::Shopify::Liquid::Exception::Renderer;
187 38 ▶use base 'WWW::Shopify::Liquid::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
188 0 ▶sub english { return "Rendering exception"; }
Subroutine english: not called CC=1 SCAR=6.9
189  
190 package WWW::Shopify::Liquid::Exception::Renderer::Unimplemented;
191 38 ▶use base 'WWW::Shopify::Liquid::Exception::Renderer';
Subroutine BEGIN: called CC=1 SCAR=0.0
192 0 ▶sub english { return "Unimplemented method"; }
Subroutine english: not called CC=1 SCAR=6.9
193  
194 package WWW::Shopify::Liquid::Exception::Renderer::Forbidden;
195 38 ▶use base 'WWW::Shopify::Liquid::Exception::Renderer';
Subroutine BEGIN: called CC=1 SCAR=0.0
196 0 ▶sub english { return "Forbidden operation"; }
Subroutine english: not called CC=1 SCAR=6.9
197  
198 package WWW::Shopify::Liquid::Exception::Renderer::Wrapped;
199 38 ▶use base 'WWW::Shopify::Liquid::Exception::Renderer';
Subroutine BEGIN: called CC=1 SCAR=0.0
200 0 ▶sub english { return "Wrapped internal exception"; }
Subroutine english: not called CC=1 SCAR=6.9
201  
202 package WWW::Shopify::Liquid::Exception::Renderer::Arguments;
203 38 ▶use base 'WWW::Shopify::Liquid::Exception::Renderer';
Subroutine BEGIN: called CC=1 SCAR=0.0
204 0 ▶sub english { print STDERR $_[0]->stack->as_string; return "Wrong type? Number of arguments."; }
Subroutine english: not called CC=1 SCAR=6.9
205  
206 38 1;
« lib/WWW/Shopify/Liquid/Filter/Date.pm ↑ Summary lib/WWW/Shopify/Liquid/Filter/Sort.pm »