pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files - Added three warning categorie...
details: https://anonhg.NetBSD.org/pkgsrc/rev/da98d5984cb8
branches: trunk
changeset: 506120:da98d5984cb8
user: rillig <rillig%pkgsrc.org@localhost>
date: Thu Jan 12 10:32:40 2006 +0000
description:
- Added three warning categories "debug", "quoting" and "space" that can
be enabled independently. They are all disabled by default.
- A note is emitted if variable definitions are aligned using space instead
of tabs.
diffstat:
pkgtools/pkglint/files/pkglint.0 | 9 +++++++++
pkgtools/pkglint/files/pkglint.1 | 9 ++++++++-
pkgtools/pkglint/files/pkglint.pl | 18 ++++++++++++++----
3 files changed, 31 insertions(+), 5 deletions(-)
diffs (128 lines):
diff -r 0e51bb61ddf4 -r da98d5984cb8 pkgtools/pkglint/files/pkglint.0
--- a/pkgtools/pkglint/files/pkglint.0 Thu Jan 12 07:12:31 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.0 Thu Jan 12 10:32:40 2006 +0000
@@ -103,6 +103,9 @@
[[nnoo--]]aabbssnnaammee Warn if a file contains an absolute pathname.
+ [[nnoo--]]ddeebbuugg Enable some warnings that are only useful for
+ debugging pkglint itself.
+
[[nnoo--]]ddiirreeccttccmmdd Warn if a system command name is used instead
of a variable (e.g. sed instead of ${SED}).
@@ -116,6 +119,12 @@
alphabetically. This warning is disabled by
default.
+ [[nnoo--]]qquuoottiinngg Warn for possibly invalid quoting of make vari-
+ ables in shell programs and shell variables
+ themselves.
+
+ [[nnoo--]]ssppaaccee Emit notes for inconsistent use of white-space.
+
[[nnoo--]]ttyyppeess Warn for some Makefile variables if their
assigned values do not match their type.
diff -r 0e51bb61ddf4 -r da98d5984cb8 pkgtools/pkglint/files/pkglint.1
--- a/pkgtools/pkglint/files/pkglint.1 Thu Jan 12 07:12:31 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.1 Thu Jan 12 10:32:40 2006 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkglint.1,v 1.33 2006/01/11 11:42:27 rillig Exp $
+.\" $NetBSD: pkglint.1,v 1.34 2006/01/12 10:32:40 rillig Exp $
.\" From FreeBSD: portlint.1,v 1.8 1997/11/25 14:53:14 itojun Exp
.\"
.\" Copyright (c) 1997 by Jun-ichiro Itoh <itojun%itojun.org@localhost>.
@@ -125,6 +125,8 @@
Disable all warnings.
.It Cm [no-]absname
Warn if a file contains an absolute pathname.
+.It Cm [no-]debug
+Enable some warnings that are only useful for debugging pkglint itself.
.It Cm [no-]directcmd
Warn if a system command name is used instead of a variable (e.g. sed
instead of ${SED}).
@@ -136,6 +138,11 @@
.It Cm [no-]plist-sort
Warn if items of a PLIST file are not sorted alphabetically.
This warning is disabled by default.
+.It Cm [no-]quoting
+Warn for possibly invalid quoting of make variables in shell programs
+and shell variables themselves.
+.It Cm [no-]space
+Emit notes for inconsistent use of white-space.
.It Cm [no-]types
Warn for some Makefile variables if their assigned values do not match
their type.
diff -r 0e51bb61ddf4 -r da98d5984cb8 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Thu Jan 12 07:12:31 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Thu Jan 12 10:32:40 2006 +0000
@@ -1,5 +1,5 @@
#! @PERL@ -w
-# $NetBSD: pkglint.pl,v 1.464 2006/01/12 04:31:30 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.465 2006/01/12 10:32:40 rillig Exp $
#
# pkglint - static analyzer and checker for pkgsrc packages
@@ -916,17 +916,23 @@
);
my $opt_warn_absname = true;
+my $opt_warn_debug = false;
my $opt_warn_directcmd = true;
my $opt_warn_extra = false;
my $opt_warn_order = true;
my $opt_warn_plist_sort = false;
+my $opt_warn_quoting = false;
+my $opt_warn_space = false;
my $opt_warn_types = true;
my (%warnings) = (
"absname" => [\$opt_warn_absname, "warn about use of absolute file names"],
+ "debug" => [\$opt_warn_debug, "enable some warnings that are useful for debugging pkglint"],
"directcmd" => [\$opt_warn_directcmd, "warn about use of direct command names instead of Make variables"],
"extra" => [\$opt_warn_extra, "enable some extra warnings"],
"order" => [\$opt_warn_order, "warn if Makefile entries are unordered"],
"plist-sort" => [\$opt_warn_plist_sort, "warn about unsorted entries in PLISTs"],
+ "quoting" => [\$opt_warn_quoting, "warn about quoting issues"],
+ "space" => [\$opt_warn_space, "warn about inconsistent use of white-space"],
"types" => [\$opt_warn_types, "do some simple type checking in Makefiles"],
);
@@ -1986,7 +1992,7 @@
if ($rest =~ s/^\$\{(${regex_varname})(:[^\{]+)?\}//) {
my ($varname, $mod) = ($1, $2);
- if (!$opt_warn_extra) {
+ if (!$opt_warn_quoting) {
# Skip the following checks.
} elsif ($state == SWST_PLAIN && defined($mod) && $mod eq ":Q") {
@@ -2008,7 +2014,7 @@
} elsif ($rest =~ s/^\$\$([0-9A-Z_a-z]+)//
|| $rest =~ s/^\$\$\{([0-9A-Z_a-z]+)\}//) {
my ($shvarname) = ($1);
- if ($opt_warn_extra and $check_quoting) {
+ if ($opt_warn_quoting and $check_quoting) {
$line->log_warning("Unquoted shell variable \"${shvarname}\".");
}
} else {
@@ -2058,7 +2064,7 @@
}
}
if ($rest ne "") {
- $line->log_debug("[checkline_mk_shellword] " . statename->[$state] . ": rest=${rest}");
+ $opt_warn_debug && $line->log_error("[checkline_mk_shellword] " . statename->[$state] . ": rest=${rest}");
}
}
@@ -2917,6 +2923,10 @@
} elsif ($text =~ regex_varassign) {
my ($varname, $op, $value, $comment) = ($1, $2, $3, $4);
+ my $align = substr($text, $+[2], $-[3] - $+[2]);
+ if ($align !~ qr"^\t*$") {
+ $opt_warn_space && $line->log_note("Alignment of variable values should be done with tabs, not spaces.");
+ }
checkline_mk_varassign($line, $varname, $op, $value, $comment);
} elsif ($text =~ regex_shellcmd) {
Home |
Main Index |
Thread Index |
Old Index