Thu Oct 15 03:00:56 2015 UTC ()
Reverted part of 1.888 (perlcritic --stern)

The warning that "return undef" is bad must be taken with great care.
Although perlcritic explains it a lot and warns to think before simply
fixing it, it doesn't mention that in some cases a simple "return" means
"return '0'", which had happened here.


(rillig)
diff -r1.892 -r1.893 pkgsrc/pkgtools/pkglint/files/pkglint.pl

cvs diff -r1.892 -r1.893 pkgsrc/pkgtools/pkglint/files/Attic/pkglint.pl (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkglint/files/Attic/pkglint.pl 2015/10/15 02:09:49 1.892
+++ pkgsrc/pkgtools/pkglint/files/Attic/pkglint.pl 2015/10/15 03:00:56 1.893
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! @PERL@ 1#! @PERL@
2# $NetBSD: pkglint.pl,v 1.892 2015/10/15 02:09:49 rillig Exp $ 2# $NetBSD: pkglint.pl,v 1.893 2015/10/15 03:00:56 rillig Exp $
3# 3#
4 4
5# pkglint - static analyzer and checker for pkgsrc packages 5# pkglint - static analyzer and checker for pkgsrc packages
6# 6#
7# Written by: 7# Written by:
8# Roland Illig <rillig@NetBSD.org> 8# Roland Illig <rillig@NetBSD.org>
9# 9#
10# Based on work by: 10# Based on work by:
11# Hubert Feyrer <hubertf@NetBSD.org> 11# Hubert Feyrer <hubertf@NetBSD.org>
12# Thorsten Frueauf <frueauf@NetBSD.org> 12# Thorsten Frueauf <frueauf@NetBSD.org>
13# Thomas Klausner <wiz@NetBSD.org> 13# Thomas Klausner <wiz@NetBSD.org>
14# and others. 14# and others.
15# 15#
@@ -609,27 +609,27 @@ sub parse_acls($$) { @@ -609,27 +609,27 @@ sub parse_acls($$) {
609 "b" => qr"(?:^|/)buildlink3\.mk$", 609 "b" => qr"(?:^|/)buildlink3\.mk$",
610 "c" => qr"(?:^|/)Makefile\.common$", 610 "c" => qr"(?:^|/)Makefile\.common$",
611 "h" => qr"(?:^|/)hacks\.mk$", 611 "h" => qr"(?:^|/)hacks\.mk$",
612 "m" => qr"(?:^|/)Makefile$", 612 "m" => qr"(?:^|/)Makefile$",
613 "o" => qr"(?:^|/)options\.mk$", 613 "o" => qr"(?:^|/)options\.mk$",
614 }; 614 };
615 615
616 my $regex_acl_entry = qr"^(?: 616 my $regex_acl_entry = qr"^(?:
617 \$([\w_]+) # $acl_name 617 \$([\w_]+) # $acl_name
618 | ([\w.*]+|_):([adpsu]*) # file*mask:perms 618 | ([\w.*]+|_):([adpsu]*) # file*mask:perms
619 ) (?:\,\s*|$)"x; 619 ) (?:\,\s*|$)"x;
620 620
621 if (!defined($acltext)) { 621 if (!defined($acltext)) {
622 return; 622 return undef;
623 } 623 }
624 624
625 $acls = []; 625 $acls = [];
626 while ($acltext =~ s,$regex_acl_entry,,) { 626 while ($acltext =~ s,$regex_acl_entry,,) {
627 my ($acldef, $subject, $perms) = ($1, $2, $3); 627 my ($acldef, $subject, $perms) = ($1, $2, $3);
628 628
629 if (defined($acldef)) { 629 if (defined($acldef)) {
630 if (!exists($acl_definitions->{$acldef})) { 630 if (!exists($acl_definitions->{$acldef})) {
631 $line->log_fatal("ACL definition ${acldef} not found."); 631 $line->log_fatal("ACL definition ${acldef} not found.");
632 } else { 632 } else {
633 push(@{$acls}, @{$acl_definitions->{$acldef}}); 633 push(@{$acls}, @{$acl_definitions->{$acldef}});
634 } 634 }
635 635
@@ -1797,27 +1797,27 @@ sub get_variable_type($$) { @@ -1797,27 +1797,27 @@ sub get_variable_type($$) {
1797 : ($varname =~ m"_CMD$") ? PkgLint::Type->new(LK_NONE, "ShellCommand", allow_runtime, GUESSED) 1797 : ($varname =~ m"_CMD$") ? PkgLint::Type->new(LK_NONE, "ShellCommand", allow_runtime, GUESSED)
1798 : ($varname =~ m"_ARGS$") ? PkgLint::Type->new(LK_EXTERNAL, "ShellWord", allow_runtime, GUESSED) 1798 : ($varname =~ m"_ARGS$") ? PkgLint::Type->new(LK_EXTERNAL, "ShellWord", allow_runtime, GUESSED)
1799 : ($varname =~ m"_(?:C|CPP|CXX|LD|)FLAGS$") ? PkgLint::Type->new(LK_EXTERNAL, "ShellWord", allow_runtime, GUESSED) 1799 : ($varname =~ m"_(?:C|CPP|CXX|LD|)FLAGS$") ? PkgLint::Type->new(LK_EXTERNAL, "ShellWord", allow_runtime, GUESSED)
1800 : ($varname =~ m"_MK$") ? PkgLint::Type->new(LK_NONE, "Unchecked", allow_all, GUESSED) 1800 : ($varname =~ m"_MK$") ? PkgLint::Type->new(LK_NONE, "Unchecked", allow_all, GUESSED)
1801 : ($varname =~ m"^PLIST.") ? PkgLint::Type->new(LK_NONE, "Yes", allow_all, GUESSED) 1801 : ($varname =~ m"^PLIST.") ? PkgLint::Type->new(LK_NONE, "Yes", allow_all, GUESSED)
1802 : undef; 1802 : undef;
1803 1803
1804 if (defined($type)) { 1804 if (defined($type)) {
1805 $opt_debug_vartypes and $line->log_debug("The guessed type of ${varname} is \"" . $type->to_string . "\"."); 1805 $opt_debug_vartypes and $line->log_debug("The guessed type of ${varname} is \"" . $type->to_string . "\".");
1806 return $type; 1806 return $type;
1807 } 1807 }
1808 1808
1809 $opt_debug_vartypes and $line->log_debug("No type definition found for ${varcanon}."); 1809 $opt_debug_vartypes and $line->log_debug("No type definition found for ${varcanon}.");
1810 return; 1810 return undef;
1811} 1811}
1812 1812
1813sub get_variable_perms($$) { 1813sub get_variable_perms($$) {
1814 my ($line, $varname) = @_; 1814 my ($line, $varname) = @_;
1815 1815
1816 my $type = get_variable_type($line, $varname); 1816 my $type = get_variable_type($line, $varname);
1817 if (!defined($type)) { 1817 if (!defined($type)) {
1818 $opt_debug_misc and $line->log_debug("No type definition found for ${varname}."); 1818 $opt_debug_misc and $line->log_debug("No type definition found for ${varname}.");
1819 return "adpsu"; 1819 return "adpsu";
1820 } 1820 }
1821 1821
1822 my $perms = $type->perms($line->fname, $varname); 1822 my $perms = $type->perms($line->fname, $varname);
1823 if (!defined($perms)) { 1823 if (!defined($perms)) {