Sisimai/RFC791.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 10 / 10 Conditioncond 85.7% 6 / 7 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 96.2% 51 / 53 CC 10 SCAR 16.9
CC
10
Cov
98%
is_ipv4address
8.0
find
3.0
BEGIN
1.0
CRAP 5.4
« Sisimai/Reason/Filtered.pm ↑ Summary Sisimai/Reason/FailedSTARTTLS.pm »
1 package Sisimai::RFC791;
2 100 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 100 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 100 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 199750 ▶sub is_ipv4address {
Subroutine is_ipv4address: called CC=8 SCAR=20.8
Pod documented
7 # Returns 1 if the argument is an IPv4 address
8 # @param [String] argv1 IPv4 address like "192.0.2.25"
9 # @return [Bool] 1: is an IPv4 address
10 # @since v5.2.0
11 199750 my $class = shift;
12 199750 ▶ my $argv0 = shift || return 0; return 0 if length $argv0 < 7;
Branch: 1 branch
BranchTrueFalseTotal
if length $argv0 < 7 124275 75332 199607
Condition100%2/2
shift() || (return 0)
l!l
199607143
MC/DC100%1/1
shift() || (return 0)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
13 75332 ▶ my @octet = split(/[.]/, $argv0); return 0 if scalar @octet != 4;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @octet != 4 69654 5678 75332
14  
15 5678 for my $e ( @octet ) {
16 # Check each octet is between 0 and 255
17 16923 ▶ return 0 unless $e =~ /\A[0-9]{1,3}\z/; my $v = int $e;
Branch: 1 branch
BranchTrueFalseTotal
unless $e =~ /\A[0-9]{1,3}\z/u 2117 14806 16923
18 14806 ▶ return 0 if $v < 0 || $v > 255;
Branch: 1 branch
BranchTrueFalseTotal
if $v < 0 or $v > 255 2 14804 14806
Condition66%2/3
$v < 0 or $v > 255
l!l&&r!l&&!r
0214804
MC/DC50%1/2
$v < 0 or $v > 255
$v < 0 $v > 255
Truth table66%2/3
A or B
A= $v < 0B= $v > 255
ABresult
1X1
011
000
19 }
20 3559 return 1;
21 }
22  
23 10472 ▶sub find {
Subroutine find: called CC=3 SCAR=11.0
Pod documented
24 # Find an IPv4 address from the given string
25 # @param [String] argv1 String including an IPv4 address
26 # @return [Array] List of IPv4 addresses
27 # @since v5.0.0
28 10472 my $class = shift;
29 10472 ▶ my $argv0 = shift || return undef; return [] if length $argv0 < 7;
Branch: 1 branch
BranchTrueFalseTotal
if length $argv0 < 7 1 10470 10471
Condition100%2/2
shift() || (return undef)
l!l
104711
MC/DC100%1/1
shift() || (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
30  
31 10470 $argv0 =~ tr/()[],/ /;
32 10470 return [grep { $class->is_ipv4address($_) } split(' ', $argv0)];
33 }
34  
35 100 1;
36 __END__
« Sisimai/Reason/Filtered.pm ↑ Summary Sisimai/Reason/FailedSTARTTLS.pm »