blib/lib/Unblock/WebSocket/_Random.pm

filter: Statementstmt 81.8% 18 / 22 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 59.5% 28 / 47 CC 6 SCAR 18.4
CC
6
Cov
66%
bytes
10.5
mask_key
2.0
BEGIN
1.0
CRAP 6.3
« blib/lib/Unblock/WebSocket/_Deflate.pm ↑ Summary blib/lib/Unblock/WebSocket/_UTF8.pm »
1 package Unblock::WebSocket::_Random;
2  
3 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 23 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 23 ▶use Unblock::WebSocket ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶sub bytes {
Subroutine bytes: called CC=6 SCAR=23.5
Pod undocumented
9 4 my ($class, $length) = @_;
10 4 ▶ croak 'bytes(): length must be a positive integer'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $length and not ref $length and $length =~ /\A[0-9]+\z/ and $length > 0 0 4 4
Condition33%3/9
defined $length and not ref $length and $length =~ /\A[0-9]+\z/ and $length > 0
!ll&&!rl&&r
004
defined $length and not ref $length and $length =~ /\A[0-9]+\z/
!ll&&!rl&&r
004
defined $length and not ref $length
!ll&&!rl&&r
004
MC/DC0%0/4
defined $length and not ref $length and $length =~ /\A[0-9]+\z/ and $length > 0
defined $length not ref $length $length =~ /\A[0-9]+\z/ $length > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $lengthB= not ref $lengthC= $length =~ /\A[0-9]+\z/D= $length > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
11 unless defined($length) && !ref($length)
12 && $length =~ /\A[0-9]+\z/ && $length > 0;
13  
14 4 ▶ if (Unblock::WebSocket->native_available) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Unblock::WebSocket"->native_available) 4 0 4
15 4 require Unblock::WebSocket::_Native;
16 4 return Unblock::WebSocket::_Native->_random_bytes($length);
17 }
18  
19 0 require Crypt::SysRandom;
20 0 return Crypt::SysRandom::random_bytes($length);
21 }
22  
23 0 ▶sub mask_key {
Subroutine mask_key: not called CC=1 SCAR=6.9
Pod undocumented
24 0 my ($class) = @_;
25 0 return $class->bytes(4);
26 }
27  
28 23 1;
« blib/lib/Unblock/WebSocket/_Deflate.pm ↑ Summary blib/lib/Unblock/WebSocket/_UTF8.pm »