summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig>2015-10-11 21:06:20 +0000
committerrillig <rillig>2015-10-11 21:06:20 +0000
commit144a54f45a58e7a53018919a6cce1b40d1cc469b (patch)
treecb62719de9eeee6e55cb870384a0e32c4dfb54ca /pkgtools
parent47e95cb872b5fd391914ccba4c725d984a135751 (diff)
downloadpkgsrc-144a54f45a58e7a53018919a6cce1b40d1cc469b.tar.gz
Fixed errors reported by perlcritic in --gentle mode
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/files/PkgLint/CVS_Entry.pm12
-rw-r--r--pkgtools/pkglint/files/PkgLint/Change.pm12
-rw-r--r--pkgtools/pkglint/files/PkgLint/FileUtil.pm29
-rw-r--r--pkgtools/pkglint/files/PkgLint/Line.pm11
-rw-r--r--pkgtools/pkglint/files/PkgLint/Logging.pm16
-rw-r--r--pkgtools/pkglint/files/PkgLint/Patches.pm4
-rw-r--r--pkgtools/pkglint/files/PkgLint/SimpleMatch.pm9
-rw-r--r--pkgtools/pkglint/files/PkgLint/SubstContext.pm12
-rw-r--r--pkgtools/pkglint/files/PkgLint/Type.pm15
-rw-r--r--pkgtools/pkglint/files/PkgLint/Util.pm13
-rw-r--r--pkgtools/pkglint/files/PkgLint/VarUseContext.pm15
-rw-r--r--pkgtools/pkglint/files/pkglint.pl38
12 files changed, 91 insertions, 95 deletions
diff --git a/pkgtools/pkglint/files/PkgLint/CVS_Entry.pm b/pkgtools/pkglint/files/PkgLint/CVS_Entry.pm
index 8feb414951f..ce84cbdc27b 100644
--- a/pkgtools/pkglint/files/PkgLint/CVS_Entry.pm
+++ b/pkgtools/pkglint/files/PkgLint/CVS_Entry.pm
@@ -1,7 +1,10 @@
+# $NetBSD: CVS_Entry.pm,v 1.2 2015/10/11 21:06:20 rillig Exp $
+#
+# One line from a CVS/Entries file.
+#
package PkgLint::CVS_Entry;
-#==========================================================================
-# A CVS_Entry represents one line from a CVS/Entries file.
-#==========================================================================
+
+use strict;
use enum qw(FNAME REVISION MTIME TAG);
@@ -15,6 +18,3 @@ sub fname($) { return shift()->[FNAME]; }
sub revision($) { return shift()->[REVISION]; }
sub mtime($) { return shift()->[MTIME]; }
sub tag($) { return shift()->[TAG]; }
-#== End of PkgLint::CVS_Entry =============================================
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/Change.pm b/pkgtools/pkglint/files/PkgLint/Change.pm
index b68c5286d73..ef029e91c75 100644
--- a/pkgtools/pkglint/files/PkgLint/Change.pm
+++ b/pkgtools/pkglint/files/PkgLint/Change.pm
@@ -1,7 +1,10 @@
-package PkgLint::Change;
-#==========================================================================
+# $NetBSD: Change.pm,v 1.2 2015/10/11 21:06:20 rillig Exp $
+#
# A change entry from doc/CHANGES-*
-#==========================================================================
+#
+package PkgLint::Change;
+
+use strict;
sub new($$$$$$) {
my ($class, $line, $action, $pkgpath, $version, $author, $date) = @_;
@@ -15,6 +18,3 @@ sub pkgpath($) { return shift()->[2]; }
sub version($) { return shift()->[3]; }
sub author($) { return shift()->[4]; }
sub date($) { return shift()->[5]; }
-#== End of PkgLint::Change ================================================
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/FileUtil.pm b/pkgtools/pkglint/files/PkgLint/FileUtil.pm
index 399bfe2356c..b70ec610187 100644
--- a/pkgtools/pkglint/files/PkgLint/FileUtil.pm
+++ b/pkgtools/pkglint/files/PkgLint/FileUtil.pm
@@ -1,13 +1,15 @@
-package PkgLint::FileUtil;
-#==========================================================================
-# This package provides subroutines for loading and saving line-oriented
-# files. The load_file() subroutine loads a file completely into memory,
+# $NetBSD: FileUtil.pm,v 1.3 2015/10/11 21:06:20 rillig Exp $
+#
+# Subroutines for loading and saving line-oriented files.
+# The load_file() subroutine loads a file completely into memory,
# optionally handling continuation line folding. The load_lines() subrou-
# tine is an abbreviation for the common case of loading files without
# continuation lines. The save_autofix_changes() subroutine examines an
# array of lines if some of them have changed. It then saves the modified
# files.
-#==========================================================================
+#
+package PkgLint::FileUtil;
+
use strict;
use warnings;
@@ -34,13 +36,13 @@ sub load_physical_lines($) {
my ($physlines, $line, $lineno);
$physlines = [];
- open(F, "<", $fname) or return undef;
+ open(my $f, "<", $fname) or return;
$lineno = 0;
- while (defined($line = <F>)) {
+ while (defined($line = <$f>)) {
$lineno++;
push(@{$physlines}, [$lineno, $line]);
}
- close(F) or return undef;
+ close($f) or return;
return $physlines;
}
@@ -141,15 +143,16 @@ sub save_autofix_changes($) {
foreach my $fname (sort(keys(%changed))) {
my $new = "${fname}.pkglint.tmp";
+ my $f;
- if (!open(F, ">", $new)) {
+ if (!open($f, ">", $new)) {
log_error($new, NO_LINE_NUMBER, "$!");
next;
}
foreach my $physline (@{$physlines{$fname}}) {
- print F ($physline->[1]);
+ print $f ($physline->[1]);
}
- if (!close(F)) {
+ if (!close($f)) {
log_error($new, NO_LINE_NUMBER, "$!");
next;
}
@@ -161,7 +164,3 @@ sub save_autofix_changes($) {
log_note($fname, NO_LINE_NUMBER, "Has been autofixed. Please re-run pkglint.");
}
}
-
-#== End of PkgLint::FileUtil ==============================================
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/Line.pm b/pkgtools/pkglint/files/PkgLint/Line.pm
index 6f22821e954..bd4e6cb427b 100644
--- a/pkgtools/pkglint/files/PkgLint/Line.pm
+++ b/pkgtools/pkglint/files/PkgLint/Line.pm
@@ -1,4 +1,5 @@
-#==========================================================================
+# $NetBSD: Line.pm,v 1.4 2015/10/11 21:06:20 rillig Exp $
+#
# When files are read in by pkglint, they are interpreted in terms of
# lines. For Makefiles, line continuations are handled properly, allowing
# multiple physical lines to end in a single logical line. For other files
@@ -18,9 +19,11 @@
#
# A line can have some "extra" fields that allow the results of parsing to
# be saved under a name.
-#==========================================================================
+#
package PkgLint::Line;
+use strict;
+
BEGIN {
import PkgLint::Util qw(
false true
@@ -211,7 +214,3 @@ sub set_text($$) {
$self->[PHYSLINES] = [[0, "$text\n"]];
$self->[CHANGED] = true;
}
-
-#== End of PkgLint::Line ==================================================
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/Logging.pm b/pkgtools/pkglint/files/PkgLint/Logging.pm
index 4e84c61d114..51c9dfaa199 100644
--- a/pkgtools/pkglint/files/PkgLint/Logging.pm
+++ b/pkgtools/pkglint/files/PkgLint/Logging.pm
@@ -1,7 +1,7 @@
-package PkgLint::Logging;
-#==========================================================================
-# This package provides subroutines for printing messages to the user in a
-# common format. The subroutines all have the parameters C<$fname>,
+# $NetBSD: Logging.pm,v 1.2 2015/10/11 21:06:20 rillig Exp $
+#
+# Subroutines for printing messages to the user in a common format.
+# The subroutines all have the parameters C<$fname>,
# C<$lineno> and C<$message>. In case there's no appropriate filename for
# the message, NO_FILE may be passed, likewise for C<$lineno> and
# NO_LINES. Before printing, the filename is normalized, that is,
@@ -13,10 +13,12 @@ package PkgLint::Logging;
# log_error(NO_FILE, NO_LINES, "Invalid command line.");
# log_warning($fname, NO_LINES, "Not found.");
# log_debug($fname, $lineno, sprintf("invalid character (0x%02x).", $c));
-#==========================================================================
+#
+package PkgLint::Logging;
use strict;
use warnings;
+
BEGIN {
use Exporter;
use vars qw(@ISA @EXPORT_OK);
@@ -130,7 +132,3 @@ sub set_explain() { $explain_flag = true; }
sub set_gcc_output_format() { $gcc_output_format = true; }
sub get_show_source_flag() { return $show_source_flag; }
sub set_show_source_flag() { $show_source_flag = true; }
-
-#== End of PkgLint::Logging ===============================================
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/Patches.pm b/pkgtools/pkglint/files/PkgLint/Patches.pm
index 23b7bb8487d..c96fd3ce063 100644
--- a/pkgtools/pkglint/files/PkgLint/Patches.pm
+++ b/pkgtools/pkglint/files/PkgLint/Patches.pm
@@ -1,8 +1,10 @@
-# $NetBSD: Patches.pm,v 1.1 2015/10/11 19:20:17 rillig Exp $
+# $NetBSD: Patches.pm,v 1.2 2015/10/11 21:06:20 rillig Exp $
#
# Everything concerning checks for patch files.
#
+use strict;
+
# Guess the type of file based on the filename. This is used to select
# the proper subroutine for detecting absolute pathnames.
#
diff --git a/pkgtools/pkglint/files/PkgLint/SimpleMatch.pm b/pkgtools/pkglint/files/PkgLint/SimpleMatch.pm
index e3db828432e..bf469e09e7d 100644
--- a/pkgtools/pkglint/files/PkgLint/SimpleMatch.pm
+++ b/pkgtools/pkglint/files/PkgLint/SimpleMatch.pm
@@ -1,10 +1,13 @@
-#==========================================================================
+# $NetBSD: SimpleMatch.pm,v 1.2 2015/10/11 21:06:20 rillig Exp $
+#
# A SimpleMatch is the result of applying a regular expression to a Perl
# scalar value. It can return the range and the text of the captured
# groups.
-#==========================================================================
+#
package PkgLint::SimpleMatch;
+use strict;
+
use enum qw(STRING STARTS ENDS N);
sub new($$) {
@@ -38,5 +41,3 @@ sub range($$) {
return ($self->[STARTS]->[$n], $self->[ENDS]->[$n]);
}
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/SubstContext.pm b/pkgtools/pkglint/files/PkgLint/SubstContext.pm
index fc9fbd637ef..b028f5840f8 100644
--- a/pkgtools/pkglint/files/PkgLint/SubstContext.pm
+++ b/pkgtools/pkglint/files/PkgLint/SubstContext.pm
@@ -1,10 +1,13 @@
-package PkgLint::SubstContext;
-#==========================================================================
+# $NetBSD: SubstContext.pm,v 1.2 2015/10/11 21:06:20 rillig Exp $
+#
# This class records the state of a block of variable assignments that make
# up a SUBST class. As these variable assignments are not easy to get right
# unless you do it every day, and the possibility of typos is high, pkglint
# provides additional checks for them.
-#==========================================================================
+#
+package PkgLint::SubstContext;
+
+use strict;
BEGIN {
import PkgLint::Util qw(
@@ -192,6 +195,3 @@ sub to_string($) {
scalar(@{$self->subst_sed}),
(defined($self->subst_id) ? $self->subst_id : "(undef)"));
}
-#== End of PkgLint::SubstContext ==========================================
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/Type.pm b/pkgtools/pkglint/files/PkgLint/Type.pm
index 3f542620c4e..17bce8d8205 100644
--- a/pkgtools/pkglint/files/PkgLint/Type.pm
+++ b/pkgtools/pkglint/files/PkgLint/Type.pm
@@ -1,9 +1,12 @@
-package PkgLint::Type;
-#==========================================================================
+# $NetBSD: Type.pm,v 1.2 2015/10/11 21:06:20 rillig Exp $
+#
# A Type in pkglint is a combination of a data type and a permission
# specification. Further details can be found in the chapter ``The pkglint
# type system'' of the pkglint book.
-#==========================================================================
+#
+package PkgLint::Type;
+
+use strict;
BEGIN {
import PkgLint::Util qw(
@@ -47,7 +50,7 @@ sub perms($$) {
return $acl_entry->[ACLE_PERMS];
}
}
- return undef;
+ return;
}
# Returns the union of all possible permissions. This can be used to
@@ -96,7 +99,3 @@ sub to_string($) {
return (["", "InternalList of ", "List of "]->[$self->kind_of_list]) . $self->basic_type;
}
-
-#== End of PkgLint::Type ==================================================
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/Util.pm b/pkgtools/pkglint/files/PkgLint/Util.pm
index 2edecf8b330..5683638d11d 100644
--- a/pkgtools/pkglint/files/PkgLint/Util.pm
+++ b/pkgtools/pkglint/files/PkgLint/Util.pm
@@ -1,12 +1,16 @@
-package PkgLint::Util;
-#==========================================================================
+# $NetBSD: Util.pm,v 1.2 2015/10/11 21:06:20 rillig Exp $
+#
# This package is a catch-all for subroutines that are not application-spe-
# cific. Currently it contains the boolean constants C<false> and C<true>,
# as well as a function to print text in a table format, and a function
# that converts an array into a hash. The latter is just for convenience
# because I don't know of a Perl operator similar to qw() that can be used
# for creating a hash.
-#==========================================================================
+#
+package PkgLint::Util;
+
+use strict;
+
BEGIN {
use Exporter;
use vars qw(@ISA @EXPORT_OK);
@@ -90,6 +94,3 @@ sub normalize_pathname($) {
return $fname;
}
-#== End of PkgLint::Util ==================================================
-
-1;
diff --git a/pkgtools/pkglint/files/PkgLint/VarUseContext.pm b/pkgtools/pkglint/files/PkgLint/VarUseContext.pm
index 308f809f410..a782daca27f 100644
--- a/pkgtools/pkglint/files/PkgLint/VarUseContext.pm
+++ b/pkgtools/pkglint/files/PkgLint/VarUseContext.pm
@@ -1,9 +1,10 @@
+# The various contexts in which make(1) variables can appear in pkgsrc.
+# Further details can be found in the chapter ``The pkglint type system''
+# of the pkglint book.
+#
package PkgLint::VarUseContext;
-#==========================================================================
-# This class represents the various contexts in which make(1) variables can
-# appear in pkgsrc. Further details can be found in the chapter ``The
-# pkglint type system'' of the pkglint book.
-#==========================================================================
+
+use strict;
BEGIN {
import PkgLint::Util qw(
@@ -63,7 +64,3 @@ sub to_string($) {
["none", "plain", "squot", "dquot", "backt", "for"]->[$self->shellword],
["unknown", "full", "word", "word-part"]->[$self->extent]);
}
-
-#== End of PkgLint::VarUseContext =========================================
-
-1;
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index ce575495097..55030131c35 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -1,5 +1,5 @@
#! @PERL@
-# $NetBSD: pkglint.pl,v 1.887 2015/10/11 19:20:17 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.888 2015/10/11 21:06:20 rillig Exp $
#
# pkglint - static analyzer and checker for pkgsrc packages
@@ -611,7 +611,7 @@ sub parse_acls($$) {
) (?:\,\s*|$)"x;
if (!defined($acltext)) {
- return undef;
+ return;
}
$acls = [];
@@ -1834,7 +1834,7 @@ sub get_variable_type($$) {
}
$opt_debug_vartypes and $line->log_debug("No type definition found for ${varcanon}.");
- return undef;
+ return;
}
sub get_variable_perms($$) {
@@ -2370,7 +2370,7 @@ sub checkword_absolute_pathname($$) {
sub check_unused_licenses() {
- for my $licensefile (<${cwd_pkgsrcdir}/licenses/*>) {
+ for my $licensefile (glob("${cwd_pkgsrcdir}/licenses/*")) {
if (-f $licensefile) {
my $licensename = basename($licensefile);
if (!exists($ipc_used_licenses{$licensename})) {
@@ -2427,7 +2427,7 @@ sub checkline_valid_characters($$) {
($rest = $line->text) =~ s/$re_validchars//g;
if ($rest ne "") {
- my @chars = map { $_ = sprintf("0x%02x", ord($_)); } split(//, $rest);
+ my @chars = map { sprintf("0x%02x", ord($_)); } split(//, $rest);
$line->log_warning("Line contains invalid characters (" . join(", ", @chars) . ").");
}
}
@@ -2441,7 +2441,7 @@ sub checkline_valid_characters_in_variable($$) {
$rest =~ s/$re_validchars//g;
if ($rest ne "") {
- my @chars = map { $_ = sprintf("0x%02x", ord($_)); } split(//, $rest);
+ my @chars = map { sprintf("0x%02x", ord($_)); } split(//, $rest);
$line->log_warning("${varname} contains invalid characters (" . join(", ", @chars) . ").");
}
}
@@ -3146,7 +3146,7 @@ sub checkline_mk_shelltext($$) {
INSTALL_DIR INSTALL_DIR2
);
use enum (":SCST_", scst);
- use constant scst_statename => [ map { $_ = "SCST_$_"; } scst ];
+ use constant scst_statename => [ map { "SCST_$_" } scst ];
use constant forbidden_commands => array_to_hash(qw(
ktrace
@@ -5612,17 +5612,17 @@ sub checkfile_distinfo($) {
$line->log_warning("${patches_dir}/${chksum_fname} is registered in distinfo but not added to CVS.");
}
- if (open(PATCH, "<", $fname)) {
- my $data = "";
- foreach my $patchline (<PATCH>) {
- $data .= $patchline unless $patchline =~ m"\$[N]etBSD";
+ if (open(my $patchfile, "<", $fname)) {
+ my $sha1 = Digest::SHA1->new();
+ foreach my $patchline (<$patchfile>) {
+ $sha1->add($patchline) unless $patchline =~ m"\$[N]etBSD";
}
- close(PATCH);
- my $chksum = Digest::SHA1::sha1_hex($data);
+ close($patchfile);
+ my $chksum = $sha1->hexdigest();
if ($sum ne $chksum) {
$line->log_error("${alg} checksum of ${chksum_fname} differs (expected ${sum}, got ${chksum}). Rerun '".conf_make." makepatchsum'.");
}
- } elsif (true) {
+ } else {
$line->log_warning("${chksum_fname} does not exist.");
$line->explain_warning(
"All patches that are mentioned in a distinfo file should actually exist.",
@@ -5634,7 +5634,7 @@ sub checkfile_distinfo($) {
checklines_trailing_empty_lines($lines);
if (defined($patches_dir)) {
- foreach my $patch (<${current_dir}/${patches_dir}/patch-*>) {
+ foreach my $patch (glob("${current_dir}/${patches_dir}/patch-*")) {
$patch = basename($patch);
if (!exists($in_distinfo{$patch})) {
log_error($fname, NO_LINE_NUMBER, "$patch is not recorded. Rerun '".conf_make." makepatchsum'.");
@@ -6593,14 +6593,14 @@ sub checkdir_package() {
goto cleanup;
}
- my @files = <${current_dir}/*>;
+ my @files = glob("${current_dir}/*");
if ($pkgdir ne ".") {
- push(@files, <${current_dir}/${pkgdir}/*>);
+ push(@files, glob("${current_dir}/${pkgdir}/*"));
}
if ($opt_check_extra) {
- push(@files, <${current_dir}/${filesdir}/*>);
+ push(@files, glob("${current_dir}/${filesdir}/*"));
}
- push(@files, <${current_dir}/${patchdir}/*>);
+ push(@files, glob("${current_dir}/${patchdir}/*"));
if ($distinfo_file !~ m"^(?:\./)?distinfo$") {
push(@files, "${current_dir}/${distinfo_file}");
}