| 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"} ||= []
MC/DC100%1/1
$self->{"filters"} ||= []
$self->{"filters"}
Truth table100%2/2
A
A= $self->{"filters"}
| |||||||||||||||||||||||||||||
| 8 | 337 | ▶ | if (@new_filters) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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]
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]
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
not -d $_ and $self->filename_matches_filters($_)
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($_)
| |||||||||||||||||||||||||||||
| 55 | $input | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 12 | return @result; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 20 | 1; | |||||||||||||||||||||||||||