From 07be5809aae45ab263bf096496c3332a8c3f4c28 Mon Sep 17 00:00:00 2001 From: Phan Tung Bui Date: Thu, 22 Feb 2024 16:54:24 -0500 Subject: [PATCH] Bug 36027: Tidy code for QA script --- .../search_for_data_inconsistencies.pl | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl index ec013efe4e..2ee1fd4cd0 100755 --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ b/misc/maintenance/search_for_data_inconsistencies.pl @@ -40,49 +40,52 @@ use Data::Dumper; # Option 7: CheckRelationshipsLoop - Check for relationships or dependencies between borrowers in a loop my %methods = ( -1 => \&CheckItemsBranch, -2 => \&CheckItemsAuthHeader, -3 => \&CheckItemsStatus, -4 => \&CheckItemsFramework, -5 => \&CheckItemsTitle, -6 => \&CheckAgeForCategory, + 1 => \&CheckItemsBranch, + 2 => \&CheckItemsAuthHeader, + 3 => \&CheckItemsStatus, + 4 => \&CheckItemsFramework, + 5 => \&CheckItemsTitle, + 6 => \&CheckAgeForCategory, ); my @methods_to_run; -if (@ARGV == 0) { +if ( @ARGV == 0 ) { + # If no arguments are provided, add all methods to the list @methods_to_run = keys %methods; - } else { +} +else { foreach my $arg (@ARGV) { - if ($arg =~ /^(\d+)$/) { + if ( $arg =~ /^(\d+)$/ ) { my $method_number = $1; - if ($method_number >= 1 && $method_number <= 7) { + if ( $method_number >= 1 && $method_number <= 7 ) { push @methods_to_run, $method_number; - } else { + } + else { print "Invalid method number: $method_number\n"; } - } else { + } + else { print "Invalid argument: $arg\n"; } } } foreach my $choice (@methods_to_run) { - if ($choice =~ /^\d+$/ && $choice >= 1 && $choice <= 7) { - if (exists $methods{$choice}) { + if ( $choice =~ /^\d+$/ && $choice >= 1 && $choice <= 7 ) { + if ( exists $methods{$choice} ) { $methods{$choice}->(); - } else { + } + else { print "Method $choice not found\n"; } - } else { + } + else { print "Invalid choice: $choice\n"; } } - - - sub CheckItemsBranch { my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch")} -- 2.34.1