pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files pkglint can now automatically a...
details: https://anonhg.NetBSD.org/pkgsrc/rev/5d834cbe3c43
branches: trunk
changeset: 538082:5d834cbe3c43
user: rillig <rillig%pkgsrc.org@localhost>
date: Mon Jan 28 01:18:13 2008 +0000
description:
pkglint can now automatically add the "used by" clauses to
Makefile.common when run with the --autofix option.
diffstat:
pkgtools/pkglint/files/pkglint.pl | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diffs (46 lines):
diff -r b4ec8b69e1f6 -r 5d834cbe3c43 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Mon Jan 28 01:15:26 2008 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Mon Jan 28 01:18:13 2008 +0000
@@ -1,5 +1,5 @@
#! @PERL@
-# $NetBSD: pkglint.pl,v 1.758 2008/01/28 00:53:21 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.759 2008/01/28 01:18:13 rillig Exp $
#
# pkglint - static analyzer and checker for pkgsrc packages
@@ -3623,16 +3623,17 @@
# Makefile.common that says which files
# include it.
if ($includefile =~ qr"/Makefile\.common$") {
- my $mentioned = false;
+ my @mc_lines = @{$all_lines}[$last_lineno+1 .. $#{$all_lines}];
my $expected = "# used by " . relative_path($cwd_pkgsrcdir, $fname);
- for (my $i = $last_lineno + 1; $i <= $#{$all_lines}; $i++) {
- my $mcline = $all_lines->[$i];
- $mentioned = true if $mcline->text eq $expected;
- }
-
- if (!$mentioned) {
- $all_lines->[$last_lineno + 3]->log_warning("Please add a line \"$expected\" here.");
- $all_lines->[$last_lineno + 3]->explain_warning(
+
+ if (!(grep { $_->text eq $expected } @mc_lines)) {
+ my $lineno = 0;
+ while ($lineno < $#mc_lines && $mc_lines[$lineno]->has("is_comment")) {
+ $lineno++;
+ }
+ my $iline = $mc_lines[$lineno];
+ $iline->log_warning("Please add a line \"$expected\" here.");
+ $iline->explain_warning(
"Since Makefile.common files usually don't have any comments and",
"therefore not a clearly defined interface, they should at least contain",
"references to all files that include them, so that it is easier to see",
@@ -3641,6 +3642,8 @@
"If there are more than five packages that use a Makefile.common,",
"you should think about giving it a proper name (maybe plugin.mk) and",
"documenting its interface.");
+ $iline->append_before($expected);
+ autofix(\@mc_lines);
}
}
}
Home |
Main Index |
Thread Index |
Old Index