[Patches] [PATCH] Bug 6679 : cataloguing/ now passing critic tests

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Fri Nov 4 19:55:44 NZDT 2011


From: Chris Cormack <chrisc at catalyst.net.nz>
Date: Mon, 31 Oct 2011 21:16:29 +1300
Subject: [PATCH] Bug 6679 : cataloguing/ now passing critic tests

Declare variables outside of conditionals
Don't use prototypes http://www.modernperlbooks.com/mt/2009/08/the-problem-with-prototypes.html
Use ":encoding(UTF-8)" to get strict validation.
---
 cataloguing/addbiblio.pl |    8 ++++----
 cataloguing/additem.pl   |    3 ++-
 cataloguing/merge.pl     |    2 +-
 cataloguing/ysearch.pl   |    2 +-
 t/00-testcritic.t        |    2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl
index 1a82989..71d43d7 100755
--- a/cataloguing/addbiblio.pl
+++ b/cataloguing/addbiblio.pl
@@ -159,7 +159,7 @@ sub MARCfindbreeding {
 
 =cut
 
-sub build_authorized_values_list ($$$$$$$) {
+sub build_authorized_values_list {
     my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
 
     my @authorised_values;
@@ -252,7 +252,7 @@ sub build_authorized_values_list ($$$$$$$) {
 
 =cut
 
-sub CreateKey(){
+sub CreateKey {
     return int(rand(1000000));
 }
 
@@ -263,7 +263,7 @@ sub CreateKey(){
 
 =cut
 
-sub GetMandatoryFieldZ3950($){
+sub GetMandatoryFieldZ3950 {
     my $frameworkcode = shift;
     my @isbn   = GetMarcFromKohaField('biblioitems.isbn',$frameworkcode);
     my @title  = GetMarcFromKohaField('biblio.title',$frameworkcode);
@@ -536,7 +536,7 @@ sub format_indicator {
     return $ind_value;
 }
 
-sub build_tabs ($$$$$) {
+sub build_tabs {
     my ( $template, $record, $dbh, $encoding,$input ) = @_;
 
     # fill arrays
diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index 4442ed3..d8bc877 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -381,7 +381,8 @@ if ($op eq "additem") {
         my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode",$frameworkcode);
 
 	# If there is a barcode and we can't find him new values, we can't add multiple copies
-        my $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
+	my $testbarcode;
+        $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
 	if ($oldbarcode && !$testbarcode) {
 
 	    push @errors, "no_next_barcode";
diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl
index e3ee725..0b881f1 100755
--- a/cataloguing/merge.pl
+++ b/cataloguing/merge.pl
@@ -250,7 +250,7 @@ Create a random value to set it into the input name
 
 =cut
 
-sub createKey(){
+sub createKey {
     return int(rand(1000000));
 }
 
diff --git a/cataloguing/ysearch.pl b/cataloguing/ysearch.pl
index 5cd0205..a697ddb 100755
--- a/cataloguing/ysearch.pl
+++ b/cataloguing/ysearch.pl
@@ -39,7 +39,7 @@ my $field = $input->param('field');
 # Prevent from disclosing data
 die() unless ($table eq "biblioitems"); 
 
-binmode STDOUT, ":utf8";
+binmode STDOUT, ":encoding(UTF-8)";
 print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
 
 my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { cataloguing => '*' } );
diff --git a/t/00-testcritic.t b/t/00-testcritic.t
index c97828b..aad6471 100755
--- a/t/00-testcritic.t
+++ b/t/00-testcritic.t
@@ -16,7 +16,7 @@ my @all_koha_dirs = qw( acqui admin authorities basket C4 catalogue cataloguing
 labels members misc offline_circ opac patroncards reports reserve reviews rotating_collections
 serials sms suggestion t tags test tools virtualshelves);
 
-my @dirs = qw( acqui admin authorities basket catalogue circ debian errors offline_circ reserve 
+my @dirs = qw( acqui admin authorities basket catalogue cataloguing circ debian errors offline_circ reserve 
     reviews rotating_collections serials sms virtualshelves );
 
 if ( not $ENV{TEST_QA} ) {
-- 
1.7.5.4


More information about the Patches mailing list