lib/Mogura/Server/Tags.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 10 / 10 Conditioncond 88.8% 8 / 9 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 93.4% 43 / 46 CC 10 SCAR 21.4
CC
10
Cov
97%
validate
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.5
« lib/Mogura/Server.pm ↑ Summary lib/Mogura/Server/Results.pm »
1 package Mogura::Server::Tags;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 22 ▶sub validate {
Subroutine validate: called CC=10 SCAR=23.0
Pod undocumented
6 22 my ($class, $tags) = @_;
7  
8 22 ▶ die 'Invalid tags' unless ref($tags) eq 'ARRAY' && @$tags <= 20;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tags eq "ARRAY" and @$tags <= 20 1 21 22
Condition66%2/3
ref $tags eq "ARRAY" and @$tags <= 20
!ll&&!rl&&r
0121
MC/DC50%1/2
ref $tags eq "ARRAY" and @$tags <= 20
ref $tags eq "ARRAY" @$tags <= 20
Truth table66%2/3
A and B
A= ref $tags eq "ARRAY"B= @$tags <= 20
ABresult
0X0
100
111
9 21 my @normalized;
10 my %seen;
11 21 for my $value (@$tags) {
12 24 my $tag = $value;
13 24 ▶ die 'Invalid tag' if !defined($tag) || ref($tag) || $tag =~ /[\x00-\x1f\x7f]/;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $tag or ref $tag or $tag =~ /[\x00-\x1f\x7f]/ 3 21 24
Condition100%6/6
not defined $tag or ref $tag or $tag =~ /[\x00-\x1f\x7f]/
l!l&&r!l&&!r
2121
not defined $tag or ref $tag
l!l&&r!l&&!r
1122
MC/DC100%3/3
not defined $tag or ref $tag or $tag =~ /[\x00-\x1f\x7f]/
not defined $tag ref $tag $tag =~ /[\x00-\x1f\x7f]/
Truth table100%4/4
not(A) or B or C
A= not defined $tagB= ref $tagC= $tag =~ /[\x00-\x1f\x7f]/
ABCresult
1XX1
01X1
0011
0000
14 21 $tag =~ s/\A\s+|\s+\z//g;
15 21 ▶ next unless length($tag);
Branch: 1 branch
BranchTrueFalseTotal
unless length $tag 2 19 21
16 19 ▶ die 'Tag too long' if length($tag) > 120;
Branch: 1 branch
BranchTrueFalseTotal
if length $tag > 120 2 17 19
17 17 ▶ push @normalized, $tag unless $seen{$tag}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $seen{$tag}++ 16 1 17
18 }
19 16 return \@normalized;
20 }
21  
22 5 1;
« lib/Mogura/Server.pm ↑ Summary lib/Mogura/Server/Results.pm »