SDK/Storage/Blobs/BlobItem.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 75.0% 9 / 12 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 87.5% 7 / 8 Podpod 100% 2 / 2 totaltotal 86.1% 56 / 65 CC 9 SCAR 13.2
CC
9
Cov
88%
__ANON__
5.6
_normalize_etag
5.0
as_hashref
2.0
CRAP 3.7
« SDK/Storage/Queues/QueueItem.pm ↑ Summary SDK/Core/Request.pm »
1 3 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 3 class Azure::SDK::Storage::Blobs::BlobItem {
6 3 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 3 field $name :param :reader = undef;
9 3 field $etag :param :reader = undef;
10 3 field $last_modified :param :reader = undef;
11 3 field $content_length :param :reader = undef;
12 3 field $content_type :param :reader = undef;
13
14 3 field $etag_is_weak :reader = 0;
15
16 19 ▶ ADJUST {
Subroutine __ANON__: called CC=5 SCAR=17.2
17 19 ▶ croak 'Azure::SDK::Storage::Blobs::BlobItem requires a name'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and length $name 0 19 19
Condition33%1/3
defined $name and length $name
!ll&&!rl&&r
0019
MC/DC0%0/2
defined $name and length $name
defined $name length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
ABresult
0X0
100
111
18 unless defined $name && length $name;
19
20 19 ( $etag, $etag_is_weak ) = _normalize_etag($etag);
21
22 19 ▶ if ( defined $content_length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $content_length) 10 9 19
23 10 ▶ croak 'Azure::SDK::Storage::Blobs::BlobItem content_length must be numeric'
Branch: 1 branch
BranchTrueFalseTotal
unless $content_length =~ /\A[0-9]+\z/u 0 10 10
24 unless $content_length =~ /\A[0-9]+\z/;
25 10 $content_length = 0 + $content_length;
26 }
27 }
28
29 # The service is not self-consistent about quoting: the ETag response header
30 # is quoted, the <Etag> listing element is not.
31 5 ▶ sub normalize_etag ( $class, $value ) {
Subroutine normalize_etag: called CC=1 SCAR=0.0
Pod documented
32 5 my ($normalized) = _normalize_etag($value);
33 5 return $normalized;
34 }
35
36 # Quoting differences collapse, strength does not: RFC 9110 requires a strong
37 # comparison for If-Match, so folding W/"tag" into "tag" would let a weak
38 # validator be used as a strong precondition.
39 24 ▶ sub _normalize_etag ($value) {
Subroutine _normalize_etag: called CC=5 SCAR=16.1
40 24 ▶ return ( undef, 0 ) unless defined $value && length $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and length $value 3 21 24
Condition100%3/3
defined $value and length $value
!ll&&!rl&&r
2121
MC/DC100%2/2
defined $value and length $value
defined $value length $value
Truth table100%3/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
41
42 21 my $normalized = $value;
43 21 $normalized =~ s/\A\s+|\s+\z//g;
44
45 21 ▶ my $weak = $normalized =~ s/\AW\/// ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$normalized =~ s[\AW/][]u ? : 3 18 21
46
47 21 $normalized =~ s/\A"(.*)"\z/$1/s;
48
49 21 ▶ return length $normalized ? ( $normalized, $weak ) : ( undef, 0 );
Branch: 1 branch
BranchTrueFalseTotal
length $normalized ? : 21 0 21
50 }
51
52 0 ▶ method as_hashref () {
Subroutine as_hashref: not called CC=1 SCAR=6.9
Pod documented
53 return {
54 0 name => $name,
55 etag => $etag,
56 etag_is_weak => $etag_is_weak,
57 last_modified => $last_modified,
58 content_length => $content_length,
59 content_type => $content_type,
60 };
61 }
62 }
63
64 3 1;
65
66 __END__
« SDK/Storage/Queues/QueueItem.pm ↑ Summary SDK/Core/Request.pm »