From a04f9447f7e3e92fc1faebd9998b1fdf223eb4fb Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sat, 14 Oct 2023 21:48:42 +0000 Subject: [PATCH] Bug 27943: (QA follow-up) Perltidy I have some trouble to get the tidyness test on AuthoritiesMarc.pm passing. There are several outstanding patches touching this file, so I didn't dare to perltidy the whole file just yet. Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/AuthoritiesMarc.pm | 136 +++++++++++++++---------------- t/db_dependent/AuthoritiesMarc.t | 78 +++++++++--------- 2 files changed, 106 insertions(+), 108 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 67464d826d..6989a6a513 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -991,8 +991,8 @@ sub BuildSummary { use C4::Heading::MARC21; my $handler = C4::Heading::MARC21->new(); my $subfields_to_report; - my $subfields_to_subdivision=""; - my $delimiter = C4::Context->preference('AuthoritySeparator'); + my $subfields_to_subdivision = ""; + my $delimiter = C4::Context->preference('AuthoritySeparator'); foreach my $field ($record->field('1..')) { my $tag = $field->tag(); @@ -1071,70 +1071,68 @@ sub BuildSummary { push @notes, { note => $field->as_string(), field => $field->tag() }; } - foreach my $field ($record->field('7..')) - { - my $tag = $field->tag(); - - if ($tag eq '700') { - $subfields_to_report = 'abcdefghjklmnopqrst'; - $subfields_to_subdivision='vxyz'; - } elsif ($tag eq '710') { - $subfields_to_report = 'abcdefghklmnoprst'; - $subfields_to_subdivision='vxyz'; - } elsif ($tag eq '711') { - $subfields_to_report = 'acdefghklnpqst'; - $subfields_to_subdivision='vxyz'; - } elsif ($tag eq '730') { - $subfields_to_report = 'adfghklmnoprst'; - $subfields_to_subdivision='vxyz'; - } elsif ($tag eq '748') { - $subfields_to_report = 'ab'; - $subfields_to_subdivision='vxyz'; - } elsif ($tag eq '750') { - $subfields_to_report = 'ab'; - $subfields_to_subdivision='vxyz'; - } elsif ($tag eq '751') { - $subfields_to_report = 'a'; - $subfields_to_subdivision='vxyz'; - } elsif ($tag eq '755') { - $subfields_to_report = 'abvxyz'; - $subfields_to_subdivision='vxyz'; - } elsif ($tag eq '780') { - $subfields_to_report = 'vxyz'; - $delimiter=" "; - } elsif ($tag eq '781') { - $subfields_to_report = 'vxyz'; - $delimiter=" "; - } elsif ($tag eq '782') { - $subfields_to_report = 'vxyz'; - $delimiter=" "; - } elsif ($tag eq '785') { - $subfields_to_report = 'vxyz'; - $delimiter=" "; - } + foreach my $field ( $record->field('7..') ) { + my $tag = $field->tag(); + + if ( $tag eq '700' ) { + $subfields_to_report = 'abcdefghjklmnopqrst'; + $subfields_to_subdivision = 'vxyz'; + } elsif ( $tag eq '710' ) { + $subfields_to_report = 'abcdefghklmnoprst'; + $subfields_to_subdivision = 'vxyz'; + } elsif ( $tag eq '711' ) { + $subfields_to_report = 'acdefghklnpqst'; + $subfields_to_subdivision = 'vxyz'; + } elsif ( $tag eq '730' ) { + $subfields_to_report = 'adfghklmnoprst'; + $subfields_to_subdivision = 'vxyz'; + } elsif ( $tag eq '748' ) { + $subfields_to_report = 'ab'; + $subfields_to_subdivision = 'vxyz'; + } elsif ( $tag eq '750' ) { + $subfields_to_report = 'ab'; + $subfields_to_subdivision = 'vxyz'; + } elsif ( $tag eq '751' ) { + $subfields_to_report = 'a'; + $subfields_to_subdivision = 'vxyz'; + } elsif ( $tag eq '755' ) { + $subfields_to_report = 'abvxyz'; + $subfields_to_subdivision = 'vxyz'; + } elsif ( $tag eq '780' ) { + $subfields_to_report = 'vxyz'; + $delimiter = " "; + } elsif ( $tag eq '781' ) { + $subfields_to_report = 'vxyz'; + $delimiter = " "; + } elsif ( $tag eq '782' ) { + $subfields_to_report = 'vxyz'; + $delimiter = " "; + } elsif ( $tag eq '785' ) { + $subfields_to_report = 'vxyz'; + $delimiter = " "; + } - my $heading = $field->as_string($subfields_to_report); + my $heading = $field->as_string($subfields_to_report); - my $subheading = $field->as_string($subfields_to_subdivision,$delimiter); - if(length $subheading > 0 ) - { - $heading.=$delimiter.$subheading; - } + my $subheading = $field->as_string( $subfields_to_subdivision, $delimiter ); + if ( length $subheading > 0 ) { + $heading .= $delimiter . $subheading; + } - if ($subfields_to_report) { - push @equalterm, { - heading => $heading, - hemain => ( $field->subfield( substr($subfields_to_report, 0, 1) ) // undef ), - field => $tag, - }; - } else { - push @equalterm, { - heading => $field->as_string(), - hemain => ( $field->subfield( 'a' ) // undef ), - field => $tag, - }; - } + if ($subfields_to_report) { + push @equalterm, { + heading => $heading, + hemain => ( $field->subfield( substr( $subfields_to_report, 0, 1 ) ) // undef ), + field => $tag, + }; + } else { + push @equalterm, { + heading => $field->as_string(), + hemain => ( $field->subfield('a') // undef ), + field => $tag, + }; } + } foreach my $field ($record->field('880')) { my $linkage = $field->subfield('6'); @@ -1156,14 +1154,14 @@ sub BuildSummary { push @otherscript, { term => $field->as_string($subfields_to_report), category => $category, type => $type, direction => $direction, linkage => $linkage }; } } - $summary{mainentry} = $authorized[0]->{heading}; + $summary{mainentry} = $authorized[0]->{heading}; $summary{mainmainentry} = $authorized[0]->{hemain}; - $summary{authorized} = \@authorized; - $summary{notes} = \@notes; - $summary{seefrom} = \@seefrom; - $summary{seealso} = \@seealso; - $summary{otherscript} = \@otherscript; - $summary{equalterm} = \@equalterm; + $summary{authorized} = \@authorized; + $summary{notes} = \@notes; + $summary{seefrom} = \@seefrom; + $summary{seealso} = \@seealso; + $summary{otherscript} = \@otherscript; + $summary{equalterm} = \@equalterm; return \%summary; } diff --git a/t/db_dependent/AuthoritiesMarc.t b/t/db_dependent/AuthoritiesMarc.t index 2bb69ba36c..5f5c86f2c6 100755 --- a/t/db_dependent/AuthoritiesMarc.t +++ b/t/db_dependent/AuthoritiesMarc.t @@ -130,32 +130,33 @@ $dbh->do(q{ t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); my $expected_marc21_summary = { 'authorized' => [ - { - 'field' => '151', - 'heading' => 'New York (State)', - 'hemain' => 'New York (State)' - } - ], - 'authtypecode' => 'GEOGR_NAME', - 'mainentry' => 'New York (State)', + { + 'field' => '151', + 'heading' => 'New York (State)', + 'hemain' => 'New York (State)' + } + ], + 'authtypecode' => 'GEOGR_NAME', + 'mainentry' => 'New York (State)', 'mainmainentry' => 'New York (State)', - 'notes' => [], - 'otherscript' => [], - 'seealso' => [ - { - 'authid' => '1', - 'field' => '551', - 'heading' => 'United States', - 'hemain' => 'United States', - 'search' => 'United States', - 'type' => 'broader' - } - ], - 'seefrom' => [], - 'label' => 'Geographic Name', - 'type' => 'Geographic Name', + 'notes' => [], + 'otherscript' => [], + 'seealso' => [ + { + 'authid' => '1', + 'field' => '551', + 'heading' => 'United States', + 'hemain' => 'United States', + 'search' => 'United States', + 'type' => 'broader' + } + ], + 'seefrom' => [], + 'label' => 'Geographic Name', + 'type' => 'Geographic Name', 'equalterm' => [] }; + is_deeply( BuildSummary(C4::AuthoritiesMarc::GetAuthority(2), 2, 'GEOGR_NAME'), $expected_marc21_summary, @@ -183,23 +184,22 @@ $unimarc_name_auth->add_fields( ); my $expected_unimarc_name_summary = { 'authorized' => [ - { - 'field' => '200', - 'heading' => 'Fossey Brigitte', - 'hemain' => 'Fossey' - } - ], - 'authtypecode' => 'NP', - 'mainentry' => 'Fossey Brigitte', + { + 'field' => '200', + 'heading' => 'Fossey Brigitte', + 'hemain' => 'Fossey' + } + ], + 'authtypecode' => 'NP', + 'mainentry' => 'Fossey Brigitte', 'mainmainentry' => 'Fossey', - 'notes' => [], - 'otherscript' => [], - 'seealso' => [], - 'seefrom' => [], - 'summary' => 'Fossey, Brigitte', - 'type' => 'Auteur', - 'equalterm' => [] - + 'notes' => [], + 'otherscript' => [], + 'seealso' => [], + 'seefrom' => [], + 'summary' => 'Fossey, Brigitte', + 'type' => 'Auteur', + 'equalterm' => [] }; is_deeply( -- 2.39.5