Commits

Anonymous committed 377a619

Perl::Critic refactoring

  • Participants
  • Parent commits 8b93d8e

Comments (0)

Files changed (8)

 use strict;
+use warnings;
 use lib qw( builder );
 use Build;
 
 my $mb = Build->new;
 $mb->change_versions(1);
 $mb->create_build_script;
+
+1;
     module_name    => 'Sys::Info::Driver::Unknown',
     requires       => {
         'Sys::Info::Base' => '0.72',
+        ( $] < 5.006 ? ( 'warnings::compat' => 0 ) : ()),
     },
     build_requires => {
         'Test::Sys::Info' => '0.15',

File lib/Sys/Info/Driver/Unknown.pm

 package Sys::Info::Driver::Unknown;
 use strict;
+use warnings;
 use vars qw( $VERSION );
 
 $VERSION = '0.73';

File lib/Sys/Info/Driver/Unknown/Device.pm

 package Sys::Info::Driver::Unknown::Device;
 use strict;
+use warnings;
 use vars qw( $VERSION );
 
 $VERSION = '0.70';

File lib/Sys/Info/Driver/Unknown/Device/CPU.pm

 package Sys::Info::Driver::Unknown::Device::CPU;
 use strict;
+use warnings;
 use vars qw($VERSION $UP);
 use base qw(Sys::Info::Driver::Unknown::Device::CPU::Env);
 
 BEGIN {
     local $SIG{__DIE__};
     local $@;
-    eval {
+    my $eok = eval {
         require Unix::Processors;
         Unix::Processors->import;
     };
     $UP = Unix::Processors->new if ! $@;
 }
 
-sub load { 0 }
-
+sub load    {}
 sub bitness {}
 
 sub identify {

File lib/Sys/Info/Driver/Unknown/Device/CPU/Env.pm

 package Sys::Info::Driver::Unknown::Device::CPU::Env;
 use strict;
+use warnings;
 use vars qw( $VERSION );
 
 $VERSION = '0.70';
         }
 
         my($cpu, $count, @cpu);
-        if ($CPU{id} =~ /(.+?), (?:Genuine(Intel)|Authentic(AMD))/) {
+        if ($CPU{id} =~ /(.+?), \s (?:Genuine(Intel)|Authentic(AMD))/xms ) {
             my $cid  = $1;
             my $corp = $2 || $3;
             if ( my %info = $self->_parse( $cid ) ) {
                 if ( my $mn = $self->_corp( $corp, $info{Family} ) ) {
                     if ( my $name = $mn->{ $info{Model} } ) {
-                        $count = ($CPU{number} && $CPU{number} > 1) ? $CPU{number} : '';
+                        $count = ($CPU{number} && $CPU{number} > 1) ? $CPU{number} : q{};
                         $cpu   = "$corp $name";
                     }
                 }
         }
 
         foreach my $other (keys %OTHER_ID) {
-            if ($CPU{id} =~ /\Q$other/) {
+            if ($CPU{id} =~ / \Q$other\E /xms) {
                 $cpu = $OTHER_ID{$other};
             }
         }
         $CPU{id} = $self->__env_pi;
     }
     $INSTALLED = 1;
+    return;
 }
 
 sub _corp {
     my $self   = shift;
     my $corp   = shift;
     my $family = shift;
-    return $INTEL{$family} if $corp eq 'Intel';
-    return $AMD{$family}   if $corp eq 'AMD';
+    return    $corp eq 'Intel' ? $INTEL{$family}
+            : $corp eq 'AMD'   ? $AMD{$family}
+            :                    undef;
 }
 
 sub _parse {
     my $self = shift;
     my $id   = shift;
     my $arch = $CPU{arch};
-    if ($id =~ /$arch\s(.+?)$/) {
-        my %h = split /\s+/, $1; # Family Model Stepping
+    if ($id =~ /$arch\s(.+?) \z/xms) {
+        my %h = split /\s+/xms, $1; # Family Model Stepping
         for my $k (keys %h) {
-            $h{$k} = '' unless defined $h{$k};
+            $h{$k} = q{} unless defined $h{$k};
         }
         return %h;
     }
 
 sub _INTEL {
    # Family  Model    Name
-    4  => {
-            0     => '486 DX-25/33',
-            1     => '486 DX-50',
-            2     => '486 SX',
-            3     => '486 DX/2',
-            4     => '486 SL',
-            5     => '486 SX/2',
-            7     => '486 DX/2-WB',
-            8     => '486 DX/4',
-            9     => '486 DX/4-WB',
+   return
+    '4'  => {
+            '0'     => '486 DX-25/33',
+            '1'     => '486 DX-50',
+            '2'     => '486 SX',
+            '3'     => '486 DX/2',
+            '4'     => '486 SL',
+            '5'     => '486 SX/2',
+            '7'     => '486 DX/2-WB',
+            '8'     => '486 DX/4',
+            '9'     => '486 DX/4-WB',
     },
-    5  => {
-            0     => 'Pentium 60/66 A-step',
-            1     => 'Pentium 60/66',
-            2     => 'Pentium 75 - 200',
-            3     => 'OverDrive PODP5V83',
-            4     => 'Pentium MMX',
-            7     => 'Mobile Pentium 75 - 200',
-            8     => 'Mobile Pentium MMX',
+    '5'  => {
+            '0'     => 'Pentium 60/66 A-step',
+            '1'     => 'Pentium 60/66',
+            '2'     => 'Pentium 75 - 200',
+            '3'     => 'OverDrive PODP5V83',
+            '4'     => 'Pentium MMX',
+            '7'     => 'Mobile Pentium 75 - 200',
+            '8'     => 'Mobile Pentium MMX',
     },
-    6  => {
-            0     => 'Pentium Pro A-step',
-            1     => 'Pentium Pro',
-            3     => 'Pentium II (Klamath)',
-            5     => 'Pentium II (Deschutes), Celeron (Covington), Mobile Pentium II (Dixon)',
-            6     => 'Mobile Pentium II, Celeron (Mendocino)',
-            7     => 'Pentium III (Katmai)',
-            8     => 'Pentium III (Coppermine)',
-            9     => 'Mobile Pentium III',
-            10    => 'Pentium III (0.18 �m)',
-            11    => 'Pentium III (0.13 �m)',
+    '6'  => {
+            '0'     => 'Pentium Pro A-step',
+            '1'     => 'Pentium Pro',
+            '3'     => 'Pentium II (Klamath)',
+            '5'     => 'Pentium II (Deschutes), Celeron (Covington), Mobile Pentium II (Dixon)',
+            '6'     => 'Mobile Pentium II, Celeron (Mendocino)',
+            '7'     => 'Pentium III (Katmai)',
+            '8'     => 'Pentium III (Coppermine)',
+            '9'     => 'Mobile Pentium III',
+            '10'    => 'Pentium III (0.18 �m)',
+            '11'    => 'Pentium III (0.13 �m)',
 
-            13    => 'Celeron M', # ???
-            15    => 'Core 2 Duo (Merom)', # ???
+            '13'    => 'Celeron M', # ???
+            '15'    => 'Core 2 Duo (Merom)', # ???
     },
-    7  => {
-            0     => 'Itanium (IA-64)',
+    '7'  => {
+            '0'     => 'Itanium (IA-64)',
     },
-    15 => {
-            0     => "Pentium IV (0.18 �m)",
-            1     => "Pentium IV (0.18 �m)",
-            2     => "Pentium IV (0.13 �m)",
-            3     => "Pentium IV (0.09 �m)",
+    '15' => {
+            '0'     => 'Pentium IV (0.18 �m)',
+            '1'     => 'Pentium IV (0.18 �m)',
+            '2'     => 'Pentium IV (0.13 �m)',
+            '3'     => 'Pentium IV (0.09 �m)',
             # Itanium 2 (IA-64)?
     },
 }
 
 sub _AMD {
     # Family  Model    Name
-    4  => {
-        3     => '486 DX/2',
-        7     => '486 DX/2-WB',
-        8     => '486 DX/4',
-        9     => '486 DX/4-WB',
-        14    => 'Am5x86-WT',
-        15    => 'Am5x86-WB',
+    return
+    '4'  => {
+        '3'     => '486 DX/2',
+        '7'     => '486 DX/2-WB',
+        '8'     => '486 DX/4',
+        '9'     => '486 DX/4-WB',
+        '14'    => 'Am5x86-WT',
+        '15'    => 'Am5x86-WB',
     },
-    5  => {
-        0     => 'K5/SSA5',
-        1     => 'K5',
-        2     => 'K5',
-        3     => 'K5',
-        6     => 'K6',
-        7     => 'K6',
-        8     => 'K6-2',
-        9     => 'K6-3',
-        13    => 'K6-2+ or K6-III+',
+    '5'  => {
+        '0'     => 'K5/SSA5',
+        '1'     => 'K5',
+        '2'     => 'K5',
+        '3'     => 'K5',
+        '6'     => 'K6',
+        '7'     => 'K6',
+        '8'     => 'K6-2',
+        '9'     => 'K6-3',
+        '13'    => 'K6-2+ or K6-III+',
     },
-    6  => {
-        0     => "Athlon (25 �m)",
-        1     => "Athlon (25 �m)",
-        2     => "Athlon (18 �m)",
-        3     => 'Duron',
-        4     => 'Athlon (Thunderbird)',
-        6     => 'Athlon (Palamino)',
-        7     => 'Duron (Morgan)',
-        8     => 'Athlon (Thoroughbred)',
-        10    => 'Athlon (Barton)',
+    '6'  => {
+        '0'     => 'Athlon (25 �m)',
+        '1'     => 'Athlon (25 �m)',
+        '2'     => 'Athlon (18 �m)',
+        '3'     => 'Duron',
+        '4'     => 'Athlon (Thunderbird)',
+        '6'     => 'Athlon (Palamino)',
+        '7'     => 'Duron (Morgan)',
+        '8'     => 'Athlon (Thoroughbred)',
+        '10'    => 'Athlon (Barton)',
     },
-    15 => {
-        4     => 'Athlon 64',
-        5     => 'Athlon 64 FX Opteron',
+    '15' => {
+        '4'     => 'Athlon 64',
+        '5'     => 'Athlon 64 FX Opteron',
     },
 }
 
 sub _OTHER_ID {
     # Vendor          Manufacturer Name
+    return
     'CyrixInstead' => 'Cyrix',
     'CentaurHauls' => 'Centaur',
     'NexGenDriven' => 'NexGen',
 }
 
 sub _OTHER {
+    return
     Cyrix => {
     # Family Model Name
-        4 => {
-            4 => 'MediaGX',
+        '4' => {
+            '4' => 'MediaGX',
         },
-        5 => {
-            2 => '6x86 / 6x86L (Identifying the difference)',
-            4 => 'MediaGX MMX Enhanced',
+        '5' => {
+            '2' => '6x86 / 6x86L (Identifying the difference)',
+            '4' => 'MediaGX MMX Enhanced',
         },
-        6 => {
-            0 => 'm II (6x86MX)',
-            5 => 'VIA Cyrix M2 core',
-            6 => 'WinChip C5A',
-            7 => 'WinChip C5B ,WinChip C5C',
-            8 => 'WinChip C5N',
-            9 => 'WinChip C5XL, WinChip C5P',
+        '6' => {
+            '0' => 'm II (6x86MX)',
+            '5' => 'VIA Cyrix M2 core',
+            '6' => 'WinChip C5A',
+            '7' => 'WinChip C5B ,WinChip C5C',
+            '8' => 'WinChip C5N',
+            '9' => 'WinChip C5XL, WinChip C5P',
         },
     },
     UMC => {
-        4 => {
-            1 => 'U5D',
-            2 => 'U5S',
+        '4' => {
+            '1' => 'U5D',
+            '2' => 'U5S',
         },
     },
     Centaur => {
-        5 => {
-            4 => 'C6',
-            8 => 'C2',
-            9 => 'C3',
+        '5' => {
+            '4' => 'C6',
+            '8' => 'C2',
+            '9' => 'C3',
         },
     },
     'National Semiconductor' => {
-        5 => {
-            4 => 'GX1, GXLV, GXm',
-            5 => 'GX2',
+        '5' => {
+            '4' => 'GX1, GXLV, GXm',
+            '5' => 'GX2',
         },
     },
 
     NexGen => {
-        5 => {
-            0 => 'Nx586',
+        '5' => {
+            '0' => 'Nx586',
         },
     },
     Rise => {
-        5 => {
-            0 => 'mP6',
-            1 => 'mP6',
+        '5' => {
+            '0' => 'mP6',
+            '1' => 'mP6',
         },
     },
     SiS => {
-        5 => {
-            0 => '55x',
+        '5' => {
+            '0' => '55x',
         }
     },
     Transmeta => {
-        5 => {
-            4 => 'Crusoe TM3x00 and TM5x00',
+        '5' => {
+            '4' => 'Crusoe TM3x00 and TM5x00',
         },
     },
 }
 
 __END__
 
+=pod
+
 =head1 NAME
 
 Sys::Info::Driver::Unknown::Device::CPU::Env - Fetch CPU information from %ENV

File lib/Sys/Info/Driver/Unknown/OS.pm

 package Sys::Info::Driver::Unknown::OS;
 use strict;
+use warnings;
 use vars qw( $VERSION );
 use POSIX ();
 use Sys::Info::Constants qw( :unknown );
          ? $ENV{TZ}
          : do {
                require POSIX;
-               POSIX::strftime("%Z", localtime);
+               POSIX::strftime('%Z', localtime);
            };
 }
 
 }
 
 sub name {
-    my $self  = shift;
-    my %opt   = @_ % 2 ? () : (@_);
+    my($self, @args) = @_;
+    my %opt   = @args % 2 ? () : @args;
     my $uname = $self->uname;
-    my $rv    = $opt{long} ? join(' ', $uname->{sysname}, $uname->{release})
+    my $rv    = $opt{long} ? join(q{ }, $uname->{sysname}, $uname->{release})
               :              $uname->{sysname}
               ;
     return $rv;
 }
 
-sub version { shift->uname->{release} }
+sub version { return shift->uname->{release} }
 
 sub build {
     my $build = shift->uname->{version} || return;
-    return $build =~ UN_RE_BUILD ? $1 : $build;
+    if ( $build =~ UN_RE_BUILD ) {
+        return $1;
+    }
+    return $build;
 }
 
-sub node_name { shift->uname->{nodename} }
+sub node_name { return shift->uname->{nodename} }
 
 sub login_name {
     my $name;
-    eval { $name = getlogin() };
+    my $eok = eval { $name = getlogin };
     return $name;
 }
 

File t/03-basic.t

 #!/usr/bin/env perl -w
 use strict;
+use warnings;
 BEGIN { $^O = 'SomeFakeValue' }
 use Test::Sys::Info;