Przeglądaj źródła

scripts: Unpack arguments instead of accessing @_ directly

Addresses Subroutines::RequireArgUnpacking.

Warned-by: perlcritic
Guillem Jover 11 lat temu
rodzic
commit
4502f420bd

+ 3 - 1
scripts/Dpkg/Compression.pm

@@ -106,7 +106,9 @@ known and supported.
 =cut
 
 sub compression_is_supported {
-    return exists $COMP->{$_[0]};
+    my $comp = shift;
+
+    return exists $COMP->{$comp};
 }
 
 =item compression_get_property($comp, $property)

+ 6 - 3
scripts/Dpkg/Control/FieldsCore.pm

@@ -428,7 +428,9 @@ Returns true if the field is official and known.
 =cut
 
 sub field_is_official($) {
-    return exists $FIELDS{field_capitalize($_[0])};
+    my $field = field_capitalize(shift);
+
+    return exists $FIELDS{$field};
 }
 
 =item field_is_allowed_in($fname, @types)
@@ -589,7 +591,8 @@ Breaks, ...). Returns undef for fields which are not dependencies.
 =cut
 
 sub field_get_dep_type($) {
-    my $field = field_capitalize($_[0]);
+    my $field = field_capitalize(shift);
+
     return unless field_is_official($field);
     return $FIELDS{$field}{dependency} if exists $FIELDS{$field}{dependency};
     return;
@@ -603,7 +606,7 @@ FIELD_SEP_SPACE, FIELD_SEP_COMMA or FIELD_SEP_LINE.
 =cut
 
 sub field_get_sep_type($) {
-    my $field = field_capitalize($_[0]);
+    my $field = field_capitalize(shift);
 
     return $FIELDS{$field}{separator} if exists $FIELDS{$field}{separator};
     return FIELD_SEP_UNKNOWN;

+ 4 - 3
scripts/Dpkg/Gettext.pm

@@ -38,10 +38,11 @@ BEGIN {
             sub textdomain {
             }
             sub ngettext {
-                if ($_[2] == 1) {
-                    return $_[0];
+                my ($msgid, $msgid_plural, $n) = @_;
+                if ($n == 1) {
+                    return $msgid;
                 } else {
-                    return $_[1];
+                    return $msgid_plural;
                 }
             }
             sub P_ {

+ 21 - 7
scripts/Dpkg/Shlibs/Symbol.pm

@@ -185,11 +185,15 @@ sub initialize {
 }
 
 sub get_symbolname {
-    return $_[0]->{symbol};
+    my $self = shift;
+
+    return $self->{symbol};
 }
 
 sub get_symboltempl {
-    return $_[0]->{symbol_templ} || $_[0]->{symbol};
+    my $self = shift;
+
+    return $self->{symbol_templ} || $self->{symbol};
 }
 
 sub set_symbolname {
@@ -307,7 +311,9 @@ sub arch_is_concerned {
 
 # Get reference to the pattern the symbol matches (if any)
 sub get_pattern {
-    return $_[0]->{matching_pattern};
+    my $self = shift;
+
+    return $self->{matching_pattern};
 }
 
 ### NOTE: subroutines below require (or initialize) $self to be a pattern ###
@@ -323,23 +329,31 @@ sub init_pattern {
 
 # Is this symbol a pattern or not?
 sub is_pattern {
-    return exists $_[0]->{pattern};
+    my $self = shift;
+
+    return exists $self->{pattern};
 }
 
 # Get pattern type if this symbol is a pattern.
 sub get_pattern_type {
-    return $_[0]->{pattern}{type} // '';
+    my $self = shift;
+
+    return $self->{pattern}{type} // '';
 }
 
 # Get (sub)type of the alias pattern. Returns empty string if current
 # pattern is not alias.
 sub get_alias_type {
-    return ($_[0]->get_pattern_type() =~ /^alias-(.+)/ && $1) || '';
+    my $self = shift;
+
+    return ($self->get_pattern_type() =~ /^alias-(.+)/ && $1) || '';
 }
 
 # Get a list of symbols matching this pattern if this symbol is a pattern
 sub get_pattern_matches {
-    return @{$_[0]->{pattern}{matches}};
+    my $self = shift;
+
+    return @{$self->{pattern}{matches}};
 }
 
 # Create a new symbol based on the pattern (i.e. $self)

+ 2 - 3
scripts/Dpkg/Source/Package.pm

@@ -457,8 +457,7 @@ that if $targetdir already exists, it will be erased.
 =cut
 
 sub extract {
-    my $self = shift;
-    my $newdirectory = $_[0];
+    my ($self, $newdirectory) = @_;
 
     my ($ok, $error) = version_check($self->{fields}{'Version'});
     if (not $ok) {
@@ -488,7 +487,7 @@ sub extract {
     }
 
     # Try extract
-    eval { $self->do_extract(@_) };
+    eval { $self->do_extract($newdirectory) };
     if ($@) {
         run_exit_handlers();
         die $@;

+ 5 - 3
scripts/Dpkg/Source/Package/V3/Quilt.pm

@@ -167,9 +167,11 @@ sub prepare_build {
     # on debian/patches/series symlinks and d/p/.dpkg-source-applied
     # stamp file created by ourselves
     my $func = sub {
-        return 1 if $_[0] eq 'debian/patches/series' and -l $_[0];
-        return 1 if $_[0] =~ /^\.pc(\/|$)/;
-        return 1 if $_[0] =~ /$self->{options}{diff_ignore_regex}/;
+        my $pathname = shift;
+
+        return 1 if $pathname eq 'debian/patches/series' and -l $pathname;
+        return 1 if $pathname =~ /^\.pc(\/|$)/;
+        return 1 if $pathname =~ /$self->{options}{diff_ignore_regex}/;
         return 0;
     };
     $self->{diff_options}{diff_ignore_func} = $func;

+ 3 - 1
scripts/Dpkg/Version.pm

@@ -379,7 +379,9 @@ return ("1", ".", "024", "~beta", "1", "+svn", "234").
 =cut
 
 sub version_split_digits($) {
-    return split(/(?<=\d)(?=\D)|(?<=\D)(?=\d)/, $_[0]);
+    my $version = shift;
+
+    return split /(?<=\d)(?=\D)|(?<=\D)(?=\d)/, $version;
 }
 
 =item my ($ok, $msg) = version_check($version)

+ 4 - 2
scripts/dpkg-mergechangelogs.pl

@@ -110,7 +110,8 @@ my @result; # Lines to output
 my $exitcode = 0; # 1 if conflict encountered
 
 unless (merge_block($cho, $cha, $chb, sub {
-			my $tail = $_[0]->get_unparsed_tail();
+			my $changes = shift;
+			my $tail = $changes->get_unparsed_tail();
 			chomp $tail if defined $tail;
 			return $tail;
 		    }))
@@ -214,8 +215,9 @@ sub merge_entries($$$) {
 		       $a->get_part('changes'), $b->get_part('changes'),
 		       {
 			   CONFLICT => sub {
+				my ($ca, $cb) = @_;
 				$exitcode = 1;
-				return get_conflict_block($_[0], $_[1]);
+				return get_conflict_block($ca, $cb);
 			   }
 		       });
     unshift @result, @merged;

+ 3 - 1
scripts/dpkg-source.pl

@@ -508,10 +508,12 @@ sub set_testsuite_field
 }
 
 sub setopmode {
+    my $opmode = shift;
+
     if (defined($options{opmode})) {
 	usageerr(_g('only one of -x, -b or --print-format allowed, and only once'));
     }
-    $options{opmode} = $_[0];
+    $options{opmode} = $opmode;
 }
 
 sub version {