ソースを参照

scripts: Use none instead of ah-hoc checks

This simplifies the code, and fixes a false positive on perl critic
(ControlStructures::ProhibitUntilBlocks), due to the word "until"
appearing in the block.
Guillem Jover 11 年 前
コミット
0ccd2f60fc
共有2 個のファイルを変更した7 個の追加11 個の削除を含む
  1. 2 5
      scripts/Dpkg/Changelog/Parse.pm
  2. 5 6
      scripts/changelog/debian.pl

+ 2 - 5
scripts/Dpkg/Changelog/Parse.pm

@@ -43,6 +43,7 @@ our @EXPORT = qw(
 use Exporter qw(import);
 
 use Dpkg ();
+use Dpkg::Util qw(none);
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::Changelog::Debian;
@@ -77,11 +78,7 @@ sub changelog_parse_debian {
     $options{format} //= 'dpkg';
     $options{all} = 1 if exists $options{all};
 
-    unless (defined $options{since} or defined $options{until} or
-            defined $options{from} or defined $options{to} or
-            defined $options{offset} or defined $options{count} or
-            defined $options{all})
-    {
+    if (none { defined $options{$_} } qw(since until from to offset count all)) {
         $options{count} = 1;
     }
 

+ 5 - 6
scripts/changelog/debian.pl

@@ -25,6 +25,7 @@ use warnings;
 use Getopt::Long qw(:config posix_default bundling no_ignorecase);
 
 use Dpkg ();
+use Dpkg::Util qw(none);
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::Changelog::Debian;
@@ -117,18 +118,16 @@ if (@ARGV) {
 
 $file //= $default_file;
 $label //= $file;
-unless (defined($since) or defined($until) or defined($from) or
-        defined($to) or defined($offset) or defined($count) or
-        defined($all))
-{
-    $count = 1;
-}
+
 my %all = $all ? ( all => $all ) : ();
 my $range = {
     since => $since, until => $until, from => $from, to => $to,
     count => $count, offset => $offset,
     %all
 };
+if (none { defined $range->{$_} } qw(since until from to offset count all)) {
+    $range->{count} = 1;
+}
 
 my $changes = Dpkg::Changelog::Debian->new(reportfile => $label, range => $range);