lib/Mail/DKIM2/Util.pm

filter: Statementstmt 74.2% 26 / 35 Branchbran 50.0% 2 / 4 Conditioncond 44.4% 8 / 18 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 77.7% 7 / 9 Podpod 100% 4 / 4 totaltotal 64.1% 50 / 78 CC 11 SCAR 14.7
CC
11
Cov
63%
is_base64string
6.6
is_base64string
6.6
check_options
4.1
CRAP 4.3
« lib/Mail/DKIM2/MessageStore.pm ↑ Summary bin/validate.pl »
1 package Mail::DKIM2::Util;
2 222 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 222 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 222 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 222 our $VERSION = '0.34';
7  
8 222 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 222 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 222 our @EXPORT_OK = qw(
12 check_options
13 is_base64string
14 );
15  
16 # check_options($what, \%opts, @known): croak on an option not in @known.
17 # Every public constructor and class method taking named options calls this
18 # first (Mail::DKIM2 CONVENTIONS: a misspelling is an error, not a silently
19 # ignored setting -- Algz => ['sha512'] used to compute SHA-256).
20 13377 ▶sub check_options {
Subroutine check_options: called CC=3 SCAR=14.2
Pod documented
21 0 ▶ my ($what, $opts, @known) = @_;
Subroutine check_options: not called CC=3 SCAR=14.2
Pod documented
22 0 my %known = map { $_ => 1 } @known;
23 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1; # blame our caller's caller
24 0 for my $k (sort keys %$opts) {
25 0 ▶ Carp::croak("unknown option $k for $what") unless $known{$k};
Branch: 2 branches
BranchTrueFalseTotal
unless $known{$k} 18 17832 17850
unless $known{$k} 0 0 0
26 }
27 0 return;
28 }
29  
30 # A base64string (-09 ยง2.13), FWS already removed: base64 characters,
31 # padded with "=" to a multiple of four ("MUST be padded").
32 16983 ▶sub is_base64string {
Subroutine is_base64string: called CC=4 SCAR=18.9
Pod documented
33 0 ▶ my ($s) = @_;
Subroutine is_base64string: not called CC=4 SCAR=18.9
Pod documented
34 0 ▶ return defined $s && length $s && length($s) % 4 == 0
Condition44%8/18
defined $s && length $s && length($s) % 4 == 0 && $s =~ m[\A[A-Za-z0-9+/]+={0,2}\z]u
!ll&&!rl&&r
9216972
defined $s and length $s and length($s) % 4 == 0
!ll&&!rl&&r
1816974
defined $s and length $s
!ll&&!rl&&r
0116982
defined $s && length $s && length($s) % 4 == 0 && $s =~ m[\A[A-Za-z0-9+/]+={0,2}\z]u
!ll&&!rl&&r
000
defined $s and length $s and length($s) % 4 == 0
!ll&&!rl&&r
000
defined $s and length $s
!ll&&!rl&&r
000
MC/DC75%3/4
defined $s && length $s && length($s) % 4 == 0 && $s =~ m[\A[A-Za-z0-9+/]+={0,2}\z]u
defined $s length $s length($s) % 4 == 0 $s =~ m[\A[A-Za-z0-9+/]+={0,2}\z]u
MC/DC0%0/4
defined $s && length $s && length($s) % 4 == 0 && $s =~ m[\A[A-Za-z0-9+/]+={0,2}\z]u
defined $s length $s length($s) % 4 == 0 $s =~ m[\A[A-Za-z0-9+/]+={0,2}\z]u
Truth table80%4/5
A and B and C && D
A= defined $sB= length $sC= length($s) % 4 == 0D= $s =~ m[\A[A-Za-z0-9+/]+={0,2}\z]u
ABCDresult
0XXX0
10XX0
110X0
11100
11111
Truth table0%0/5
A and B and C && D
A= defined $sB= length $sC= length($s) % 4 == 0D= $s =~ m[\A[A-Za-z0-9+/]+={0,2}\z]u
ABCDresult
0XXX0
10XX0
110X0
11100
11111
35 && $s =~ m{\A[A-Za-z0-9+/]+={0,2}\z};
36 }
37  
38 222 1;
39  
40 __END__
« lib/Mail/DKIM2/MessageStore.pm ↑ Summary bin/validate.pl »