VirusScan/Result.pm

filter: Statementstmt 80.9% 34 / 42 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 71.4% 10 / 14 Podpod 100% 7 / 7 totaltotal 77.9% 53 / 68 CC 4 SCAR 5.4
CC
4
Cov
78%
_make_accessors
3.0
new
2.0
virus
2.0
CRAP 1.7
« VirusScan.pm ↑ Summary VirusScan/Engine/Daemon.pm »
1 package File::VirusScan::Result;
2 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 23 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 23 my @STATES = qw( clean error virus suspicious );
7 23 __PACKAGE__->_make_accessors(@STATES);
8  
9 sub new
10 2 ▶{
Subroutine new: called CC=2 SCAR=7.1
Pod documented
11 2 my ($class, $args) = @_;
12 my $self = {
13 state => $args->{state} || 'clean',
14 data => $args->{data},
15 2 ▶ };
Condition50%1/2
$args->{'state'} || 'clean'
l!l
20
MC/DC0%0/1
$args->{'state'} || 'clean'
$args->{'state'}
Truth table50%1/2
A
A= $args->{'state'}
Aresult
11
00
16 2 return bless $self, $class;
17 }
18  
19 sub error
20 2 ▶{
Subroutine error: called CC=1 SCAR=0.0
Pod documented
21 2 my ($class, $err) = @_;
22 2 return $class->new(
23 {
24 state => 'error',
25 data => $err,
26 }
27 );
28 }
29  
30 sub virus
31 0 ▶{
Subroutine virus: not called CC=1 SCAR=6.9
Pod documented
32 0 my ($class, $vname) = @_;
33 0 return $class->new(
34 {
35 state => 'virus',
36 data => $vname,
37 }
38 );
39 }
40  
41 sub suspicious
42 0 ▶{
Subroutine suspicious: not called CC=1 SCAR=6.9
Pod documented
43 0 my ($class, $what) = @_;
44 0 return $class->new(
45 {
46 state => 'suspicious',
47 data => $what,
48 }
49 );
50 }
51  
52 sub clean
53 0 ▶{
Subroutine clean: not called CC=1 SCAR=6.9
Pod documented
54 0 my ($class) = @_;
55 0 return $class->new({ state => 'clean', });
56 }
57  
58 sub get_state
59 0 ▶{
Subroutine get_state: not called CC=1 SCAR=6.9
Pod documented
60 0 my ($self) = @_;
61 0 return $self->{state};
62 }
63  
64 sub get_data
65 2 ▶{
Subroutine get_data: called CC=1 SCAR=0.0
Pod documented
66 2 my ($self) = @_;
67 2 return $self->{data};
68 }
69  
70  
71 # Generate is_XXX accessors for all valid states
72 sub _make_accessors
73 23 ▶{
Subroutine _make_accessors: called CC=3 SCAR=11.0
74 23 my ($class, @methods) = @_;
75 23 ▶ no strict 'refs'; ## no critic (ProhibitNoStrict)
Subroutine BEGIN: called CC=1 SCAR=0.0
76 23 foreach my $name (@methods) {
77 92 my $wrappername = "${class}::is_${name}";
78 92 ▶ if(!defined &{$wrappername}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &{$wrappername;}) 92 0 92
79 92 ▶ *{$wrappername} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
80 6 my ($self) = @_;
81 6 return ($self->{state} eq $name);
82 92 };
83 }
84 }
85  
86 23 ▶ use strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
87 }
88  
89  
90 23 1;
91 __END__
« VirusScan.pm ↑ Summary VirusScan/Engine/Daemon.pm »