Jmespath.pm

filter: Statementstmt 91.3% 42 / 46 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 86.6% 13 / 15 Podpod 0.0% 0 / 2 totaltotal 83.9% 68 / 81 CC 7 SCAR 11.5
CC
7
Cov
88%
search
7.2
compile
2.0
__ANON__
2.0
CRAP 3.2
« Jmespath/ArityException.pm ↑ Summary Jmespath/Parser.pm »
1 package Jmespath;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Jmespath::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Jmespath::Visitor;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use JSON qw(encode_json decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 our $VERSION = '0.02';
10 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 0 ▶sub compile {
Subroutine compile: not called CC=1 SCAR=6.9
Pod undocumented
14 0 my ( $class, $expression ) = @_;
15 0 return Jmespath::Parser->new->parse( Encode::encode_utf8($expression) );
16 }
17  
18 861 ▶sub search {
Subroutine search: called CC=7 SCAR=19.8
Pod undocumented
19 861 my ( $class, $expression, $data, $options ) = @_;
20 861 my ($result);
21 861 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
22 861 $result = Jmespath::Parser->new->parse( $expression )
23 ->search( $data, $options );
24 146 ▶ } catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 146 $_->throw;
26 861 };
27 715 ▶ return $result if not defined $result;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result 84 631 715
28  
29 # JSON block result
30 631 ▶ if ( ( ref ($result) eq 'HASH' ) or
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq "HASH" or ref $result eq "ARRAY") 312 319 631
Condition100%3/3
ref $result eq "HASH" or ref $result eq "ARRAY"
l!l&&r!l&&!r
53259319
MC/DC100%2/2
ref $result eq "HASH" or ref $result eq "ARRAY"
ref $result eq "HASH" ref $result eq "ARRAY"
Truth table100%3/3
A or B
A= ref $result eq "HASH"B= ref $result eq "ARRAY"
ABresult
1X1
011
000
31 ( ref ($result) eq 'ARRAY' ) ) {
32 312 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
33 312 $result = JSON->new
34 ->utf8(1)
35 ->allow_nonref
36 ->space_after
37 ->allow_blessed(1)
38 ->convert_blessed(1)
39 ->encode( $result );
40 312 return $result;
41 0 ▶ } catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 Jmespath::ValueException->new( message => "cannot encode" )->throw;
43 312 };
44 }
45  
46 631 ▶ if ( $result =~ /[0-9]+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result =~ /[0-9]+/u) 381 250 631
47 381 return $result;
48 }
49  
50 # Unquoted string result
51 250 ▶ if ( $ENV{JP_UNQUOTED} == 0 or
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"JP_UNQUOTED"} == 0 or not defined $ENV{"JP_UNQUOTED"}) 0 250 250
Condition33%1/3
$ENV{"JP_UNQUOTED"} == 0 or not defined $ENV{"JP_UNQUOTED"}
l!l&&r!l&&!r
00250
MC/DC0%0/2
$ENV{"JP_UNQUOTED"} == 0 or not defined $ENV{"JP_UNQUOTED"}
$ENV{"JP_UNQUOTED"} == 0 not defined $ENV{"JP_UNQUOTED"}
Truth table33%1/3
A or not(B)
A= $ENV{"JP_UNQUOTED"} == 0B= not defined $ENV{"JP_UNQUOTED"}
ABresult
1X1
011
000
52 not defined $ENV{JP_UNQUOTED} ) {
53 0 $result = q{"} . $result . q{"};
54 }
55 250 return $result;
56 }
57  
58 2 1;
59  
60 __END__
« Jmespath/ArityException.pm ↑ Summary Jmespath/Parser.pm »