pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc/files lintpkgsrc: condense 'else' ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/3efebaef7774
branches:  trunk
changeset: 382505:3efebaef7774
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 30 06:25:51 2022 +0000

description:
lintpkgsrc: condense 'else' and 'elsif'

diffstat:

 pkgtools/lintpkgsrc/files/lintpkgsrc.pl |  174 ++++++++++---------------------
 1 files changed, 58 insertions(+), 116 deletions(-)

diffs (truncated from 477 to 300 lines):

diff -r 809f087165bc -r 3efebaef7774 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 06:21:17 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 06:25:51 2022 +0000
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.24 2022/07/30 06:21:17 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.25 2022/07/30 06:25:51 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -333,8 +333,7 @@
                                        while (<PKGINFO>) {
                                                if (/Required by:/) {
                                                        $list = 1;
-                                               }
-                                               elsif ($list) {
+                                               } elsif ($list) {
                                                        chomp;
                                                        s/-\d.*//;
                                                        print " $_";
@@ -384,8 +383,7 @@
                # Skip these subdirs if present
                $File::Find::prune = 1;
 
-       }
-       elsif (/(.+)-(\d.*)\.t[bg]z$/) {
+       } elsif (/(.+)-(\d.*)\.t[bg]z$/) {
                my ($pkg, $ver) = ($1, $2);
 
                $pkg = canonicalize_pkgname($pkg);
@@ -415,8 +413,7 @@
                        }
                }
 
-       }
-       elsif (-d $_) {
+       } elsif (-d $_) {
                if ($prebuilt_pkgdir_cache{"$File::Find::dir/$_"}) {
                        $File::Find::prune = 1;
                        return;
@@ -479,26 +476,19 @@
        foreach $elem (@_) {
                if ($elem =~ /\d+/) {
                        push(@temp, $elem);
-               }
-               elsif ($elem =~ /^pl$/ or $elem =~ /^\.$/) {
+               } elsif ($elem =~ /^pl$/ or $elem =~ /^\.$/) {
                        push(@temp, 0);
-               }
-               elsif ($elem =~ /^_$/) {
+               } elsif ($elem =~ /^_$/) {
                        push(@temp, 0);
-               }
-               elsif ($elem =~ /^pre$/) {
+               } elsif ($elem =~ /^pre$/) {
                        push(@temp, -1);
-               }
-               elsif ($elem =~ /^rc$/) {
+               } elsif ($elem =~ /^rc$/) {
                        push(@temp, -1);
-               }
-               elsif ($elem =~ /^beta$/) {
+               } elsif ($elem =~ /^beta$/) {
                        push(@temp, -2);
-               }
-               elsif ($elem =~ /^alpha$/) {
+               } elsif ($elem =~ /^alpha$/) {
                        push(@temp, -3);
-               }
-               else {
+               } else {
                        push(@temp, 0);
                        push(@temp, ord($elem) - ord("a") + 1);
                }
@@ -516,8 +506,7 @@
        $i = 0;
        if ($#matchlist > $#vallist) {
                $len = $#matchlist;
-       }
-       else {
+       } else {
                $len = $#vallist;
        }
        while (!$cmp && ($i++ <= $len)) {
@@ -569,8 +558,7 @@
 
        if ($opt{P}) {
                $default_vars->{PKGSRCDIR} = realpath($opt{P});
-       }
-       else {
+       } else {
                $default_vars->{PKGSRCDIR} = $conf_pkgsrcdir;
        }
 
@@ -583,8 +571,7 @@
                foreach my $var (keys %{$vars}) {
                        $default_vars->{$var} = $vars->{$var};
                }
-       }
-       elsif (-f ${conf_sysconfdir} . '/mk.conf' &&
+       } elsif (-f ${conf_sysconfdir} . '/mk.conf' &&
            ($vars = parse_makefile_vars(${conf_sysconfdir} . '/mk.conf'))) {
                foreach my $var (keys %{$vars}) {
                        $default_vars->{$var} = $vars->{$var};
@@ -597,8 +584,7 @@
 
        if ($opt{M}) {
                $default_vars->{DISTDIR} = realpath($opt{M});
-       }
-       else {
+       } else {
                $default_vars->{DISTDIR} ||= $default_vars->{PKGSRCDIR} . '/distfiles';
        }
 
@@ -637,8 +623,7 @@
                        foreach (split(',', $2)) {
                                push(@todo, "$1$_$3");
                        }
-               }
-               else {
+               } else {
                        push(@pkgmatches, $pkgmatch);
                }
        }
@@ -653,12 +638,10 @@
                                $fail .=
                                    "Version mismatch: '$pkg' $badver vs "
                                        . join(',', $pkgs->versions) . "\n";
-                       }
-                       else {
+                       } else {
                                $fail .= "Unknown package: '$pkg' version $badver\n";
                        }
-               }
-               else {
+               } else {
 
                        # If we find one match, don't bitch about others
                        $ok = 1;
@@ -681,8 +664,7 @@
        if (defined($dir)) {
                $thisdir .= "/$dir";
                $dir .= '/';
-       }
-       else {
+       } else {
                $dir = '';
        }
 
@@ -692,8 +674,7 @@
        foreach my $entry (@thislist) {
                if (-d "$thisdir/$entry") {
                        push(@list, listdir($base, "$dir$entry"));
-               }
-               else {
+               } else {
                        push(@list, "$dir$entry");
                }
        }
@@ -759,35 +740,27 @@
        while (defined($_ = shift @chars)) {
                if ($_ eq '*') {
                        $regex .= '.*';
-               }
-               elsif ($_ eq '?') {
+               } elsif ($_ eq '?') {
                        $regex .= '.';
-               }
-               elsif ($_ eq '+') {
+               } elsif ($_ eq '+') {
                        $regex .= '.';
-               }
-               elsif ($_ eq '\\+') {
+               } elsif ($_ eq '\\+') {
                        $regex .= $_ . shift @chars;
-               }
-               elsif ($_ eq '.' || $_ eq '|') {
+               } elsif ($_ eq '.' || $_ eq '|') {
                        $regex .= quotemeta;
-               }
-               elsif ($_ eq '{') {
+               } elsif ($_ eq '{') {
                        $regex .= '(';
                        ++$in_alt;
-               }
-               elsif ($_ eq '}') {
+               } elsif ($_ eq '}') {
                        if (!$in_alt) {
                                # Error
                                return undef;
                        }
                        $regex .= ')';
                        --$in_alt;
-               }
-               elsif ($_ eq ',' && $in_alt) {
+               } elsif ($_ eq ',' && $in_alt) {
                        $regex .= '|';
-               }
-               else {
+               } else {
                        $regex .= $_;
                }
        }
@@ -826,8 +799,7 @@
                                                $matchver = undef;
                                                last;
                                        }
-                               }
-                               else {
+                               } else {
                                        if (deweycmp($pkgver->ver, $test, $matchver)) {
                                                $matchver = undef;
                                                last;
@@ -840,8 +812,7 @@
                        }
                }
 
