| 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
Condition66%2/3
ref $tags eq "ARRAY" and @$tags <= 20
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%6/6
not defined $tag or ref $tag or $tag =~ /[\x00-\x1f\x7f]/
not defined $tag or ref $tag
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]/
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 21 | $tag =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 21 | ▶ | next unless length($tag); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 19 | ▶ | die 'Tag too long' if length($tag) > 120; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 17 | ▶ | push @normalized, $tag unless $seen{$tag}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 16 | return \@normalized; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||