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

filter: Statementstmt 76.4% 13 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod n/a totaltotal 75.0% 18 / 24 CC 1 SCAR 2.8
CC
1
Cov
76%
symbol
2.0
priority
2.0
BEGIN
1.3
CRAP 1.3
« blib/lib/WWW/Shopify/Liquid/Operator/PlusAssignment.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Dialect/Shopify.pm »
1 #!/usr/bin/perl
2 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5  
6 package WWW::Shopify::Liquid::Operator::Regex;
7 37 ▶use base 'WWW::Shopify::Liquid::Operator';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 0 ▶sub symbol { return '=~'; }
Subroutine symbol: not called CC=1 SCAR=6.9
9 0 ▶sub priority { return 5; }
Subroutine priority: not called CC=1 SCAR=6.9
10  
11 # Ensures that regexes can't be used maliciously.
12 37 ▶no re 'eval';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 37 ▶use re::engine::RE2 (-strict => 1, -max_mem => (2**24));
Subroutine BEGIN: called CC=1 SCAR=2.6
14  
15 sub operate {
16 my ($self, $hash, $action, $op1, $op2) = @_;
17 return undef unless defined $op1 && defined $op2;
18 my @groups = ($op1 =~ m/$op2/);
19 return undef if (int(@groups) == 0);
20 return \@groups;
21 }
22  
23 1;
« blib/lib/WWW/Shopify/Liquid/Operator/PlusAssignment.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Dialect/Shopify.pm »