CriticDB.pm

filter: Statementstmt 56.2% 27 / 48 Branchbran 16.6% 1 / 6 Conditioncond 25.0% 2 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 53.8% 7 / 13 Podpod 0.0% 0 / 3 totaltotal 44.5% 37 / 83 CC 7 SCAR 12.5
CC
7
Cov
48%
_load
6.0
collect
6.0
report
6.0
CRAP 3.5
« CriticDB/DB/Index/Set.pm ↑ Summary CriticDB/DB/Index/Id.pm »
1 package App::CriticDB;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use App::CriticDB::Collector;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use App::CriticDB::DB;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use App::CriticDB::Report;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION='0.0.6';
12  
13 1 ▶sub new {
Subroutine new: called CC=4 SCAR=15.2
Pod undocumented
14 1 my ($ref,%opt)=@_;
15 1 ▶ my $class=ref($ref)||$ref;
Condition33%1/3
ref $ref || $ref
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $ref || $ref
ref $ref $ref
Truth table33%1/3
A || B
A= ref $refB= $ref
ABresult
1X1
011
000
16 1 my %self;
17 1 ▶ if($opt{file}) { %self=(mode=>'file',file=>$opt{file},type=>$opt{type}//'storable') }
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{'file'}) { } 1 0 1
Condition50%1/2
$opt{"type"} // "storable"
l!l
10
MC/DC0%0/1
$opt{"type"} // "storable"
$opt{"type"}
Truth table50%1/2
A
A= $opt{"type"}
Aresult
11
00
18 0 else { confess('Only file mode is available at this time') }
19 1 @self{qw/profile debug/}=@opt{qw/profile debug/};
20 1 return bless(\%self,$class);
21 }
22  
23 0 ▶sub _load {
Subroutine _load: not called CC=2 SCAR=17.9
24 0 my ($self)=@_;
25 0 ▶ if($$self{db}) { return }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"db"}) 0 0 0
26 0 $$self{db}=App::CriticDB::DB->new(%$self);
27 0 return $self;
28 }
29  
30 0 ▶sub collect {
Subroutine collect: not called CC=2 SCAR=17.9
Pod undocumented
31 0 my ($self,@paths)=@_;
32 0 $self->_load();
33 0 $$self{db}->cleanup();
34 $$self{collector}//=App::CriticDB::Collector->new(
35 profile=>$$self{profile},
36 debug=>$$self{debug},
37 0 ▶ store=>sub{$$self{db}->store(@_)},
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 0 ▶ flush=>sub{$$self{db}->flush(@_)},
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 ▶ newer=>sub{$$self{db}->newer(@_)},
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 ▶ );
Condition0%0/3
$self->{"collector"} //= "App::CriticDB::Collector"->new("profile", $self->{"profile"}, "debug", $self->{"debug"}, "store", sub { $self->{"db"}->store(@_); } , "flush", sub { $self->{"db"}->flush(@_); } , "newer", sub { $self->{"db"}->newer(@_); } )
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"collector"} //= "App::CriticDB::Collector"->new("profile", $self->{"profile"}, "debug", $self->{"debug"}, "store", sub { $self->{"db"}->store(@_); } , "flush", sub { $self->{"db"}->flush(@_); } , "newer", sub { $self->{"db"}->newer(@_); } )
$self->{"collector"} "App::CriticDB::Collector"->new("profile", $self->{"profile"}, "debug", $self->{"debug"}, "store", sub { $self->{"db"}->store(@_); } , "flush", sub { $self->{"db"}->flush(@_); } , "newer", sub { $self->{"db"}->newer(@_); } )
Truth table0%0/3
A //= B
A= $self->{"collector"}B= "App::CriticDB::Collector"->new("profile", $self->{"profile"}, "debug", $self->{"debug"}, "store", sub { $self->{"db"}->store(@_); } , "flush", sub { $self->{"db"}->flush(@_); } , "newer", sub { $self->{"db"}->newer(@_); } )
ABresult
1X1
011
000
41 0 $$self{collector}->collect(@paths);
42 0 return $self;
43 }
44  
45 0 ▶sub report {
Subroutine report: not called CC=2 SCAR=17.9
Pod undocumented
46 0 my ($self,%opt)=@_;
47 0 $self->_load();
48 0 my $report=App::CriticDB::Report->new(verbose=>$opt{verbose});
49 0 ▶ while(my $violation=$$self{db}->report()) { print $report->text($violation) }
Branch: 1 branch
BranchTrueFalseTotal
if (my $violation = $self->{"db"}->report) 0 0 0
50 0 return $self;
51 }
52  
53 1 1;
54  
55 __END__
« CriticDB/DB/Index/Set.pm ↑ Summary CriticDB/DB/Index/Id.pm »