Просмотр исходного кода

Dpkg::Source::Package: Use a simple string match instead of a regex

Addresses RegularExpressions::ProhibitFixedStringMatches.

Warned-by: perlcritic
Guillem Jover лет назад: 12
Родитель
Сommit
13ae3fa02e

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

@@ -71,13 +71,13 @@ sub parse_cmdline_option {
         $o->{sourcestyle} = $1;
         $o->{copy_orig_tarballs} = 0 if $1 eq 'n'; # Extract option -sn
         return 1;
-    } elsif ($opt =~ m/^--skip-debianization$/) {
+    } elsif ($opt eq '--skip-debianization') {
         $o->{skip_debianization} = 1;
         return 1;
-    } elsif ($opt =~ m/^--ignore-bad-version$/) {
+    } elsif ($opt eq '--ignore-bad-version') {
         $o->{ignore_bad_version} = 1;
         return 1;
-    } elsif ($opt =~ m/^--abort-on-upstream-changes$/) {
+    } elsif ($opt eq '--abort-on-upstream-changes') {
         $o->{abort_on_upstream_changes} = 1;
         return 1;
     }

+ 12 - 12
scripts/Dpkg/Source/Package/V2.pm

@@ -66,40 +66,40 @@ sub init_options {
 
 sub parse_cmdline_option {
     my ($self, $opt) = @_;
-    if ($opt =~ /^--include-removal$/) {
+    if ($opt eq '--include-removal') {
         $self->{options}{include_removal} = 1;
         return 1;
-    } elsif ($opt =~ /^--include-timestamp$/) {
+    } elsif ($opt eq '--include-timestamp') {
         $self->{options}{include_timestamp} = 1;
         return 1;
-    } elsif ($opt =~ /^--include-binaries$/) {
+    } elsif ($opt eq '--include-binaries') {
         $self->{options}{include_binaries} = 1;
         return 1;
-    } elsif ($opt =~ /^--no-preparation$/) {
+    } elsif ($opt eq '--no-preparation') {
         $self->{options}{preparation} = 0;
         return 1;
-    } elsif ($opt =~ /^--skip-patches$/) {
+    } elsif ($opt eq '--skip-patches') {
         $self->{options}{skip_patches} = 1;
         return 1;
-    } elsif ($opt =~ /^--unapply-patches$/) {
+    } elsif ($opt eq '--unapply-patches') {
         $self->{options}{unapply_patches} = 'yes';
         return 1;
-    } elsif ($opt =~ /^--no-unapply-patches$/) {
+    } elsif ($opt eq '--no-unapply-patches') {
         $self->{options}{unapply_patches} = 'no';
         return 1;
-    } elsif ($opt =~ /^--skip-debianization$/) {
+    } elsif ($opt eq '--skip-debianization') {
         $self->{options}{skip_debianization} = 1;
         return 1;
-    } elsif ($opt =~ /^--create-empty-orig$/) {
+    } elsif ($opt eq '--create-empty-orig') {
         $self->{options}{create_empty_orig} = 1;
         return 1;
-    } elsif ($opt =~ /^--abort-on-upstream-changes$/) {
+    } elsif ($opt eq '--abort-on-upstream-changes') {
         $self->{options}{auto_commit} = 0;
         return 1;
-    } elsif ($opt =~ /^--auto-commit$/) {
+    } elsif ($opt eq '--auto-commit') {
         $self->{options}{auto_commit} = 1;
         return 1;
-    } elsif ($opt =~ /^--ignore-bad-version$/) {
+    } elsif ($opt eq '--ignore-bad-version') {
         $self->{options}{ignore_bad_version} = 1;
         return 1;
     }

+ 2 - 2
scripts/Dpkg/Source/Package/V3/Quilt.pm

@@ -49,7 +49,7 @@ sub init_options {
 sub parse_cmdline_option {
     my ($self, $opt) = @_;
     return 1 if $self->SUPER::parse_cmdline_option($opt);
-    if ($opt =~ /^--single-debian-patch$/) {
+    if ($opt eq '--single-debian-patch') {
         $self->{options}{single_debian_patch} = 1;
         # For backwards compatibility.
         $self->{options}{auto_commit} = 1;
@@ -167,7 +167,7 @@ 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] =~ m{^debian/patches/series$} and -l $_[0];
+        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}/;
         return 0;