| 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
Condition33%1/3
defined $value and ref $value
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
defined $name and length $name and not $name =~ /[\x00-\x1f\x7f]/u
defined $name and length $name
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
defined $tag_value and not ref $tag_value and not $tag_value =~ /[\x00-\x1f\x7f]/u
defined $tag_value and not ref $tag_value
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition44%4/9
JSON::PP::is_bool($locked) or not ref $locked and defined $locked and "$locked" =~ /\A[01]\z/u
not ref $locked and defined $locked and "$locked" =~ /\A[01]\z/u
not ref $locked and defined $locked
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
defined $candidate and not ref $candidate and length $candidate
defined $candidate and not ref $candidate
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | unless defined $candidate && !ref $candidate && length $candidate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 16 | ▶ | croak "App Configuration key must not be '.' or '..'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$candidate eq "." or $candidate eq ".."
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 ".."
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | if $candidate eq '.' || $candidate eq '..'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 16 | ▶ | croak 'App Configuration key must not contain percent or control characters' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | if $candidate =~ /[%\x00-\x1f\x7f]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 16 | ▶ | croak 'App Configuration key exceeds 10 KiB' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 23 | ▶ | croak "App Configuration $name must be a scalar" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | if ref $candidate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | croak "App Configuration $name must not be empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 23 | ▶ | if !$options{allow_empty} && !length $candidate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$options{"allow_empty"} or length $candidate
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 23 | ▶ | croak "App Configuration $name contains control characters" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | if $candidate =~ /[\x00-\x1f\x7f]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 23 | return $candidate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||