Analizo/Filter/Client.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 10 / 10 Conditioncond 87.5% 7 / 8 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 6 totaltotal 88.5% 62 / 70 CC 11 SCAR 9.4
CC
11
Cov
98%
filters
3.0
filename_matches_filters
3.0
apply_filters
3.0
CRAP 2.6
« Analizo.pm ↑ Summary Analizo/Metric/MaximumMethodLinesOfCode.pm »
1 package Analizo::Filter::Client;
2  
3 20 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 337 ▶sub filters {
Subroutine filters: called CC=3 SCAR=11.0
Pod undocumented
6 337 my ($self, @new_filters) = @_;
7 337 ▶ $self->{filters} ||= [];
Condition100%2/2
$self->{"filters"} ||= []
l!l
31720
MC/DC100%1/1
$self->{"filters"} ||= []
$self->{"filters"}
Truth table100%2/2
A
A= $self->{"filters"}
Aresult
11
00
8 337 ▶ if (@new_filters) {
Branch: 1 branch
BranchTrueFalseTotal
if (@new_filters) 24 313 337
9 24 push @{$self->{filters}}, @new_filters;
10 }
11 337 return $self->{filters};
12 }
13  
14 20 ▶sub has_filters {
Subroutine has_filters: called CC=2 SCAR=7.1
Pod undocumented
15 20 my ($self) = @_;
16 20 ▶ return exists($self->{filters}) && exists($self->{filters}->[0]);
Condition66%2/3
exists $self->{'filters'} && exists $self->{'filters'}[0]
!ll&&!rl&&r
1307
MC/DC50%1/2
exists $self->{'filters'} && exists $self->{'filters'}[0]
exists $self->{'filters'} exists $self->{'filters'}[0]
Truth table66%2/3
A && B
A= exists $self->{'filters'}B= exists $self->{'filters'}[0]
ABresult
0X0
100
111
17 }
18  
19 105 ▶sub share_filters_with($$) {
Subroutine share_filters_with: called CC=1 SCAR=0.0
Pod undocumented
20 105 my ($self, $other) = @_;
21 105 $other->{filters} = $self->{filters};
22 }
23  
24 4 ▶sub exclude {
Subroutine exclude: called CC=2 SCAR=6.9
Pod undocumented
25 4 my ($self, @dirs) = @_;
26 4 ▶ if (!$self->{excluding_dirs}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"excluding_dirs"}) 3 1 4
27 3 $self->{excluding_dirs} = 1;
28 3 $self->filters(Analizo::LanguageFilter->new);
29 }
30 4 $self->filters(Analizo::FilenameFilter->exclude(@dirs));
31 }
32  
33 307 ▶sub filename_matches_filters {
Subroutine filename_matches_filters: called CC=3 SCAR=11.0
Pod undocumented
34 307 my ($self, $filename) = @_;
35 307 for my $filter (@{$self->filters}) {
36 318 ▶ unless ($filter->matches($filename)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($filter->matches($filename)) 67 251 318
37 67 return 0;
38 }
39 }
40 240 return 1;
41 }
42  
43 12 ▶sub apply_filters {
Subroutine apply_filters: called CC=3 SCAR=11.0
Pod undocumented
44 12 my ($self, @input) = @_;
45  
46 12 ▶ unless ($self->has_filters) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_filters) 6 6 12
47 # By default, only look at supported languages
48 6 $self->filters(Analizo::LanguageFilter->new('all'));
49 }
50  
51 12 my @result = ();
52 12 for my $input (@input) {
53 find(
54 11 ▶ { wanted => sub { push @result, $_ if !-d $_ && $self->filename_matches_filters($_); }, no_chdir => 1 },
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
if not -d $_ and $self->filename_matches_filters($_) 63 25 88
Condition100%3/3
not -d $_ and $self->filename_matches_filters($_)
!ll&&!rl&&r
131263
MC/DC100%2/2
not -d $_ and $self->filename_matches_filters($_)
not -d $_ $self->filename_matches_filters($_)
Truth table100%3/3
not(A) and B
A= not -d $_B= $self->filename_matches_filters($_)
ABresult
0X0
100
111
55 $input
56 );
57 }
58 12 return @result;
59 }
60  
61 20 1;
« Analizo.pm ↑ Summary Analizo/Metric/MaximumMethodLinesOfCode.pm »