Validator/Plugin/Field040.pm

filter: Statementstmt 98.4% 63 / 64 Branchbran 70.0% 7 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 13 / 13 Podpod 100% 4 / 4 totaltotal 89.0% 89 / 100 CC 9 SCAR 13.6
CC
9
Cov
90%
process
8.3
_process_errors
2.0
BEGIN
1.0
CRAP 3.9
« Validator/Plugin/Field008.pm ↑ Summary Validator/Plugin/Field035.pm »
1 package MARC::Validator::Plugin::Field040;
2  
3 6 ▶use base qw(MARC::Validator::Abstract);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use Data::MARC::Validator::Report::Error 0.02;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Data::MARC::Validator::Report::Plugin::Errors 0.02;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Error::Pure::Utils qw(err_get);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use MARC::Leader 0.08;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 6 our $VERSION = 0.25;
14  
15 5 ▶sub module_name {
Subroutine module_name: called CC=1 SCAR=0.0
Pod documented
16 5 my $self = shift;
17  
18 5 return __PACKAGE__;
19 }
20  
21 6 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
22 6 my $self = shift;
23  
24 6 return 'field_040';
25 }
26  
27 3 ▶sub process {
Subroutine process: called CC=8 SCAR=21.2
Pod documented
28 3 my ($self, $marc_record) = @_;
29  
30 3 my $record_id = $self->{'cb_record_id'}->($marc_record);
31 3 my @record_errors;
32  
33 3 my $leader_string = $marc_record->leader;
34 3 my $leader = eval {
35 MARC::Leader->new(
36 3 'verbose' => $self->{'verbose'},
37 )->parse($leader_string);
38 };
39 3 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($MARC::Validator::Plugin::Field040::EVAL_ERROR) 1 2 3
40 1 my @errors = err_get(1);
41 1 foreach my $error (@errors) {
42 2 my %err_params = @{$error->{'msg'}}[1 .. $#{$error->{'msg'}}];
43 push @record_errors, Data::MARC::Validator::Report::Error->new(
44 2 'error' => $error->{'msg'}->[0],
45 'params' => \%err_params,
46 );
47 }
48 1 $self->_process_errors($record_id, @record_errors);
49 1 return;
50 }
51  
52 2 my $field_040 = $marc_record->field('040');
53 2 ▶ if (! defined $field_040) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $field_040) 1 1 2
54 1 push @record_errors, Data::MARC::Validator::Report::Error->new(
55 'error' => "Field 040 isn't present.",
56 );
57 1 $self->_process_errors($record_id, @record_errors);
58 1 return;
59 }
60  
61 1 ▶ if (! $field_040->subfield('a')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($field_040->subfield("a")) 0 1 1
62 0 push @record_errors, Data::MARC::Validator::Report::Error->new(
63 'error' => "Subfield 040a doesn't exists.",
64 );
65 }
66  
67 1 my $desc_conventions = $field_040->subfield('e');
68 1 ▶ if ($leader->descriptive_cataloging_form eq 'a'
Branch: 1 branch
BranchTrueFalseTotal
if ($leader->descriptive_cataloging_form eq "a" and defined $desc_conventions and $desc_conventions eq "rda") 1 0 1
Condition33%2/6
$leader->descriptive_cataloging_form eq "a" and defined $desc_conventions and $desc_conventions eq "rda"
!ll&&!rl&&r
001
$leader->descriptive_cataloging_form eq "a" and defined $desc_conventions
!ll&&!rl&&r
001
MC/DC0%0/3
$leader->descriptive_cataloging_form eq "a" and defined $desc_conventions and $desc_conventions eq "rda"
$leader->descriptive_cataloging_form eq "a" defined $desc_conventions $desc_conventions eq "rda"
Truth table25%1/4
A and B and C
A= $leader->descriptive_cataloging_form eq "a"B= defined $desc_conventionsC= $desc_conventions eq "rda"
ABCresult
0XX0
10X0
1100
1111
69 && defined $desc_conventions
70 && $desc_conventions eq 'rda') {
71  
72 1 push @record_errors, Data::MARC::Validator::Report::Error->new(
73 'error' => 'Leader descriptive cataloging form (a) is inconsistent with field 040e description conventions (rda).',
74 );
75 }
76  
77 1 $self->_process_errors($record_id, @record_errors);
78  
79 1 return;
80 }
81  
82 5 ▶sub version {
Subroutine version: called CC=1 SCAR=0.0
Pod documented
83 5 my $self = shift;
84  
85 5 return $VERSION;
86 }
87  
88 3 ▶sub _process_errors {
Subroutine _process_errors: called CC=2 SCAR=7.0
89 3 my ($self, $record_id, @record_errors) = @_;
90  
91 3 ▶ if (@record_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@record_errors) 3 0 3
92 3 push @{$self->{'errors'}}, Data::MARC::Validator::Report::Plugin::Errors->new(
93 'errors' => \@record_errors,
94 3 'filters' => $self->{'filters'},
95 'record_id' => $record_id,
96 );
97 }
98  
99 3 return;
100 }
101  
102 6 1;
103  
104 __END__
« Validator/Plugin/Field008.pm ↑ Summary Validator/Plugin/Field035.pm »