blib/lib/App/Ack/Filter/Collection.pm

filter: Statementstmt 81.8% 27 / 33 Branchbran 100% 6 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 60.0% 3 / 5 totaltotal 77.1% 44 / 57 CC 7 SCAR 11.0
CC
7
Cov
83%
filter
5.0
add
3.0
inspect
2.0
CRAP 3.0
« blib/lib/App/Ack/ConfigFinder.pm ↑ Summary /usr/local/bin/perldoc »
1 package App::Ack::Filter::Collection;
2  
3 =head1 NAME
4  
5 App::Ack::Filter::Collection
6  
7 =head1 DESCRIPTION
8  
9 The Ack::Filter::Collection class can contain filters and internally sort
10 them into groups. The groups can then be optimized for faster filtering.
11  
12 Filters are grouped and replaced by a fast hash lookup. This leads to
13 improved performance when many such filters are active, like when using
14 the C<--known> command line option.
15  
16 =cut
17  
18 582 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 582 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 582 ▶use parent 'App::Ack::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1427 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
23 1427 my ( $class ) = @_;
24  
25 1427 return bless {
26 groups => {},
27 ungrouped => [],
28 }, $class;
29 }
30  
31 27143 ▶sub filter {
Subroutine filter: called CC=5 SCAR=16.1
Pod documented
32 27143 my ( $self, $file ) = @_;
33  
34 27143 for my $group (values %{$self->{groups}}) {
35 43896 ▶ return 1 if $group->filter($file);
Branch: 1 branch
BranchTrueFalseTotal
if $group->filter($file) 2623 41273 43896
36 }
37  
38 24520 for my $filter (@{$self->{ungrouped}}) {
39 4496 ▶ return 1 if $filter->filter($file);
Branch: 1 branch
BranchTrueFalseTotal
if $filter->filter($file) 3394 1102 4496
40 }
41  
42 21126 return 0;
43 }
44  
45 29908 ▶sub add {
Subroutine add: called CC=3 SCAR=11.0
Pod undocumented
46 29908 my ( $self, $filter ) = @_;
47  
48 29908 ▶ if (exists $filter->{'groupname'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $filter->{'groupname'}) { } 29667 241 29908
49 29667 ▶ my $group = ($self->{groups}->{$filter->{groupname}} ||= $filter->create_group());
Condition66%2/3
$self->{"groups"}{$filter->{"groupname"}} ||= $filter->create_group
l!l&&r!l&&!r
2758620810
MC/DC0%0/2
$self->{"groups"}{$filter->{"groupname"}} ||= $filter->create_group
$self->{"groups"}{$filter->{"groupname"}} $filter->create_group
Truth table66%2/3
A ||= B
A= $self->{"groups"}{$filter->{"groupname"}}B= $filter->create_group
ABresult
1X1
011
000
50 29667 $group->add($filter);
51 }
52 else {
53 241 push @{$self->{'ungrouped'}}, $filter;
54 }
55  
56 29908 return;
57 }
58  
59 0 ▶sub inspect {
Subroutine inspect: not called CC=1 SCAR=6.9
Pod documented
60 0 my ( $self ) = @_;
61  
62 0 return ref($self) . " - $self";
63 }
64  
65 0 ▶sub to_string {
Subroutine to_string: not called CC=1 SCAR=6.9
Pod documented
66 0 my ( $self ) = @_;
67  
68 0 return join(', ', map { "($_)" } @{$self->{ungrouped}});
69 }
70  
71 582 1;
« blib/lib/App/Ack/ConfigFinder.pm ↑ Summary /usr/local/bin/perldoc »