Przeglądaj źródła

scripts: Do not modify the topic variable values in list functions

Fixes ControlStructures::ProhibitMutatingListFunctions.

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

+ 1 - 0
debian/changelog

@@ -33,6 +33,7 @@ dpkg (1.17.17) UNRELEASED; urgency=low
     dpkg-architecture. This restores the ability to specify the target
     architecture when building cross-compilers. Regression introduced in
     dpkg 1.17.14. Reported by Helmut Grohne <helmut@subdivi.de>.
+  * Do not modify the topic variable values in list functions in perl code.
 
   [ Updated programs translations ]
   * German (Sven Joachim).

+ 2 - 1
scripts/Dpkg/Source/Package/V1.pm

@@ -375,7 +375,8 @@ sub do_build {
         pop_exit_handler();
 
 	my $analysis = $diff->analyze($origdir);
-	my @files = grep { ! m{^debian/} } map { s{^[^/]+/+}{}; $_ }
+	my @files = grep { ! m{^debian/} }
+		    map { my $file = $_; $file =~ s{^[^/]+/+}{}; $file }
 		    sort keys %{$analysis->{filepatched}};
 	if (scalar @files) {
 	    warning(_g('the diff modifies the following upstream files: %s'),

+ 6 - 5
scripts/dpkg-shlibdeps.pl

@@ -511,13 +511,14 @@ foreach my $field (reverse @depfields) {
 	$dep = join ', ',
 	    map {
 		# Translate dependency templates into real dependencies
-		if ($dependencies{$field}{$_}) {
-		    s/#MINVER#/(>= $dependencies{$field}{$_})/g;
+		my $templ = $_;
+		if ($dependencies{$field}{$templ}) {
+		    $templ =~ s/#MINVER#/(>= $dependencies{$field}{$templ})/g;
 		} else {
-		    s/#MINVER#//g;
+		    $templ =~ s/#MINVER#//g;
 		}
-		s/\s+/ /g;
-		$_;
+		$templ =~ s/\s+/ /g;
+		$templ;
 	    } grep { filter_deps($_, $field) }
 	    keys %{$dependencies{$field}};
     }

+ 1 - 0
test/critic.t

@@ -57,6 +57,7 @@ my @policies = qw(
     CodeLayout::RequireConsistentNewlines
     ControlStructures::ProhibitCStyleForLoops
     ControlStructures::ProhibitLabelsWithSpecialBlockNames
+    ControlStructures::ProhibitMutatingListFunctions
     ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions
     ControlStructures::ProhibitUntilBlocks
     Documentation::RequirePackageMatchesPodName

+ 3 - 0
test/critic/perlcriticrc

@@ -3,6 +3,9 @@ severity = 1
 verbose = %f %l:%c (Severity: %s)\n  %P (%s)\n  near '%r'\n%d\n
 program-extensions = .pl .t
 
+[ControlStructures::ProhibitMutatingListFunctions]
+add_list_funcs = Dpkg::Util::any Dpkg::Util::none
+
 [RegularExpressions::ProhibitUnusualDelimiters]
 allow_all_brackets = 1