Client/Response.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 6 / 6 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 92.5% 37 / 40 CC 6 SCAR 14.7
CC
6
Cov
97%
decode_json
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.3
« Client/Auth/v2.pm ↑ Summary Client.pm »
1 #
2 # Copyright (c) 2018 cPanel, L.L.C.
3 # All rights reserved.
4 # http://cpanel.net/
5 #
6 # Distributed under the terms of the MIT license. See the LICENSE file for
7 # further details.
8 #
9 package OpenStack::Client::Response;
10  
11 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use base 'HTTP::Response';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 sub decode_json {
17 50 ▶ my ($self) = @_;
Subroutine decode_json: called CC=6 SCAR=17.9
Pod undocumented
18  
19 50 my $type = $self->header('Content-Type');
20 50 my $content = $self->decoded_content;
21  
22 50 ▶ if ($self->code =~ /^[45]\d{2}$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->code =~ /^[45]\d{2}$/) 3 47 50
23 3 ▶ $content ||= "@{[$self->code]} Unknown error";
Condition100%2/2
$content ||= "@{[$self->code];} Unknown error"
l!l
21
MC/DC100%1/1
$content ||= "@{[$self->code];} Unknown error"
$content
Truth table100%2/2
A
A= $content
Aresult
11
00
24  
25 3 die $content;
26 }
27  
28 47 ▶ if (defined $content && length $content) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $content and length $content) 38 9 47
Condition66%2/3
defined $content and length $content
!ll&&!rl&&r
0938
MC/DC50%1/2
defined $content and length $content
defined $content length $content
Truth table66%2/3
A and B
A= defined $contentB= length $content
ABresult
0X0
100
111
29 38 ▶ if (lc($type) =~ qr{^application/json}i) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc($type) =~ qr"^application/json"i) 37 1 38
30 37 return JSON::decode_json($content);
31 }
32 }
33  
34 10 return $content;
35 }
36  
37 2 1;
« Client/Auth/v2.pm ↑ Summary Client.pm »