SDK/AppConfiguration/SyncToken.pm

filter: Statementstmt 100% 36 / 36 Branchbran 78.5% 11 / 14 Conditioncond 66.6% 6 / 9 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 87.6% 64 / 73 CC 12 SCAR 17.2
CC
12
Cov
90%
_add_tokens
9.2
_sequence_is_newer
3.2
send
2.0
CRAP 5.6
« SDK/Core/Policy/Retry.pm ↑ Summary SDK/Core/Headers.pm »
1 2 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 2 ▶use Azure::SDK::Core::Policy;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 2 class Azure::SDK::AppConfiguration::SyncToken :isa(Azure::SDK::Core::Policy) {
8 2 field %tokens;
9
10 26 ▶ method send ($context, $request, $next) {
Subroutine send: called CC=2 SCAR=6.9
Pod documented
11 26 my $header = join ',', map { $tokens{$_}{raw} } sort keys %tokens;
12 26 ▶ $request->set_header('Sync-Token', $header) if length $header;
Branch: 1 branch
BranchTrueFalseTotal
if length $header 3 23 26
13
14 26 my $response = $next->($context, $request);
15 26 $self->_add_tokens($response->header('sync-token'));
16 26 return $response;
17 }
18
19 26 ▶ method _add_tokens ($header) {
Subroutine _add_tokens: called CC=9 SCAR=22.2
20 26 ▶ return unless defined $header && !ref $header;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $header and not ref $header 23 3 26
Condition66%2/3
defined $header and not ref $header
!ll&&!rl&&r
2303
MC/DC50%1/2
defined $header and not ref $header
defined $header not ref $header
Truth table66%2/3
A and not(B)
A= defined $headerB= not ref $header
ABresult
0X0
100
111
21
22 3 for my $raw (split /,/, $header) {
23 6 $raw =~ s/\A\s+|\s+\z//g;
24 6 my $sequence_at = index($raw, ';sn=');
25 6 ▶ next if $sequence_at < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $sequence_at < 1 1 5 6
26
27 5 my $id_and_value = substr($raw, 0, $sequence_at);
28 5 my $sequence = substr($raw, $sequence_at + 4);
29 5 my $equals_at = index($id_and_value, '=');
30 5 ▶ next if $equals_at < 1 || $sequence !~ /\A\d+\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $equals_at < 1 or not $sequence =~ /\A\d+\z/u 0 5 5
Condition33%1/3
$equals_at < 1 or not $sequence =~ /\A\d+\z/u
l!l&&r!l&&!r
005
MC/DC0%0/2
$equals_at < 1 or not $sequence =~ /\A\d+\z/u
$equals_at < 1 not $sequence =~ /\A\d+\z/u
Truth table33%1/3
A or not(B)
A= $equals_at < 1B= not $sequence =~ /\A\d+\z/u
ABresult
1X1
011
000
31
32 5 my $id = substr($id_and_value, 0, $equals_at);
33 5 $sequence =~ s/\A0+(?=\d)//;
34 next if exists $tokens{$id}
35 5 ▶ && !_sequence_is_newer($sequence, $tokens{$id}{sequence});
Branch: 1 branch
BranchTrueFalseTotal
if exists $tokens{$id} and not _sequence_is_newer($sequence, $tokens{$id}{"sequence"}) 1 4 5
Condition100%3/3
exists $tokens{$id} and not _sequence_is_newer($sequence, $tokens{$id}{"sequence"})
!ll&&!rl&&r
311
MC/DC100%2/2
exists $tokens{$id} and not _sequence_is_newer($sequence, $tokens{$id}{"sequence"})
exists $tokens{$id} not _sequence_is_newer($sequence, $tokens{$id}{"sequence"})
Truth table100%3/3
A and not(B)
A= exists $tokens{$id}B= not _sequence_is_newer($sequence, $tokens{$id}{"sequence"})
ABresult
0X0
100
111
36 4 $tokens{$id} = {
37 raw => $raw,
38 sequence => $sequence,
39 };
40 }
41 }
42
43 2 ▶ sub _sequence_is_newer ($candidate, $existing) {
Subroutine _sequence_is_newer: called CC=3 SCAR=11.7
44 2 ▶ return 1 if length($candidate) > length($existing);
Branch: 1 branch
BranchTrueFalseTotal
if length $candidate > length $existing 0 2 2
45 2 ▶ return 0 if length($candidate) < length($existing);
Branch: 1 branch
BranchTrueFalseTotal
if length $candidate < length $existing 0 2 2
46 2 return $candidate gt $existing;
47 }
48 }
49
50 2 1;
51
52 __END__
« SDK/Core/Policy/Retry.pm ↑ Summary SDK/Core/Headers.pm »