[Koha-devel] koha code cleaning bug?

Sébastien Nadeau Sebastien.Nadeau at bibl.ulaval.ca
Mon Sep 29 15:36:21 CEST 2008


Hi Marc,

Since I'm new to this list and it's my first post, I will introduce myself. I'm analyst at Bibliothèque de l'Université Laval in Québec, been working there for a while now (> 10 years), administering and developping solutions for our ILS Unicorn and Aleph 500, mostly in Perl. Thought it could be interesting to join in an open source initiative.

Now, concerning your snippet of code, no need to tell how much it's an improvement over the original one, but there seems to be some little things missing. Here would be my additions:

foreach my $subdir ('',qw( lock register shadow tab key )) {
     next if (-d "$authorityserverdir/$subdir");
     system "mkdir -p $authorityserverdir/$subdir";
     $created_dir_or_file++;
     print "Info: created $authorityserverdir/$subdir\n";
}

I think it's nice to use an iteration variable ($subdir) instead of the anonymous scalar $_.<

I hope I'm not looking too pretentious for my first post.

Sébastien
Analyste de l'informatique
Bibliothèque de l'Université Laval



> -----Message d'origine-----
> De : koha-devel-bounces at lists.koha.org 
> [mailto:koha-devel-bounces at lists.koha.org] De la part de Marc 
> Chantreux
> Envoyé : 29 septembre 2008 06:18
> À : koha-devel at lists.koha.org
> Objet : [Koha-devel] koha code cleaning bug?
> 
> hello all, 
> 
> the code that ends this email comes from zebra_rebuild.pl. It 
> can be rewritten as: 
> 
> for('',qw( lock register shadow tab key )) {
>     next if -d;
>     $created_dir_or_file++;
>     system("mkdir -p $authorityserverdir");
>     print "Info: created $authorityserverdir/$_"; } 
> 
> That is not a bug but it is currently written makes the 
> things harder to read and maintain and it discourages to 
> provide a patch to improve the code(imho). I would like to 
> provide a patch to clean this code.
> 
> This code is not the only one and so i wonder if the koha 
> communauty wants to have this kind of patch. I also wonder 
> how to do this because of the "fill a bug first" policy. It 
> can be possible to create a "code cleaning" bug that will 
> stay unfixed and our patches can be related to this one.
> 
> regards, 
> 
>     unless (-d "$authorityserverdir") {
>         system("mkdir -p $authorityserverdir");
>         print "Info: created $authorityserverdir\n";
>         $created_dir_or_file++;
>     }
>     unless (-d "$authorityserverdir/lock") {
>         mkdir "$authorityserverdir/lock";
>         print "Info: created $authorityserverdir/lock\n";
>         $created_dir_or_file++;
>     }
>     unless (-d "$authorityserverdir/register") {
>         mkdir "$authorityserverdir/register";
>         print "Info: created $authorityserverdir/register\n";
>         $created_dir_or_file++;
>     }
>     unless (-d "$authorityserverdir/shadow") {
>         mkdir "$authorityserverdir/shadow";
>         print "Info: created $authorityserverdir/shadow\n";
>         $created_dir_or_file++;
>     }
>     unless (-d "$authorityserverdir/tab") {
>         mkdir "$authorityserverdir/tab";
>         print "Info: created $authorityserverdir/tab\n";
>         $created_dir_or_file++;
>     }
>     unless (-d "$authorityserverdir/key") {
>         mkdir "$authorityserverdir/key";
>         print "Info: created $authorityserverdir/key\n";
>         $created_dir_or_file++;
> ... 
> 
> --
> Marc Chantreux
> http://www.biblibre.com
> Expert en Logiciels Libres pour l'info-doc 
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha.org
> http://lists.koha.org/mailman/listinfo/koha-devel
> 



More information about the Koha-devel mailing list