blib/lib/Punk/Observe/Ingest.pm

filter: Statementstmt 53.1% 17 / 32 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 38.6% 22 / 57 CC 9 SCAR 40.6
CC
9
Cov
35%
_inflate
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 58.2
« blib/lib/Punk/Plugin/Observe.pm ↑ Summary blib/lib/Punk/Observe/Health.pm »
1 package Punk::Observe::Ingest;
2  
3 19 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 19 ▶use Punk::Observe ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 19 ▶use File::Raw::JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 19 our $VERSION = $Punk::Observe::VERSION;
12  
13 19 our $MAX_RATIO = 20;
14  
15 0 ▶sub _inflate {
Subroutine _inflate: not called CC=9 SCAR=45.0
16 0 my ($buf, $how, $max) = @_;
17 0 ▶ my $class = $how eq 'gzip' ? 'IO::Uncompress::Gunzip'
Branch: 1 branch
BranchTrueFalseTotal
$how eq 'gzip' ? : 0 0 0
18 : 'IO::Uncompress::Inflate';
19 0 ▶ eval "require $class; 1" or return undef;
Branch: 1 branch
BranchTrueFalseTotal
eval "require $class; 1" or return undef 0 0 0
20  
21 0 ▶ my $z = $class->new(\$buf, Transparent => 0) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $z = $class->new(\$buf, "Transparent", 0) or return undef 0 0 0
22 0 my $out = '';
23 0 my $chunk;
24 0 while (1) {
25 0 my $n = $z->read($chunk, 65536);
26 # A negative read is a stream error, and the commonest one is a body
27 # that stops part way through. Returning what arrived so far would
28 # make the C build and this one disagree, and would surface later as
29 # a malformed OTLP payload with the real cause thrown away.
30 0 ▶ return undef if !defined $n || $n < 0;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $n or $n < 0 0 0 0
Condition0%0/3
not defined $n or $n < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $n or $n < 0
not defined $n $n < 0
Truth table0%0/3
not(A) or B
A= not defined $nB= $n < 0
ABresult
1X1
011
000
31 0 ▶ last if $n == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $n == 0 0 0 0
32 0 $out .= $chunk;
33 0 ▶ return undef if length($out) > $max;
Branch: 1 branch
BranchTrueFalseTotal
if length $out > $max 0 0 0
34 }
35 0 ▶ return undef if $z->error;
Branch: 1 branch
BranchTrueFalseTotal
if $z->error 0 0 0
36 0 close $z;
37 0 return $out;
38 }
39  
40 19 1;
41  
42 __END__
« blib/lib/Punk/Plugin/Observe.pm ↑ Summary blib/lib/Punk/Observe/Health.pm »