Escape.pm

filter: Statementstmt 50.0% 10 / 20 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 44.8% 13 / 29 CC 2 SCAR 10.4
CC
2
Cov
45%
escape
6.0
new
2.0
BEGIN
1.0
CRAP 2.8
« HTTP.pm ↑ Summary Commands/Status.pm »
1 # Copyright (C) 2022 Horimoto Yasuhiro <horimoto@clear-code.com>
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
15  
16 package Groonga::Escape;
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
24 0 my ($class, %args) = @_;
25 0 my $self = {%args};
26  
27 0 return bless $self, $class;
28 }
29  
30 0 ▶sub escape {
Subroutine escape: not called CC=2 SCAR=17.9
Pod undocumented
31 0 my ($class, $raw_query) = @_;
32 0 ▶ unless($raw_query) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raw_query) 0 0 0
33 0 croak "Invalid arguments: ${raw_query}";
34 }
35  
36 0 my $escape = '\\';
37 0 my $escaped_query = $raw_query;
38 0 $escaped_query =~ s/([+\-><~*()"\\:])/$escape$1/g;
39  
40 0 return $escaped_query;
41 }
42  
43 1 1;
« HTTP.pm ↑ Summary Commands/Status.pm »