瀏覽代碼

dpkg-genchanges: Do not use conditional declarations

These are quite confusing, instead just rearrange the code so that we
only declare it if we are going to need the variable.

Fixes Variables::ProhibitConditionalDeclarations.

Warned-by: perlcritic
Guillem Jover 13 年之前
父節點
當前提交
b2a6feea95
共有 2 個文件被更改,包括 6 次插入3 次删除
  1. 5 3
      scripts/dpkg-genchanges.pl
  2. 1 0
      test/100_critic.t

+ 5 - 3
scripts/dpkg-genchanges.pl

@@ -473,10 +473,12 @@ $fields->{'Files'} = '';
 my %filedone;
 
 for my $f ($checksums->get_files(), @fileslistfiles) {
-    my $arch_all = debarch_eq('all', $p2arch{$f2p{$f}}) if defined($f2p{$f});
+    if (defined $f2p{$f}) {
+        my $arch_all = debarch_eq('all', $p2arch{$f2p{$f}});
 
-    next if (defined($arch_all) && ($include == ARCH_DEP and $arch_all));
-    next if (defined($arch_all) && ($include == ARCH_INDEP and not $arch_all));
+        next if ($include == ARCH_DEP and $arch_all);
+        next if ($include == ARCH_INDEP and not $arch_all);
+    }
     next if $filedone{$f}++;
     my $uf = "$uploadfilesdir/$f";
     $checksums->add_from_file($uf, key => $f);

+ 1 - 0
test/100_critic.t

@@ -88,6 +88,7 @@ my @policies = qw(
     ValuesAndExpressions::RequireQuotedHeredocTerminator
     ValuesAndExpressions::RequireUpperCaseHeredocTerminator
     Variables::ProhibitAugmentedAssignmentInDeclaration
+    Variables::ProhibitConditionalDeclarations
     Variables::ProhibitPerl4PackageNames
     Variables::ProhibitUnusedVariables
     Variables::ProtectPrivateVars