blib/lib/OPP/Proc/Uniq.pm

filter: Statementstmt 34.2% 12 / 35 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 30.0% 15 / 50 CC 9 SCAR 42.2
CC
9
Cov
27%
process
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 67.8
« blib/lib/OPP/Proc.pm ↑ Summary blib/lib/OPP/Proc/Pivots.pm »
1 #
2 # $Id: Uniq.pm,v 58d7ce835577 2023/03/25 10:34:10 gomor $
3 #
4 package OPP::Proc::Uniq;
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use base qw(OPP::Proc);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 __PACKAGE__->cgBuildIndices;
10  
11 1 our $VERSION = '1.00';
12  
13 #
14 # | uniq hostname
15 # | uniq ip,port,forward
16 #
17 sub process {
18 0 ▶ my $self = shift;
Subroutine process: not called CC=9 SCAR=45.0
Pod undocumented
19 0 my ($input) = @_;
20  
21 0 my $fields = $self->options->{0}; # XXX: check argument
22 0 ▶ return unless defined($fields);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fields 0 0 0
23  
24 0 my @fields = split('\s*,\s*', $fields);
25  
26 0 my $k = '';
27 0 for my $this (@fields) {
28 0 my $values = $self->value($input, $this);
29 0 ▶ next unless defined($values);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $values 0 0 0
30 0 for my $v (@$values) {
31 0 $k .= $this.'-'.$v.':';
32 }
33 }
34  
35 # Skip when no key found:
36 0 ▶ return 1 unless length $k;
Branch: 1 branch
BranchTrueFalseTotal
unless length $k 0 0 0
37  
38 0 ▶ unless ($self->state->exists($k, $self->idx)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state->exists($k, $self->idx)) 0 0 0
39 0 my $clone = $self->clone($input);
40 0 my %fields = map { $_ => 1 } @fields;
41 0 for my $this (@{$self->fields($clone)}) {
42 0 ▶ next if $fields{$this};
Branch: 1 branch
BranchTrueFalseTotal
if $fields{$this} 0 0 0
43 0 $self->delete($clone, $this);
44 }
45 0 $self->output->add($clone);
46 }
47  
48 0 $self->state->incr($k, $self->idx);
49  
50 0 return 1;
51 }
52  
53 1 1;
54  
55 __END__
« blib/lib/OPP/Proc.pm ↑ Summary blib/lib/OPP/Proc/Pivots.pm »