瀏覽代碼

scripts: Do not mix boolean operators

Fixes ValuesAndExpressions::ProhibitMixedBooleanOperators.
Guillem Jover 13 年之前
父節點
當前提交
89a8da04a9

+ 2 - 2
scripts/Dpkg/IPC.pm

@@ -151,14 +151,14 @@ sub _sanity_check_opts {
 
     foreach (qw(to_string error_to_string from_string)) {
 	if (exists $opts{$_} and
-	    (!ref($opts{$_}) or ref($opts{$_}) ne 'SCALAR')) {
+	    (not ref($opts{$_}) or ref($opts{$_}) ne 'SCALAR')) {
 	    internerr("parameter $_ must be a scalar reference");
 	}
     }
 
     foreach (qw(to_pipe error_to_pipe from_pipe)) {
 	if (exists $opts{$_} and
-	    (!ref($opts{$_}) or (ref($opts{$_}) ne 'SCALAR' and
+	    (not ref($opts{$_}) or (ref($opts{$_}) ne 'SCALAR' and
 				 not $opts{$_}->isa('IO::Handle')))) {
 	    internerr("parameter $_ must be a scalar reference or an IO::Handle object");
 	}

+ 3 - 3
scripts/Dpkg/Source/Patch.pm

@@ -384,7 +384,7 @@ sub analyze {
     $_ = _getline($self);
 
   HUNK:
-    while (defined($_) || not eof($self)) {
+    while (defined($_) or not eof($self)) {
 	my (%path, %fn);
 	# skip comments leading up to patch (if any)
 	while (1) {
@@ -451,7 +451,7 @@ sub analyze {
 	my $fn = _intuit_file_patched($fn{old}, $fn{new});
 
 	my $dirname = $fn;
-	if ($dirname =~ s{/[^/]+$}{} && not -d $dirname) {
+	if ($dirname =~ s{/[^/]+$}{} and not -d $dirname) {
 	    $dirtocreate{$dirname} = 1;
 	}
 
@@ -561,7 +561,7 @@ sub apply {
     # and remove .dpkg-orig files
     my @files = keys %{$analysis->{filepatched}};
     my $now = $opts{timestamp};
-    $now ||= fs_time($files[0]) if $opts{force_timestamp} and scalar @files;
+    $now ||= fs_time($files[0]) if $opts{force_timestamp} && scalar @files;
     foreach my $fn (@files) {
 	if ($opts{force_timestamp}) {
 	    utime($now, $now, $fn) || $! == ENOENT ||

+ 1 - 1
scripts/dpkg-genchanges.pl

@@ -424,7 +424,7 @@ if (!is_binaryonly) {
     }
 
     my $ext = $compression_re_file_ext;
-    if ((($sourcestyle =~ m/i/ && not($include_tarball)) ||
+    if ((($sourcestyle =~ m/i/ && !$include_tarball) ||
 	 $sourcestyle =~ m/d/) &&
 	grep(m/\.(debian\.tar|diff)\.$ext$/, $checksums->get_files()))
     {

+ 2 - 2
scripts/dpkg-name.pl

@@ -106,7 +106,7 @@ sub getarch($$)
     my ($filename, $fields) = @_;
 
     my $arch = $fields->{Architecture};
-    if (!$fields->{Architecture} and $options{architecture}) {
+    if (not $fields->{Architecture} and $options{architecture}) {
         $arch = get_host_arch();
         warning(_g("assuming architecture '%s' for '%s'"), $arch, $filename);
     }
@@ -205,7 +205,7 @@ sub move($)
 
         if (filesame($newname, $filename)) {
             warning(_g("skipping '%s'"), $filename);
-        } elsif (-f $newname and !$options{overwrite}) {
+        } elsif (-f $newname and not $options{overwrite}) {
             warning(_g("cannot move '%s' to existing file"), $filename);
         } elsif (system(@command, $filename, $newname) == 0) {
             info(_g("moved '%s' to '%s'"), basename($filename), $newname);

+ 1 - 1
scripts/dpkg-scanpackages.pl

@@ -156,7 +156,7 @@ sub load_override_extra
     GetOptions(\%options, @options_spec);
 }
 
-if (not @ARGV >= 1 && @ARGV <= 3) {
+if (not (@ARGV >= 1 and @ARGV <= 3)) {
     usageerr(_g('one to three arguments expected'));
 }
 

+ 1 - 1
scripts/dpkg-scansources.pl

@@ -300,7 +300,7 @@ sub main {
         local $SIG{__WARN__} = sub { usageerr($_[0]) };
         GetOptions(@option_spec);
     }
-    @ARGV >= 1 && @ARGV <= 3 or usageerr(_g('one to three arguments expected'));
+    @ARGV >= 1 and @ARGV <= 3 or usageerr(_g('one to three arguments expected'));
 
     push @ARGV, undef		if @ARGV < 2;
     push @ARGV, ''		if @ARGV < 3;

+ 1 - 1
scripts/dpkg-shlibdeps.pl

@@ -358,7 +358,7 @@ foreach my $file (keys %exec) {
 		    $print_name =~ s/\@Base$//;
 		    unless ($sym->{weak}) {
 			if ($debug or ($in_public_dir and $nb_warnings < 10)
-                            or (!$in_public_dir and $nb_warnings < 1))
+                            or (not $in_public_dir and $nb_warnings < 1))
                         {
                             if ($in_public_dir) {
 			        warning(_g('symbol %s used by %s found in none of the ' .

+ 1 - 0
test/100_critic.t

@@ -85,6 +85,7 @@ my @policies = qw(
     ValuesAndExpressions::ProhibitInterpolationOfLiterals
     ValuesAndExpressions::ProhibitLongChainsOfMethodCalls
     ValuesAndExpressions::ProhibitMismatchedOperators
+    ValuesAndExpressions::ProhibitMixedBooleanOperators
     ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters
     ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator
     ValuesAndExpressions::ProhibitVersionStrings