SDK/Storage/Tables/EntityContinuation.pm

filter: Statementstmt 100% 47 / 47 Branchbran 54.5% 12 / 22 Conditioncond 40.7% 11 / 27 MC/DCmcdc 6.2% 1 / 16 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 65.3% 81 / 124 CC 21 SCAR 24.9
CC
21
Cov
73%
decode
22.7
encode
6.5
_validate_part
5.4
CRAP 12.1
« SDK/Storage/Blobs/ConnectionString.pm ↑ Summary SDK/Storage/Blobs/SharedKey.pm »
1 6 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 6 class Azure::SDK::Storage::Tables::EntityContinuation {
6 6 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶ use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶ use MIME::Base64 qw(decode_base64 encode_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
9
10 6 ▶ use constant MAX_TOKEN_LENGTH => 16 * 1024;
Subroutine BEGIN: called CC=1 SCAR=0.0
11
12 2 ▶ sub encode ( $class, $partition_key, $row_key ) {
Subroutine encode: called CC=6 SCAR=18.7
Pod undocumented
13 2 ▶ return undef unless defined $partition_key || defined $row_key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $partition_key or defined $row_key 1 1 2
Condition66%2/3
defined $partition_key or defined $row_key
l!l&&r!l&&!r
101
MC/DC50%1/2
defined $partition_key or defined $row_key
defined $partition_key defined $row_key
Truth table66%2/3
A or B
A= defined $partition_keyB= defined $row_key
ABresult
1X1
011
000
14 1 _validate_part('partition key', $partition_key);
15 1 ▶ _validate_part('row key', $row_key) if defined $row_key;
Branch: 1 branch
BranchTrueFalseTotal
if defined $row_key 1 0 1
16 1 ▶ croak 'Table entity continuation row key requires a partition key'
Branch: 1 branch
BranchTrueFalseTotal
if defined $row_key and not defined $partition_key 0 1 1
Condition33%1/3
defined $row_key and not defined $partition_key
!ll&&!rl&&r
010
MC/DC0%0/2
defined $row_key and not defined $partition_key
defined $row_key not defined $partition_key
Truth table33%1/3
A and not(B)
A= defined $row_keyB= not defined $partition_key
ABresult
0X0
100
111
17 if defined $row_key && !defined $partition_key;
18
19 1 my $json = JSON::PP->new->utf8->canonical->encode({
20 p => $partition_key,
21 r => $row_key,
22 });
23 1 my $token = encode_base64($json, '');
24 1 $token =~ tr{+/}{-_};
25 1 $token =~ s/=+\z//;
26 1 return $token;
27 }
28
29 1 ▶ sub decode ( $class, $token ) {
Subroutine decode: called CC=13 SCAR=31.2
Pod undocumented
30 1 ▶ croak 'Table entity continuation token is required'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $token and not ref $token and length $token 0 1 1
Condition33%2/6
defined $token and not ref $token and length $token
!ll&&!rl&&r
001
defined $token and not ref $token
!ll&&!rl&&r
001
MC/DC0%0/3
defined $token and not ref $token and length $token
defined $token not ref $token length $token
Truth table25%1/4
A and not(B) and C
A= defined $tokenB= not ref $tokenC= length $token
ABCresult
0XX0
10X0
1100
1111
31 unless defined $token && !ref $token && length $token;
32 1 ▶ croak 'Table entity continuation token is too long'
Branch: 1 branch
BranchTrueFalseTotal
if length $token > 16384 0 1 1
33 if length($token) > MAX_TOKEN_LENGTH;
34 1 ▶ croak 'Table entity continuation token is malformed'
Branch: 1 branch
BranchTrueFalseTotal
unless $token =~ /\A[A-Za-z0-9_-]+\z/u 0 1 1
35 unless $token =~ /\A[A-Za-z0-9_-]+\z/;
36
37 1 my $encoded = $token;
38 1 $encoded =~ tr{-_}{+/};
39 1 $encoded .= '=' x ((4 - length($encoded) % 4) % 4);
40 1 my $document = eval {
41 1 JSON::PP->new->utf8->decode(decode_base64($encoded));
42 };
43 croak 'Table entity continuation token is malformed'
44 if $@ || ref $document ne 'HASH'
45 1 ▶ || grep { $_ ne 'p' && $_ ne 'r' } keys $document->%*;
Branch: 1 branch
BranchTrueFalseTotal
if $@ or ref $document ne "HASH" or grep {$_ ne "p" and $_ ne "r";} keys %$document 0 1 1
Condition44%4/9
$@ or ref $document ne "HASH" or grep {$_ ne "p" and $_ ne "r";} keys %$document
l!l&&r!l&&!r
001
$@ or ref $document ne "HASH"
l!l&&r!l&&!r
001
$_ ne 'p' && $_ ne 'r'
!ll&&!rl&&r
110
MC/DC0%0/3
$@ or ref $document ne "HASH" or grep {$_ ne "p" and $_ ne "r";} keys %$document
$@ ref $document ne "HASH" grep {$_ ne "p" and $_ ne "r";} keys %$document
MC/DC0%0/2
$_ ne 'p' && $_ ne 'r'
$_ ne 'p' $_ ne 'r'
Truth table25%1/4
A or B or C
A= $@B= ref $document ne "HASH"C= grep {$_ ne "p" and $_ ne "r";} keys %$document
ABCresult
1XX1
01X1
0011
0000
Truth table66%2/3
A && B
A= $_ ne 'p'B= $_ ne 'r'
ABresult
0X0
100
111
46 1 _validate_part('partition key', $document->{p});
47 1 ▶ _validate_part('row key', $document->{r}) if defined $document->{r};
Branch: 1 branch
BranchTrueFalseTotal
if defined $document->{"r"} 1 0 1
48 croak 'Table entity continuation row key requires a partition key'
49 1 ▶ if defined $document->{r} && !defined $document->{p};
Branch: 1 branch
BranchTrueFalseTotal
if defined $document->{"r"} and not defined $document->{"p"} 0 1 1
Condition33%1/3
defined $document->{"r"} and not defined $document->{"p"}
!ll&&!rl&&r
010
MC/DC0%0/2
defined $document->{"r"} and not defined $document->{"p"}
defined $document->{"r"} not defined $document->{"p"}
Truth table33%1/3
A and not(B)
A= defined $document->{"r"}B= not defined $document->{"p"}
ABresult
0X0
100
111
50 1 return ($document->{p}, $document->{r});
51 }
52
53 4 ▶ sub _validate_part ( $label, $value ) {
Subroutine _validate_part: called CC=4 SCAR=16.9
54 4 ▶ croak "Table entity continuation $label is required"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value 0 4 4
Condition33%1/3
defined $value and not ref $value
!ll&&!rl&&r
004
MC/DC0%0/2
defined $value and not ref $value
defined $value not ref $value
Truth table33%1/3
A and not(B)
A= defined $valueB= not ref $value
ABresult
0X0
100
111
55 unless defined $value && !ref $value;
56 4 ▶ croak "Table entity continuation $label contains control characters"
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /[\x00-\x1f\x7f]/u 0 4 4
57 if $value =~ /[\x00-\x1f\x7f]/;
58 }
59 }
60
61 6 1;
62
63 __END__
« SDK/Storage/Blobs/ConnectionString.pm ↑ Summary SDK/Storage/Blobs/SharedKey.pm »