-       }
-       elsif ($pkgmatch =~ /^([^[]+)-([\d*?{[].*)$/) {
+       } elsif ($pkgmatch =~ /^([^[]+)-([\d*?{[].*)$/) {
 
                # (package)-(globver)
                my (@pkgnames);
@@ -851,8 +822,7 @@
                if (defined $pkglist->pkgs($matchpkgname)) {
                        push(@pkgnames, $matchpkgname);
 
-               }
-               elsif ($regex = glob2regex($matchpkgname)) {
+               } elsif ($regex = glob2regex($matchpkgname)) {
                        foreach my $pkg ($pkglist->pkgs) {
                                ($pkg->pkg() =~ /$regex/) && push(@pkgnames, $pkg->pkg());
                        }
@@ -892,8 +862,7 @@
                        }
                }
 
-       }
-       else {
+       } else {
                ($matchpkgname, $matchver) = ($pkgmatch, 'missing');
        }
 
@@ -916,8 +885,7 @@
 
        if (defined $vars->{PKGNAME}) {
                $pkgname = $vars->{PKGNAME};
-       }
-       elsif (defined $vars->{DISTNAME}) {
+       } elsif (defined $vars->{DISTNAME}) {
                $pkgname = $vars->{DISTNAME};
        }
 
@@ -937,8 +905,7 @@
                    "cd $pkgsrcdir || exit 1; ${conf_make} show-vars VARNAMES=PKGNAME");
                if (!$pid) {
                        warn "$file: Unable to run make: $!";
-               }
-               else {
+               } else {
                        close(WTR);
                        my @errors = <ERR>;
                        close(ERR);
@@ -965,12 +932,10 @@
                    and not $vars->{PKGREVISION} =~ /^\s*$/) {
                        if ($vars->{PKGREVISION} =~ /^\$\{(_(CVS|GIT|HG|SVN)_PKGVERSION):.*\}$/) {
                                # See wip/mk/*-package.mk.
-                       }
-                       elsif ($vars->{PKGREVISION} =~ /\D/) {
+                       } elsif ($vars->{PKGREVISION} =~ /\D/) {
                                print "\nBogus: PKGREVISION $vars->{PKGREVISION} (from $file)\n";
 
-                       }
-                       elsif ($vars->{PKGREVISION}) {
+                       } elsif ($vars->{PKGREVISION}) {
                                $pkgname .= "nb";
                                $pkgname .= $vars->{PKGREVISION};
                        }
@@ -979,8 +944,7 @@
                if ($pkgname =~ /\$/) {
                        print "\nBogus: $pkgname (from $file)\n";
 
-               }
-               elsif ($pkgname =~ /(.*)-(\d.*)/) {
+               } elsif ($pkgname =~ /(.*)-(\d.*)/) {
                        if ($pkglist) {
                                my ($pkgver) = $pkglist->add($1, $2);
 
@@ -996,20 +960,17 @@
 
                                if ($file =~ m:([^/]+/[^/]+)/Makefile$:) {
                                        $pkgver->var('dir', $1);
-                               }
-                               else {
+                               } else {
                                        $pkgver->var('dir', 'unknown');
                                }
                        }
-               }



Home | Main Index | Thread Index | Old Index