SDK/Storage/Tables/Entity.pm

filter: Statementstmt 98.3% 58 / 59 Branchbran 69.2% 18 / 26 Conditioncond 50.0% 16 / 32 MC/DCmcdc 25.0% 4 / 16 Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 4 totaltotal 72.0% 108 / 150 CC 28 SCAR 24.5
CC
28
Cov
79%
__ANON__
19.4
_validate_property_name
11.1
_validate_key
6.8
CRAP 11.6
« SDK/Storage/Tables/TransactionOperation.pm ↑ Summary SDK/Storage/Blobs.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 ▶use Azure::SDK::Storage::Tables::EntityProperty;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 6 class Azure::SDK::Storage::Tables::Entity {
8 6 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 6 field $partition_key :param :reader;
12 6 field $row_key :param :reader;
13 6 field $timestamp :param :reader = undef;
14 6 field $etag :param :reader = undef;
15 6 field $properties :param :reader = {};
16 6 field $property_types :param = {};
17
18 132 ▶ ADJUST {
Subroutine __ANON__: called CC=17 SCAR=29.7
19 132 _validate_key('partition_key', $partition_key);
20 132 _validate_key('row_key', $row_key);
21 132 ▶ croak 'Table entity properties must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $properties eq "HASH" 0 132 132
22 unless ref $properties eq 'HASH';
23 132 ▶ croak 'Table entity property_types must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $property_types eq "HASH" 0 132 132
24 unless ref $property_types eq 'HASH';
25 132 ▶ croak 'Table entity exceeds 252 custom properties'
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %$properties > 252 1 131 132
26 if scalar(keys $properties->%*) > 252;
27 131 ▶ croak 'Table entity ETag must not contain control characters'
Branch: 1 branch
BranchTrueFalseTotal
if defined $etag and ref $etag || !length($etag) || $etag =~ /[\x00-\x1f\x7f]/u 0 131 131
Condition44%4/9
defined $etag and ref $etag || !length($etag) || $etag =~ /[\x00-\x1f\x7f]/u
!ll&&!rl&&r
120110
ref $etag or not length $etag or $etag =~ /[\x00-\x1f\x7f]/u
l!l&&r!l&&!r
0011
ref $etag or not length $etag
l!l&&r!l&&!r
0011
MC/DC0%0/4
defined $etag and ref $etag || !length($etag) || $etag =~ /[\x00-\x1f\x7f]/u
defined $etag ref $etag not length $etag $etag =~ /[\x00-\x1f\x7f]/u
Truth table40%2/5
A and B or not(C) or D
A= defined $etagB= ref $etagC= not length $etagD= $etag =~ /[\x00-\x1f\x7f]/u
ABCDresult
0XXX0
10000
11XX1
101X1
10011
28 if defined $etag && (ref($etag) || !length($etag) || $etag =~ /[\x00-\x1f\x7f]/);
29
30 131 my (%values, %types);
31 131 for my $name (keys $properties->%*) {
32 219 _validate_property_name($name);
33 217 my $value = $properties->{$name};
34 217 ▶ if (blessed($value)
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa('Azure::SDK::Storage::Tables::EntityProperty')) { } 11 206 217
Condition66%2/3
builtin::blessed($value) and $value->isa("Azure::SDK::Storage::Tables::EntityProperty")
!ll&&!rl&&r
206011
MC/DC50%1/2
builtin::blessed($value) and $value->isa("Azure::SDK::Storage::Tables::EntityProperty")
builtin::blessed($value) $value->isa("Azure::SDK::Storage::Tables::EntityProperty")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Azure::SDK::Storage::Tables::EntityProperty")
ABresult
0X0
100
111
35 && $value->isa('Azure::SDK::Storage::Tables::EntityProperty')) {
36 croak "Table entity property '$name' specifies its type twice"
37 11 ▶ if exists $property_types->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $property_types->{$name} 0 11 11
38 11 $values{$name} = $value->value;
39 11 $types{$name} = $value->type;
40 }
41 else {
42 206 $values{$name} = $value;
43 206 ▶ $types{$name} = $property_types->{$name} // 'Edm.String'
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 205 1 206
Condition100%2/2
$property_types->{$name} // "Edm.String"
l!l
13192
MC/DC100%1/1
$property_types->{$name} // "Edm.String"
$property_types->{$name}
Truth table100%2/2
A
A= $property_types->{$name}
Aresult
11
00
44 if defined $value;
45 }
46 }
47 129 for my $name (keys $property_types->%*) {
48 croak "Table entity property type '$name' has no property value"
49 13 ▶ unless exists $properties->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $properties->{$name} 0 13 13
50 }
51
52 129 for my $name (keys %types) {
53 my $validated = Azure::SDK::Storage::Tables::EntityProperty->new(
54 type => $types{$name},
55 216 value => $values{$name},
56 );
57 216 $values{$name} = $validated->value;
58 216 $types{$name} = $validated->type;
59 }
60
61 129 $properties = \%values;
62 129 $property_types = \%types;
63 }
64
65 94 ▶ method property_type ($name) {
Subroutine property_type: called CC=1 SCAR=0.0
Pod undocumented
66 94 return $property_types->{$name};
67 }
68
69 0 ▶ method property_types () {
Subroutine property_types: not called CC=1 SCAR=6.9
Pod undocumented
70 0 return { $property_types->%* };
71 }
72
73 3 ▶ method with_etag ($new_etag) {
Subroutine with_etag: called CC=1 SCAR=0.0
Pod undocumented
74 return __CLASS__->new(
75 3 partition_key => $partition_key,
76 row_key => $row_key,
77 timestamp => $timestamp,
78 etag => $new_etag,
79 properties => { $properties->%* },
80 property_types => { $property_types->%* },
81 );
82 }
83
84 11 ▶ sub validate_property_name ( $class, $name ) {
Subroutine validate_property_name: called CC=1 SCAR=0.0
Pod undocumented
85 11 return _validate_property_name($name);
86 }
87
88 264 ▶ sub _validate_key ( $label, $value ) {
Subroutine _validate_key: called CC=5 SCAR=19.2
89 264 ▶ croak "Table entity $label is required"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value 0 264 264
Condition33%1/3
defined $value and not ref $value
!ll&&!rl&&r
00264
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
90 unless defined $value && !ref $value;
91 264 ▶ croak "Table entity $label must not exceed 1024 characters"
Branch: 1 branch
BranchTrueFalseTotal
if length $value > 1024 0 264 264
92 if length($value) > 1024;
93 264 ▶ croak "Table entity $label contains a character not permitted by Table Storage"
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ m[[/\\#?\x00-\x1f\x7f-\x9f]]u 0 264 264
94 if $value =~ m{[/\\#?\x00-\x1f\x7f-\x9f]};
95 }
96
97 230 ▶ sub _validate_property_name ($name) {
Subroutine _validate_property_name: called CC=8 SCAR=24.0
98 230 ▶ croak 'Table entity property name must be an identifier of at most 255 characters'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and not ref $name and length $name <= 255 and $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/u 2 228 230
Condition44%4/9
defined $name and not ref $name and length $name <= 255 and $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/u
!ll&&!rl&&r
02228
defined $name and not ref $name and length $name <= 255
!ll&&!rl&&r
00230
defined $name and not ref $name
!ll&&!rl&&r
00230
MC/DC25%1/4
defined $name and not ref $name and length $name <= 255 and $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/u
defined $name not ref $name length $name <= 255 $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/u
Truth table40%2/5
A and not(B) and C and D
A= defined $nameB= not ref $nameC= length $name <= 255D= $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/u
ABCDresult
0XXX0
10XX0
110X0
11100
11111
99 unless defined $name
100 && !ref $name
101 && length($name) <= 255
102 && $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/;
103 228 ▶ croak "Table entity property name '$name' is reserved"
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "PartitionKey" or $name eq "RowKey" or $name eq "Timestamp" 1 227 228
Condition50%3/6
$name eq "PartitionKey" or $name eq "RowKey" or $name eq "Timestamp"
l!l&&r!l&&!r
01227
$name eq "PartitionKey" or $name eq "RowKey"
l!l&&r!l&&!r
00228
MC/DC33%1/3
$name eq "PartitionKey" or $name eq "RowKey" or $name eq "Timestamp"
$name eq "PartitionKey" $name eq "RowKey" $name eq "Timestamp"
Truth table50%2/4
A or B or C
A= $name eq "PartitionKey"B= $name eq "RowKey"C= $name eq "Timestamp"
ABCresult
1XX1
01X1
0011
0000
104 if $name eq 'PartitionKey' || $name eq 'RowKey' || $name eq 'Timestamp';
105 227 return $name;
106 }
107 }
108
109 6 1;
110
111 __END__
« SDK/Storage/Tables/TransactionOperation.pm ↑ Summary SDK/Storage/Blobs.pm »