| 1 | package Amazon::API::EndpointResolver; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use parent qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use Amazon::API::Utils qw(slurp_json); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use File::ShareDir qw(dist_file); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 9 | our $VERSION = '2.8.2'; ## no critic (RequireInterpolationOfMetachars) | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 9 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 9 | Readonly::Hash my %FUNCTIONS => ( | |||||||||||||||||||||||||||||||||||||||||
| 20 | booleanEquals => '_boolean_equals', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | getAttr => '_get_attr', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | isSet => '_is_set', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | not => '_not', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | stringEquals => '_string_equals', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | substring => '_substring', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 'aws.partition' => '_aws_partition', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | parseURL => '_parse_url', | ||||||||||||||||||||||||||||||||||||||||||
| 28 | uriEncode => '_uri_encode', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | isValidHostLabel => '_is_valid_host_label', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 'aws.isVirtualHostableS3Bucket' => '_aws_is_virtual_hostable_s3_bucket', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 'aws.parseArn' => '_aws_parse_arn', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | Readonly::Hash my %BOOLEAN_FUNCTIONS => ( | |||||||||||||||||||||||||||||||||||||||||
| 35 | booleanEquals => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | isSet => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | not => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | stringEquals => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | __PACKAGE__->follow_best_practice; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 9 | __PACKAGE__->mk_accessors( | |||||||||||||||||||||||||||||||||||||||||
| 44 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 45 | endpoint_rule_set | ||||||||||||||||||||||||||||||||||||||||||
| 46 | partitions | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my ( $class, @options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my %options = ref $options[0] ? %{ $options[0] } : @options; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my $rule_set = $options{endpoint_rule_set}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | croak 'endpoint_rule_set is required' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | if !defined $rule_set; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | croak 'endpoint_rule_set must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $rule_set or builtin::reftype($rule_set) ne "HASH"
MC/DC0%0/2
not ref $rule_set or builtin::reftype($rule_set) ne "HASH"
not ref $rule_set
builtin::reftype($rule_set) ne "HASH"
Truth table33%1/3
not(A) or B
A= not ref $rule_setB= builtin::reftype($rule_set) ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | if !ref $rule_set || reftype($rule_set) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | $options{partitions} //= $class->_load_partitions; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$options{"partitions"} //= $class->_load_partitions
MC/DC0%0/2
$options{"partitions"} //= $class->_load_partitions
$options{"partitions"}
$class->_load_partitions
Truth table33%1/3
A //= B
A= $options{"partitions"}B= $class->_load_partitions
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | my $self = $class->SUPER::new( \%options ); | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 9 | my $partitions; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub _load_partitions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_partitions: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return $partitions | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | if $partitions; | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $file = dist_file( 'Amazon-API', 'partitions.json', ); | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $partitions = slurp_json($file); | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return $partitions; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 9 | ▶ | sub resolve { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve: called CC=5 SCAR=17.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 5 | my ( $self, @options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my %parameters = ref $options[0] ? %{ $options[0] } : @options; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 5 | my $rule_set = $self->get_endpoint_rule_set; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | croak 'unsupported endpoint rule set version' | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 5 | ▶ | if !defined $rule_set->{version} || $rule_set->{version} ne '1.0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $rule_set->{"version"} or $rule_set->{"version"} ne "1.0"
MC/DC0%0/2
not defined $rule_set->{"version"} or $rule_set->{"version"} ne "1.0"
not defined $rule_set->{"version"}
$rule_set->{"version"} ne "1.0"
Truth table33%1/3
not(A) or B
A= not defined $rule_set->{"version"}B= $rule_set->{"version"} ne "1.0"
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | my $scope = $self->_initialize_parameters( \%parameters ); | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | my $endpoint = $self->_evaluate_rules( $rule_set->{rules}, $scope, 0, ); | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 5 | ▶ | croak 'endpoint rule set exhausted without a result' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | if !defined $endpoint; | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 5 | return $endpoint; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 5 | ▶ | sub _initialize_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize_parameters: called CC=8 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | my ( $self, $supplied ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 5 | ▶ | my $definitions = $self->get_endpoint_rule_set->{parameters} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->get_endpoint_rule_set->{"parameters"} // {}
MC/DC0%0/1
$self->get_endpoint_rule_set->{"parameters"} // {}
$self->get_endpoint_rule_set->{"parameters"}
Truth table50%1/2
A
A= $self->get_endpoint_rule_set->{"parameters"}
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | foreach my $name ( keys %{$supplied} ) { | |||||||||||||||||||||||||||||||||||||||||
| 121 | croak "unknown endpoint parameter '$name'" | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 9 | ▶ | if !exists $definitions->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 5 | my %scope; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | foreach my $name ( keys %{$definitions} ) { | |||||||||||||||||||||||||||||||||||||||||
| 128 | 15 | my $definition = $definitions->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 15 | ▶ | if ( exists $supplied->{$name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 9 | $scope{$name} = $supplied->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 9 | next; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 6 | ▶ | if ( exists $definition->{default} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | $scope{$name} = $definition->{default}; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | croak "endpoint parameter '$name' is required" | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if $definition->{required}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | return \%scope; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 10 | ▶ | sub _evaluate_rules { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_evaluate_rules: called CC=8 SCAR=24.4
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 10 | my ( $self, $rules, $parent_scope, $tree ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 10 | foreach my $rule ( @{$rules} ) { | |||||||||||||||||||||||||||||||||||||||||
| 153 | 19 | my %scope = %{$parent_scope}; | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | next | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 19 | ▶ | if !$self->_conditions_match( $rule->{conditions}, \%scope, ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 10 | ▶ | my $type = $rule->{type} // q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$rule->{"type"} // ""
MC/DC0%0/1
$rule->{"type"} // ""
$rule->{"type"}
Truth table50%1/2
A
A= $rule->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 10 | ▶ | if ( $type eq 'tree' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 5 | my $result = $self->_evaluate_rules( $rule->{rules}, \%scope, 1, ); | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 5 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 | ▶ | if ( $type eq 'endpoint' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | return $self->_render_endpoint( $rule->{endpoint}, \%scope, ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ( $type eq 'error' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | croak $self->_render_value( $rule->{error}, \%scope, ); | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | croak "unsupported endpoint rule type '$type'"; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | croak 'endpoint tree exhausted without a result' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | if $tree; | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 19 | ▶ | sub _conditions_match { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conditions_match: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 19 | my ( $self, $conditions, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 19 | ▶ | foreach my $condition ( @{ $conditions // [] } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conditions // []
MC/DC0%0/1
$conditions // []
$conditions
Truth table50%1/2
A
A= $conditions
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 19 | my $result = $self->_evaluate_expression( $condition, $scope, ); | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 19 | my $function = $condition->{fn}; | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 19 | ▶ | if ( $BOOLEAN_FUNCTIONS{$function} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 14 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | if !$result; | ||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | if !defined $result; | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 10 | ▶ | if ( exists $condition->{assign} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | $scope->{ $condition->{assign} } = $result; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 10 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 38 | ▶ | sub _evaluate_expression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_evaluate_expression: called CC=7 SCAR=20.4
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 38 | my ( $self, $expression, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 38 | ▶ | croak 'endpoint expression must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $expression or builtin::reftype($expression) ne "HASH"
MC/DC0%0/2
not ref $expression or builtin::reftype($expression) ne "HASH"
not ref $expression
builtin::reftype($expression) ne "HASH"
Truth table33%1/3
not(A) or B
A= not ref $expressionB= builtin::reftype($expression) ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | if !ref $expression || reftype($expression) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 38 | ▶ | if ( exists $expression->{ref} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 19 | return $scope->{ $expression->{ref} }; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 19 | my $function = $expression->{fn}; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 19 | ▶ | croak 'endpoint expression has no function' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | if !defined $function; | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 19 | my $method = $FUNCTIONS{$function}; | |||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 19 | ▶ | croak "unsupported endpoint function '$function'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | if !defined $method; | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 19 | ▶ | my @args = map { $self->_evaluate_value( $_, $scope ) } @{ $expression->{argv} // [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$expression->{"argv"} // []
MC/DC0%0/1
$expression->{"argv"} // []
$expression->{"argv"}
Truth table50%1/2
A
A= $expression->{"argv"}
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 19 | return $self->$method(@args); | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 33 | ▶ | sub _evaluate_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_evaluate_value: called CC=7 SCAR=28.4
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 33 | my ( $self, $value, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 33 | ▶ | return $self->_render_template( $value, $scope ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | if !ref $value; | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 19 | my $type = reftype($value); | |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 19 | ▶ | if ( $type eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 19 | ▶ | if ( exists $value->{ref} || exists $value->{fn} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $value->{"ref"} or exists $value->{"fn"}
MC/DC0%0/2
exists $value->{"ref"} or exists $value->{"fn"}
exists $value->{"ref"}
exists $value->{"fn"}
Truth table33%1/3
A or B
A= exists $value->{"ref"}B= exists $value->{"fn"}
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 19 | return $self->_evaluate_expression( $value, $scope ); | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my %result; | |||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | foreach my $key ( keys %{$value} ) { | |||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $result{$key} = $self->_evaluate_value( $value->{$key}, $scope, ); | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return \%result; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ( $type eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | return [ map { $self->_evaluate_value( $_, $scope ) } @{$value} ]; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | # JSON boolean objects and similar scalar references are literals. | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 14 | ▶ | sub _boolean_equals { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_boolean_equals: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 14 | my ( $self, $left, $right ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 14 | ▶ | return ( $left ? 1 : 0 ) == ( $right ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub _is_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_set: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | return defined $value ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | sub _not { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_not: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | return $value ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub _parse_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_url: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | return | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if !defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | return | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if $value !~ m{ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | \A | ||||||||||||||||||||||||||||||||||||||||||
| 304 | (https?) | ||||||||||||||||||||||||||||||||||||||||||
| 305 | : | ||||||||||||||||||||||||||||||||||||||||||
| 306 | // | ||||||||||||||||||||||||||||||||||||||||||
| 307 | ([^/?#]+) | ||||||||||||||||||||||||||||||||||||||||||
| 308 | ([^?#]*) | ||||||||||||||||||||||||||||||||||||||||||
| 309 | (?:[?][^#]*)? | ||||||||||||||||||||||||||||||||||||||||||
| 310 | (?:[#].*)? | ||||||||||||||||||||||||||||||||||||||||||
| 311 | \z | ||||||||||||||||||||||||||||||||||||||||||
| 312 | }xsm; | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my ( $scheme, $authority, $path ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $path = q{} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | if !defined $path; | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $normalized_path = $path; | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ( $normalized_path eq q{} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $normalized_path = '/'; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | elsif ( $normalized_path !~ m{/\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $normalized_path .= '/'; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my $host = $authority; | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | # Strip the port before determining whether the authority is an IP. | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if ( $host =~ /^\[([^\]]+)\](?::\d+)?$/xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $host = $1; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $host =~ s/:\d+\z//xsm; | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | my $is_ip | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$host =~ /^\d{1,3}(?:[.]\d{1,3}){3}$/msx or $host =~ /:/msx
MC/DC0%0/2
$host =~ /^\d{1,3}(?:[.]\d{1,3}){3}$/msx or $host =~ /:/msx
$host =~ /^\d{1,3}(?:[.]\d{1,3}){3}$/msx
$host =~ /:/msx
Truth table0%0/3
A or B
A= $host =~ /^\d{1,3}(?:[.]\d{1,3}){3}$/msxB= $host =~ /:/msx
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | = $host =~ /^\d{1,3}(?:[.]\d{1,3}){3}$/xsm || $host =~ /:/xsm | ||||||||||||||||||||||||||||||||||||||||||
| 340 | ? 1 | ||||||||||||||||||||||||||||||||||||||||||
| 341 | : 0; | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | scheme => $scheme, | |||||||||||||||||||||||||||||||||||||||||
| 345 | authority => $authority, | ||||||||||||||||||||||||||||||||||||||||||
| 346 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 347 | normalizedPath => $normalized_path, | ||||||||||||||||||||||||||||||||||||||||||
| 348 | isIp => $is_ip, | ||||||||||||||||||||||||||||||||||||||||||
| 349 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub _aws_is_virtual_hostable_s3_bucket { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_aws_is_virtual_hostable_s3_bucket: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my ( $self, $bucket, $allow_subdomains ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | if !defined $bucket; | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $bucket < 3 or length $bucket > 63
MC/DC0%0/2
length $bucket < 3 or length $bucket > 63
length $bucket < 3
length $bucket > 63
Truth table0%0/3
A or B
A= length $bucket < 3B= length $bucket > 63
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | if length $bucket < 3 | ||||||||||||||||||||||||||||||||||||||||||
| 362 | || length $bucket > 63; | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | if $bucket =~ /[A-Z_]/xsm; | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$bucket =~ /^[.]/msx or $bucket =~ /[.]\z/msx or $bucket =~ /[.][.]/msx
$bucket =~ /^[.]/msx or $bucket =~ /[.]\z/msx
MC/DC0%0/3
$bucket =~ /^[.]/msx or $bucket =~ /[.]\z/msx or $bucket =~ /[.][.]/msx
$bucket =~ /^[.]/msx
$bucket =~ /[.]\z/msx
$bucket =~ /[.][.]/msx
Truth table0%0/4
A or B or C
A= $bucket =~ /^[.]/msxB= $bucket =~ /[.]\z/msxC= $bucket =~ /[.][.]/msx
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | if $bucket =~ /^[.]/xsm | ||||||||||||||||||||||||||||||||||||||||||
| 369 | || $bucket =~ /[.]\z/xsm | ||||||||||||||||||||||||||||||||||||||||||
| 370 | || $bucket =~ /[.][.]/xsm; | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | if $bucket =~ /^\d{1,3}(?:[.]\d{1,3}){3}\z/xsm; | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | return $self->_is_valid_host_label( $bucket, $allow_subdomains ); | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub _is_valid_host_label { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_valid_host_label: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my ( $self, $value, $allow_subdomains ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $value or $value eq ""
MC/DC0%0/2
not defined $value or $value eq ""
not defined $value
$value eq ""
Truth table0%0/3
not(A) or B
A= not defined $valueB= $value eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | if !defined $value | ||||||||||||||||||||||||||||||||||||||||||
| 385 | || $value eq q{}; | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | my @labels | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | = $allow_subdomains | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | ? split /[.]/xsm, $value | ||||||||||||||||||||||||||||||||||||||||||
| 390 | : ($value); | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | foreach my $label (@labels) { | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $label < 1 or length $label > 63
MC/DC0%0/2
length $label < 1 or length $label > 63
length $label < 1
length $label > 63
Truth table0%0/3
A or B
A= length $label < 1B= length $label > 63
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | if length $label < 1 | ||||||||||||||||||||||||||||||||||||||||||
| 395 | || length $label > 63; | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | if $label !~ /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/xsm; | ||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | sub _uri_encode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uri_encode: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | return | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | if !defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my $encoded = $value; | |||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $encoded =~ s{ | |||||||||||||||||||||||||||||||||||||||||
| 415 | ([^A-Za-z0-9\-._~]) | ||||||||||||||||||||||||||||||||||||||||||
| 416 | }{ | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | sprintf '%%%02X', ord $1 | |||||||||||||||||||||||||||||||||||||||||
| 418 | }gexsm; | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | return $encoded; | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub _aws_parse_arn { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_aws_parse_arn: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my ( $self, $arn ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | return | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if !defined $arn; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my @parts = split /:/xsm, $arn, 6; | |||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | return | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | if @parts != 6 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@parts != 6 or $parts[0] ne "arn"
MC/DC0%0/2
@parts != 6 or $parts[0] ne "arn"
@parts != 6
$parts[0] ne "arn"
Truth table0%0/3
A or B
A= @parts != 6B= $parts[0] ne "arn"
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | || $parts[0] ne 'arn'; | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my ( undef, $partition, $service, $region, $account_id, $resource ) = @parts; | |||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | return | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | if $partition eq q{} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$partition eq "" or $service eq "" or $resource eq ""
$partition eq "" or $service eq ""
MC/DC0%0/3
$partition eq "" or $service eq "" or $resource eq ""
$partition eq ""
$service eq ""
$resource eq ""
Truth table0%0/4
A or B or C
A= $partition eq ""B= $service eq ""C= $resource eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | || $service eq q{} | ||||||||||||||||||||||||||||||||||||||||||
| 442 | || $resource eq q{}; | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my @resource_id = split m{[:/]}xsm, $resource, -1; | |||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | partition => $partition, | |||||||||||||||||||||||||||||||||||||||||
| 448 | service => $service, | ||||||||||||||||||||||||||||||||||||||||||
| 449 | region => $region, | ||||||||||||||||||||||||||||||||||||||||||
| 450 | accountId => $account_id, | ||||||||||||||||||||||||||||||||||||||||||
| 451 | resourceId => \@resource_id, | ||||||||||||||||||||||||||||||||||||||||||
| 452 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | sub _substring { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_substring: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my ( $self, $value, $start, $stop, $reverse ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | return | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | if !defined $value | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $value and defined $start and defined $stop
defined $value and defined $start
MC/DC0%0/3
defined $value and defined $start and defined $stop
defined $value
defined $start
defined $stop
Truth table0%0/4
A and B and C
A= defined $valueB= defined $startC= defined $stop
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | || !defined $start | ||||||||||||||||||||||||||||||||||||||||||
| 463 | || !defined $stop; | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if ($reverse) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $length = length $value; | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $start = $length - $start; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $stop = $length - $stop; | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | return | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if $start < 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$start < 0 or $stop < 0 or $stop < $start
$start < 0 or $stop < 0
MC/DC0%0/3
$start < 0 or $stop < 0 or $stop < $start
$start < 0
$stop < 0
$stop < $start
Truth table0%0/4
A or B or C
A= $start < 0B= $stop < 0C= $stop < $start
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | || $stop < 0 | ||||||||||||||||||||||||||||||||||||||||||
| 475 | || $stop < $start; | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | return substr $value, $start, $stop - $start; | |||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | sub _string_equals { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_string_equals: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my ( $self, $left, $right ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $left and defined $right
MC/DC0%0/2
defined $left and defined $right
defined $left
defined $right
Truth table0%0/3
A and B
A= defined $leftB= defined $right
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | if !defined $left || !defined $right; | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return $left eq $right; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 5 | ▶ | sub _get_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_attr: called CC=15 SCAR=39.8
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 494 | 5 | my ( $self, $value, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | return | ||||||||||||||||||||||||||||||||||||||||||
| 497 | 5 | ▶ | if !defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 5 | my @path; | |||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 5 | ▶ | if ( ref $path && reftype($path) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $path and builtin::reftype($path) eq "ARRAY"
MC/DC0%0/2
ref $path and builtin::reftype($path) eq "ARRAY"
ref $path
builtin::reftype($path) eq "ARRAY"
Truth table33%1/3
A and B
A= ref $pathB= builtin::reftype($path) eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | @path = @{$path}; | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 5 | foreach my $part ( split /[.]/xsm, $path ) { | |||||||||||||||||||||||||||||||||||||||||
| 506 | 5 | ▶ | if ( $part =~ /^([^\[\]]+)((?:\[\d+\])*)$/xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 5 | push @path, $1; | |||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 5 | my $indexes = $2; | |||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 5 | ▶ | while ( $indexes =~ /\[(\d+)\]/xsmg ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | push @path, 0 + $1; | |||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | 5 | foreach my $part (@path) { | |||||||||||||||||||||||||||||||||||||||||
| 523 | 5 | ▶ | if ( ref $value && reftype($value) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value and builtin::reftype($value) eq "HASH"
MC/DC0%0/2
ref $value and builtin::reftype($value) eq "HASH"
ref $value
builtin::reftype($value) eq "HASH"
Truth table33%1/3
A and B
A= ref $valueB= builtin::reftype($value) eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | return | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 5 | ▶ | if !exists $value->{$part}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 5 | $value = $value->{$part}; | |||||||||||||||||||||||||||||||||||||||||
| 528 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if ( ref $value && reftype($value) eq 'ARRAY' && $part =~ /^\d+$/xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $value and builtin::reftype($value) eq "ARRAY" and $part =~ /^\d+$/msx
ref $value and builtin::reftype($value) eq "ARRAY"
MC/DC0%0/3
ref $value and builtin::reftype($value) eq "ARRAY" and $part =~ /^\d+$/msx
ref $value
builtin::reftype($value) eq "ARRAY"
$part =~ /^\d+$/msx
Truth table0%0/4
A and B and C
A= ref $valueB= builtin::reftype($value) eq "ARRAY"C= $part =~ /^\d+$/msx
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | return | ||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if $part > $#{$value}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $value = $value->[$part]; | |||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 5 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 546 | 5 | ▶ | sub _aws_partition { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_aws_partition: called CC=9 SCAR=29.5
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 5 | my ( $self, $region ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | return | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 5 | ▶ | if !defined $region; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | 5 | my $partitions = $self->get_partitions->{partitions}; | |||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | return | ||||||||||||||||||||||||||||||||||||||||||
| 556 | 5 | ▶ | if !$partitions; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | # Prefer an explicitly enumerated region. | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 5 | foreach my $partition ( @{$partitions} ) { | |||||||||||||||||||||||||||||||||||||||||
| 560 | next | ||||||||||||||||||||||||||||||||||||||||||
| 561 | 6 | ▶ | if !$partition->{regions}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 6 | ▶ | if ( exists $partition->{regions}->{$region} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 5 | return { %{ $partition->{outputs} } }; | |||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | # Fall back to the partition's region pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | foreach my $partition ( @{$partitions} ) { | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $regex = $partition->{regionRegex}; | |||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | next | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | if !defined $regex; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if ( $region =~ /$regex/xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | return { %{ $partition->{outputs} } }; | |||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 584 | 5 | ▶ | sub _render_endpoint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_endpoint: called CC=5 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 586 | 5 | my ( $self, $endpoint, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | 5 | ▶ | croak 'endpoint result must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $endpoint or builtin::reftype($endpoint) ne "HASH"
MC/DC0%0/2
not ref $endpoint or builtin::reftype($endpoint) ne "HASH"
not ref $endpoint
builtin::reftype($endpoint) ne "HASH"
Truth table33%1/3
not(A) or B
A= not ref $endpointB= builtin::reftype($endpoint) ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | if !ref $endpoint || reftype($endpoint) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 592 | url => $self->_render_value( $endpoint->{url}, $scope ), | ||||||||||||||||||||||||||||||||||||||||||
| 593 | properties => $self->_render_data( $endpoint->{properties} // {}, $scope ), | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 5 | ▶ | headers => $self->_render_data( $endpoint->{headers} // {}, $scope ), | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$endpoint->{"properties"} // {}
$endpoint->{"headers"} // {}
MC/DC0%0/1
$endpoint->{"properties"} // {}
$endpoint->{"properties"}
MC/DC0%0/1
$endpoint->{"headers"} // {}
$endpoint->{"headers"}
Truth table50%1/2
A
A= $endpoint->{"properties"}
Truth table50%1/2
A
A= $endpoint->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 10 | ▶ | sub _render_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_data: called CC=7 SCAR=26.3
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 10 | my ( $self, $value, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 10 | ▶ | return $self->_render_template( $value, $scope ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | if !ref $value; | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | 10 | my $type = reftype($value); | |||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | 10 | ▶ | if ( $type eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 609 | 10 | ▶ | if ( exists $value->{ref} || exists $value->{fn} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $value->{"ref"} or exists $value->{"fn"}
MC/DC0%0/2
exists $value->{"ref"} or exists $value->{"fn"}
exists $value->{"ref"}
exists $value->{"fn"}
Truth table33%1/3
A or B
A= exists $value->{"ref"}B= exists $value->{"fn"}
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | return $self->_evaluate_expression( $value, $scope ); | |||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | 10 | my %result; | |||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 10 | foreach my $key ( keys %{$value} ) { | |||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | $result{$key} = $self->_render_data( $value->{$key}, $scope, ); | |||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 10 | return \%result; | |||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | if ( $type eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | return [ map { $self->_render_data( $_, $scope ) } @{$value} ]; | |||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 630 | 5 | ▶ | sub _render_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_value: called CC=3 SCAR=15.1
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 632 | 5 | my ( $self, $value, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | 5 | ▶ | if ( ref $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | return $self->_evaluate_expression( $value, $scope ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | if reftype($value) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | 5 | return $self->_render_template( $value, $scope ); | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 645 | 19 | ▶ | sub _render_template { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_template: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 646 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 647 | 19 | my ( $self, $template, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | 19 | ▶ | return $template | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | if !defined $template; | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 19 | $template =~ s! | |||||||||||||||||||||||||||||||||||||||||
| 653 | \{ | ||||||||||||||||||||||||||||||||||||||||||
| 654 | ([A-Za-z][A-Za-z0-9_]*) | ||||||||||||||||||||||||||||||||||||||||||
| 655 | (?:\#([^}]+))? | ||||||||||||||||||||||||||||||||||||||||||
| 656 | \} | ||||||||||||||||||||||||||||||||||||||||||
| 657 | ! | ||||||||||||||||||||||||||||||||||||||||||
| 658 | 10 | $self->_resolve_template_value( $1, $2, $scope ) | |||||||||||||||||||||||||||||||||||||||||
| 659 | !gexsm; | ||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | 19 | return $template; | |||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 10 | ▶ | sub _resolve_template_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_template_value: called CC=6 SCAR=19.0
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 10 | my ( $self, $name, $path, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | croak "undefined endpoint template value '$name'" | ||||||||||||||||||||||||||||||||||||||||||
| 670 | 10 | ▶ | if !exists $scope->{$name} || !defined $scope->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $scope->{$name} and defined $scope->{$name}
MC/DC0%0/2
exists $scope->{$name} and defined $scope->{$name}
exists $scope->{$name}
defined $scope->{$name}
Truth table33%1/3
A and B
A= exists $scope->{$name}B= defined $scope->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | 10 | my $value = $scope->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | 10 | ▶ | if ( defined $path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | 5 | $value = $self->_get_attr( $value, $path ); | |||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 5 | ▶ | croak "undefined endpoint template value '$name#$path'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | if !defined $value; | ||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 10 | ▶ | croak "endpoint template value '$name' is not scalar" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | if ref $value; | ||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | 10 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||