The following commit has been merged in the master branch:
commit 840d3d8836ca3712595ce45e17af9dd16818848d
Author: Guillem Jover <[email protected]>
Date:   Fri Jan 4 10:53:59 2013 +0100

    scripts: Do not use negative expression in unless and until conditions
    
    These are double negations which are hard to grasp at a first glance.
    
    Fixes 
ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions.

diff --git a/scripts/Dpkg/Compression.pm b/scripts/Dpkg/Compression.pm
index 28c7423..ae2af0b 100644
--- a/scripts/Dpkg/Compression.pm
+++ b/scripts/Dpkg/Compression.pm
@@ -201,7 +201,7 @@ sub compression_get_default_level {
 sub compression_set_default_level {
     my ($level) = @_;
     error(_g('%s is not a compression level'), $level)
-            unless !defined($level) or compression_is_valid_level($level);
+        if defined($level) and not compression_is_valid_level($level);
     $default_compression_level = $level;
 }
 
diff --git a/scripts/Dpkg/Source/Archive.pm b/scripts/Dpkg/Source/Archive.pm
index 4f24577..9dde065 100644
--- a/scripts/Dpkg/Source/Archive.pm
+++ b/scripts/Dpkg/Source/Archive.pm
@@ -79,7 +79,8 @@ sub add_directory {
     if (*$self->{chdir}) {
         $testfile = File::Spec->catdir(*$self->{chdir}, $file);
     }
-    internerr('add_directory() only handles directories') unless not -l 
$testfile and -d _;
+    internerr('add_directory() only handles directories')
+        if -l $testfile or not -d _;
     $self->_add_entry($file);
 }
 
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index ddecbdb..3b1f8ff 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -399,7 +399,7 @@ unless (build_binaryonly) {
     chdir($dir) or syserr("chdir $dir");
 }
 
-unless ($buildtarget eq 'build' or scalar(@debian_rules) > 1) {
+if ($buildtarget ne 'build' and scalar(@debian_rules) == 1) {
     # Verify that build-{arch,indep} are supported. If not, fallback to build.
     # This is a temporary measure to not break too many packages on a flag day.
     my $pid = spawn(exec => [ 'make', '-f', @debian_rules, '-qn', $buildtarget 
],
diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl
index 13e685c..d8a2ee9 100755
--- a/scripts/dpkg-genchanges.pl
+++ b/scripts/dpkg-genchanges.pl
@@ -245,13 +245,13 @@ if (not is_sourceonly) {
                        $1, $.);
            $f2sec{$1}= $5;
            $f2pri{$1}= $6;
-           push(@archvalues,$4) unless !$4 || $archadded{$4}++;
+           push(@archvalues, $4) if $4 and not $archadded{$4}++;
            push(@fileslistfiles,$1);
        } elsif (m/^([-+.0-9a-z]+_[^_]+_([-\w]+)\.[a-z0-9.]+) (\S+) (\S+)$/) {
            # A non-deb package
            $f2sec{$1}= $3;
            $f2pri{$1}= $4;
-           push(@archvalues,$2) unless !$2 || $archadded{$2}++;
+           push(@archvalues, $2) if $2 and not $archadded{$2}++;
            push(@fileslistfiles,$1);
        } elsif (m/^([-+.,_0-9a-zA-Z]+) (\S+) (\S+)$/) {
            defined($f2sec{$1}) &&
@@ -324,7 +324,7 @@ foreach my $pkg ($control->get_packages()) {
            } elsif (!debarch_eq('all', $v)) {
                $v = '';
            }
-           push(@archvalues,$v) unless !$v || $archadded{$v}++;
+           push(@archvalues, $v) if $v and not $archadded{$v}++;
         } elsif (m/^Description$/) {
             # Description in changes is computed, do not copy this field
        } else {
diff --git a/test/100_critic.t b/test/100_critic.t
index bd98c5c..e2b15a5 100644
--- a/test/100_critic.t
+++ b/test/100_critic.t
@@ -50,6 +50,7 @@ my @policies = qw(
     CodeLayout::RequireConsistentNewlines
     ControlStructures::ProhibitCStyleForLoops
     ControlStructures::ProhibitLabelsWithSpecialBlockNames
+    ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions
     ControlStructures::ProhibitUntilBlocks
     Documentation::RequirePackageMatchesPodName
     InputOutput::ProhibitBarewordFileHandles

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to