SDK/AppConfiguration/ConfigurationSetting.pm

filter: Statementstmt 98.2% 57 / 58 Branchbran 53.5% 15 / 28 Conditioncond 36.1% 13 / 36 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 91.6% 11 / 12 Podpod 100% 3 / 3 totaltotal 63.4% 99 / 156 CC 28 SCAR 28.5
CC
28
Cov
70%
__ANON__
31.9
_validate_key
14.0
_validate_optional_text
7.1
CRAP 17.3
« SDK/AppConfiguration/Serializer.pm ↑ Summary SDK/Storage/Tables/Serializer.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 class Azure::SDK::AppConfiguration::ConfigurationSetting {
6 2 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶ use bytes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶ use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9
10 2 field $key :param :reader = undef;
11 2 field $label :param :reader = undef;
12 2 field $value :param :reader = undef;
13 2 field $content_type :param :reader = undef;
14 2 field $etag :param :reader = undef;
15 2 field $last_modified :param :reader = undef;
16 2 field $tags :param = {};
17 2 field $locked :param :reader = 0;
18
19 8 ▶ ADJUST {
Subroutine __ANON__: called CC=16 SCAR=34.6
20 8 _validate_key($key);
21 8 _validate_optional_text('label', $label, allow_empty => 0);
22 8 ▶ croak 'App Configuration value must be a scalar'
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and ref $value 0 8 8
Condition33%1/3
defined $value and ref $value
!ll&&!rl&&r
080
MC/DC0%0/2
defined $value and ref $value
defined $value ref $value
Truth table33%1/3
A and B
A= defined $valueB= ref $value
ABresult
0X0
100
111
23 if defined $value && ref $value;
24 8 _validate_optional_text('content_type', $content_type);
25 8 _validate_optional_text('etag', $etag, allow_empty => 0);
26 8 _validate_optional_text('last_modified', $last_modified, allow_empty => 0);
27
28 8 ▶ croak 'App Configuration tags must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tags eq "HASH" 0 8 8
29 unless ref $tags eq 'HASH';
30 8 my %copy;
31 8 for my $name (keys %{$tags}) {
32 7 ▶ croak 'App Configuration tag name must be a non-empty scalar without control characters'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and length $name and not $name =~ /[\x00-\x1f\x7f]/u 0 7 7
Condition33%2/6
defined $name and length $name and not $name =~ /[\x00-\x1f\x7f]/u
!ll&&!rl&&r
007
defined $name and length $name
!ll&&!rl&&r
007
MC/DC0%0/3
defined $name and length $name and not $name =~ /[\x00-\x1f\x7f]/u
defined $name length $name not $name =~ /[\x00-\x1f\x7f]/u
Truth table25%1/4
A and B and not(C)
A= defined $nameB= length $nameC= not $name =~ /[\x00-\x1f\x7f]/u
ABCresult
0XX0
10X0
1100
1111
33 unless defined $name && length $name
34 && $name !~ /[\x00-\x1f\x7f]/;
35 7 my $tag_value = $tags->{$name};
36 7 ▶ croak "App Configuration tag '$name' value must be a scalar without control characters"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tag_value and not ref $tag_value and not $tag_value =~ /[\x00-\x1f\x7f]/u 0 7 7
Condition33%2/6
defined $tag_value and not ref $tag_value and not $tag_value =~ /[\x00-\x1f\x7f]/u
!ll&&!rl&&r
007
defined $tag_value and not ref $tag_value
!ll&&!rl&&r
007
MC/DC0%0/3
defined $tag_value and not ref $tag_value and not $tag_value =~ /[\x00-\x1f\x7f]/u
defined $tag_value not ref $tag_value not $tag_value =~ /[\x00-\x1f\x7f]/u
Truth table25%1/4
A and not(B) and not(C)
A= defined $tag_valueB= not ref $tag_valueC= not $tag_value =~ /[\x00-\x1f\x7f]/u
ABCresult
0XX0
10X0
1100
1111
37 unless defined $tag_value && !ref $tag_value
38 && $tag_value !~ /[\x00-\x1f\x7f]/;
39 7 $copy{$name} = "$tag_value";
40 }
41 8 $tags = \%copy;
42
43 8 ▶ croak 'App Configuration locked must be boolean'
Branch: 1 branch
BranchTrueFalseTotal
unless JSON::PP::is_bool($locked) or not ref $locked and defined $locked and "$locked" =~ /\A[01]\z/u 0 8 8
Condition44%4/9
JSON::PP::is_bool($locked) or not ref $locked and defined $locked and "$locked" =~ /\A[01]\z/u
l!l&&r!l&&!r
620
not ref $locked and defined $locked and "$locked" =~ /\A[01]\z/u
!ll&&!rl&&r
002
not ref $locked and defined $locked
!ll&&!rl&&r
002
MC/DC0%0/4
JSON::PP::is_bool($locked) or not ref $locked and defined $locked and "$locked" =~ /\A[01]\z/u
JSON::PP::is_bool($locked) not ref $locked defined $locked "$locked" =~ /\A[01]\z/u
Truth table40%2/5
A or not(B) and C and D
A= JSON::PP::is_bool($locked)B= not ref $lockedC= defined $lockedD= "$locked" =~ /\A[01]\z/u
ABCDresult
1XXX1
01111
00XX0
010X0
01100
44 unless JSON::PP::is_bool($locked)
45 || (!ref($locked) && defined($locked) && "$locked" =~ /\A[01]\z/);
46 8 ▶ $locked = $locked ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$locked ? : 0 8 8
47 }
48
49 3 ▶ method tags () {
Subroutine tags: called CC=1 SCAR=0.0
Pod documented
50 3 return { %{$tags} };
51 }
52
53 8 ▶ sub validate_key ($class, $candidate) {
Subroutine validate_key: called CC=1 SCAR=0.0
Pod documented
54 8 return _validate_key($candidate);
55 }
56
57 0 ▶ sub validate_label ($class, $candidate) {
Subroutine validate_label: not called CC=1 SCAR=6.9
Pod documented
58 0 return _validate_optional_text('label', $candidate, allow_empty => 0);
59 }
60
61 16 ▶ sub _validate_key ($candidate) {
Subroutine _validate_key: called CC=8 SCAR=26.4
62 16 ▶ croak 'App Configuration key is required'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $candidate and not ref $candidate and length $candidate 0 16 16
Condition33%2/6
defined $candidate and not ref $candidate and length $candidate
!ll&&!rl&&r
0016
defined $candidate and not ref $candidate
!ll&&!rl&&r
0016
MC/DC0%0/3
defined $candidate and not ref $candidate and length $candidate
defined $candidate not ref $candidate length $candidate
Truth table25%1/4
A and not(B) and C
A= defined $candidateB= not ref $candidateC= length $candidate
ABCresult
0XX0
10X0
1100
1111
63 unless defined $candidate && !ref $candidate && length $candidate;
64 16 ▶ croak "App Configuration key must not be '.' or '..'"
Branch: 1 branch
BranchTrueFalseTotal
if $candidate eq "." or $candidate eq ".." 0 16 16
Condition33%1/3
$candidate eq "." or $candidate eq ".."
l!l&&r!l&&!r
0016
MC/DC0%0/2
$candidate eq "." or $candidate eq ".."
$candidate eq "." $candidate eq ".."
Truth table33%1/3
A or B
A= $candidate eq "."B= $candidate eq ".."
ABresult
1X1
011
000
65 if $candidate eq '.' || $candidate eq '..';
66 16 ▶ croak 'App Configuration key must not contain percent or control characters'
Branch: 1 branch
BranchTrueFalseTotal
if $candidate =~ /[%\x00-\x1f\x7f]/u 0 16 16
67 if $candidate =~ /[%\x00-\x1f\x7f]/;
68 16 ▶ croak 'App Configuration key exceeds 10 KiB'
Branch: 1 branch
BranchTrueFalseTotal
if &bytes::length($candidate) > 10240 0 16 16
69 if bytes::length($candidate) > 10 * 1024;
70 16 return $candidate;
71 }
72
73 32 ▶ sub _validate_optional_text ($name, $candidate, %options) {
Subroutine _validate_optional_text: called CC=6 SCAR=19.6
74 32 ▶ return undef unless defined $candidate;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $candidate 9 23 32
75 23 ▶ croak "App Configuration $name must be a scalar"
Branch: 1 branch
BranchTrueFalseTotal
if ref $candidate 0 23 23
76 if ref $candidate;
77 croak "App Configuration $name must not be empty"
78 23 ▶ if !$options{allow_empty} && !length $candidate;
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"allow_empty"} or length $candidate 0 23 23
Condition33%1/3
$options{"allow_empty"} or length $candidate
l!l&&r!l&&!r
0230
MC/DC0%0/2
$options{"allow_empty"} or length $candidate
$options{"allow_empty"} length $candidate
Truth table33%1/3
A or B
A= $options{"allow_empty"}B= length $candidate
ABresult
1X1
011
000
79 23 ▶ croak "App Configuration $name contains control characters"
Branch: 1 branch
BranchTrueFalseTotal
if $candidate =~ /[\x00-\x1f\x7f]/u 0 23 23
80 if $candidate =~ /[\x00-\x1f\x7f]/;
81 23 return $candidate;
82 }
83 }
84
85 2 1;
86
87 __END__
« SDK/AppConfiguration/Serializer.pm ↑ Summary SDK/Storage/Tables/Serializer.pm »