Treex/Block/Util/FixInvalidIDs.pm

filter: Statementstmt 33.3% 10 / 30 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 22.8% 13 / 57 CC 13 SCAR 50.6
CC
13
Cov
20%
process_zone
182.0
BEGIN
1.0
BEGIN
1.0
CRAP 157.9
« Treex/Core/Resource.pm ↑ Summary Treex/Block/Util/Find.pm »
1 package Treex::Block::Util::FixInvalidIDs;
2 1 $Treex::Block::Util::FixInvalidIDs::VERSION = '2.20210102';
3 1 ▶use Treex::Core::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 extends 'Treex::Core::Block';
6  
7 1 has action => (
8 is=>'ro',
9 default=>'warn',
10 );
11  
12 0 ▶sub process_zone {
Subroutine process_zone: not called CC=13 SCAR=52.0
Pod documented
13 0 my ( $self, $zone ) = @_;
14 0 my $doc = $zone->get_document();
15  
16 0 foreach my $tnode ($zone->get_ttree()->get_descendants()){
17 0 my $lex_rf = $tnode->get_attr('a/lex.rf');
18 0 ▶ if (!defined $lex_rf) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $lex_rf) { } 0 0 0
elsif (not $doc->id_is_indexed($lex_rf)) { } 0 0 0
19 0 ▶ log_warn "Missing id in a/lex.rf of " . $tnode->get_address if $self->action eq 'warn';
Branch: 1 branch
BranchTrueFalseTotal
if $self->action eq "warn" 0 0 0
20 }
21 elsif (!$doc->id_is_indexed($lex_rf)){
22 0 $tnode->set_lex_anode(undef);
23 0 ▶ log_warn "Missing node with id $lex_rf in a/lex.rf of " . $tnode->get_address if $self->action eq 'warn';
Branch: 1 branch
BranchTrueFalseTotal
if $self->action eq "warn" 0 0 0
24 }
25 0 my $aux_rfs = $tnode->get_attr('a/aux.rf');
26 0 ▶ if ($aux_rfs){
Branch: 1 branch
BranchTrueFalseTotal
if ($aux_rfs) 0 0 0
27 0 ▶ my @filtered = grep {defined $_ && $doc->id_is_indexed($_)} @$aux_rfs;
Condition0%0/3
defined $_ && $doc->id_is_indexed($_)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && $doc->id_is_indexed($_)
defined $_ $doc->id_is_indexed($_)
Truth table0%0/3
A && B
A= defined $_B= $doc->id_is_indexed($_)
ABresult
0X0
100
111
28 0 ▶ if (@filtered != @$aux_rfs){
Branch: 1 branch
BranchTrueFalseTotal
if (@filtered != @$aux_rfs) 0 0 0
29 0 $tnode->set_attr('a/aux.rf', \@filtered);
30  
31 0 ▶ if ($self->action eq 'warn') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->action eq "warn") 0 0 0
32 0 foreach my $aux_rf (@$aux_rfs){
33 0 ▶ if (!defined $aux_rf) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $aux_rf) { } 0 0 0
elsif (not $doc->id_is_indexed($aux_rf)) { } 0 0 0
34 0 log_warn "Missing id in a/aux.rf of " . $tnode->get_address;
35 } elsif (!$doc->id_is_indexed($aux_rf)){
36 0 log_warn "Missing node with id $aux_rf in a/aux.rf of " . $tnode->get_address;
37 }
38 }
39 }
40 }
41 }
42 }
43  
44 0 return;
45 }
46  
47 1 1;
48  
49 __END__
« Treex/Core/Resource.pm ↑ Summary Treex/Block/Util/Find.pm »