[Mageia-dev] [soft-commits] [2359] coding style update (perl_checker)

Thierry Vignaud thierry.vignaud at gmail.com
Sat Dec 10 18:59:32 CET 2011


On 10 December 2011 18:29,  <root at mageia.org> wrote:
> Revision 2359 Author rda Date 2011-12-10 18:29:07 +0100 (Sat, 10 Dec 2011)
>
> Log Message
>
> coding style update (perl_checker)

uh? Tools.pm doesn't currently pass perl_checker

> Modified Paths
>
> isocheck/trunk/Tools.pm
> isocheck/trunk/t/003_is_hybrid.t
> isocheck/trunk/t_install_iso/010_check_autorun.t
> isocheck/trunk/t_install_iso/012_check_ids.t
> isocheck/trunk/t_install_iso/013_check_rpms.t
> isocheck/trunk/t_install_iso/016_check_pubkey.t
>
> Modified: isocheck/trunk/Tools.pm
> ===================================================================
> --- isocheck/trunk/Tools.pm	2011-12-10 17:27:16 UTC (rev 2358)
> +++ isocheck/trunk/Tools.pm	2011-12-10 17:29:07 UTC (rev 2359)
> @@ -33,18 +33,18 @@
>
>  sub parse_mageia_iso_name {
>      my ($name) = @_;
> -    my %info = ();
> +    my %info;
>
> -    if ($name =~
> m/^(Mageia)-(\d+)(-(alpha|beta|RC)(\d*))?(-(.*))?-(i586|x86_64|dual)?(-(CD|DVD|BD))?(-(build\_\w+))?\.(.*)$/)
> {
> -        $info{"full"}    = $name;
> -        $info{"name"}    = $1  if defined $1;
> -        $info{"version"} = $2  if defined $2;
> -        $info{"release"} = "$4$5" if defined $4;
> -        $info{"variant"} = $7  if defined $7;
> -        $info{"arch"}    = $8  if defined $8;
> -        $info{"medium"}  = $10 if defined $10;
> -        $info{"build"}   = $12 if defined $12;
> -        $info{"ext"}     = $13 if defined $13;
> +    if ($name =~
> m/^(Mageia)-(\d+)(-(alpha|beta|RC)(\d*))?(-(.*))?-(i586|x86_64|dual)?(-(CD|DVD|BD))?(-(build_\w+))?\.(.*)$/)
> {
> +        $info{full}    = $name;
> +        $info{name}    = $1  if defined $1;
> +        $info{version} = $2  if defined $2;
> +        $info{release} = "$4$5" if defined $4;
> +        $info{variant} = $7  if defined $7;
> +        $info{arch}    = $8  if defined $8;
> +        $info{medium}  = $10 if defined $10;
> +        $info{build}   = $12 if defined $12;
> +        $info{ext}     = $13 if defined $13;

You don't need all those tests since you already checked if the regexp
matched or not.
You only have to check for ()? groups.
What's more your checks are inconsistant anyway (eg you don't check for $5)


just do sg like this:

sub parse_mageia_iso_name {
    my ($name) = @_;
    my %info;

    if ((@info{qw(name version release variant arch medium build
ext)}) = $name =~
	m/^(Mageia)-(\d+)-((?:alpha|beta|RC)\d*)?(-(?:.*))?-(i586|x86_64|dual)?(?:-(CD|DVD|BD))?(?:-(build_\w+))?\.(.*)$/)
{
        $info{full} = $name;
    }

    return %info;
}


> Modified: isocheck/trunk/t/003_is_hybrid.t
> ===================================================================
> --- isocheck/trunk/t/003_is_hybrid.t	2011-12-10 17:27:16 UTC (rev 2358)
> +++ isocheck/trunk/t/003_is_hybrid.t	2011-12-10 17:29:07 UTC (rev 2359)
> @@ -24,7 +24,7 @@
>
>  my ($image_path) = @ARGV;
>
> -ok (is_hybrid($image_path, 0), "Is hybrid");
> +ok is_hybrid($image_path, 0), "Is hybrid";

please keep (), it's clearer. just remove the space between "ok" and "("


> Modified: isocheck/trunk/t_install_iso/016_check_pubkey.t
> ===================================================================
> --- isocheck/trunk/t_install_iso/016_check_pubkey.t	2011-12-10 17:27:16 UTC
> (rev 2358)
> +++ isocheck/trunk/t_install_iso/016_check_pubkey.t	2011-12-10 17:29:07 UTC
> (rev 2359)
> @@ -39,17 +39,17 @@
>  system "ls /media/iso_check/i586/media/ > temp_media_on_iso.log" if -r
> "/media/iso_check/i586/media/";
>  system "ls /media/iso_check/x86_64/media/ >> temp_media_on_iso.log" if -r
> "/media/iso_check/x86_64/media/";
>
> -ok (-r "temp_media_on_iso.log", "Got a log for media contents");
> +ok -r "temp_media_on_iso.log", "Got a log for media contents";
>
>  open(my $file, "temp_media_on_iso.log") if -r "temp_media_on_iso.log";
>
>  while ($media = <$file>) {

just reuse cat_() from MDK::Common (simpler, easier to read)


More information about the Mageia-dev mailing list