pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update to 19.3.11
details: https://anonhg.NetBSD.org/pkgsrc/rev/9cb95bb7ac17
branches: trunk
changeset: 405431:9cb95bb7ac17
user: rillig <rillig%pkgsrc.org@localhost>
date: Wed Nov 27 22:10:06 2019 +0000
description:
pkgtools/pkglint: update to 19.3.11
Changes since 19.3.10:
The check for buildlink3.mk files that are included conditionally in one
place and unconditionally in another place have been refined. Now they
also work in cases that do not involve any variables, such as when the
condition is a mere exists(filename).
References to variables that use parentheses instead of the usual braces
produce a warning now, even if pkglint cannot fix them automatically.
This affects only a few instances where more than one such variable
reference appeared in a single line.
The --log-verbose command line option has been removed since it does not
have any practical use other than improving the performance during
pkglint development itself. Because of that it hadn't even been
mentioned in the manual page.
Warnings for missing license files now report the path to the license
file relative to the line where the warning occurs, like everywhere
else.
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/PLIST | 8 +-
pkgtools/pkglint/files/autofix.go | 16 +-
pkgtools/pkglint/files/autofix_test.go | 109 +--
pkgtools/pkglint/files/check_test.go | 70 +-
pkgtools/pkglint/files/getopt/getopt_test.go | 4 +-
pkgtools/pkglint/files/histogram/histogram_test.go | 4 +-
pkgtools/pkglint/files/intqa/ideas.go | 3 -
pkgtools/pkglint/files/intqa/qa.go | 540 +++++++++++++++
pkgtools/pkglint/files/intqa/qa_test.go | 722 ++++++++++++++++++++
pkgtools/pkglint/files/intqa/testnames.go | 463 ------------
pkgtools/pkglint/files/intqa/testnames_test.go | 628 -----------------
pkgtools/pkglint/files/licenses.go | 3 +-
pkgtools/pkglint/files/licenses/licenses_test.go | 4 +-
pkgtools/pkglint/files/licenses_test.go | 24 +-
pkgtools/pkglint/files/line.go | 6 +-
pkgtools/pkglint/files/line_test.go | 18 +
pkgtools/pkglint/files/logging.go | 11 +-
pkgtools/pkglint/files/logging_test.go | 12 +-
pkgtools/pkglint/files/mklexer.go | 414 +++++++++++
pkgtools/pkglint/files/mklexer_test.go | 750 +++++++++++++++++++++
pkgtools/pkglint/files/mkline.go | 18 +-
pkgtools/pkglint/files/mkline_test.go | 4 +-
pkgtools/pkglint/files/mklinechecker.go | 16 +-
pkgtools/pkglint/files/mklinechecker_test.go | 23 +-
pkgtools/pkglint/files/mklineparser.go | 3 +-
pkgtools/pkglint/files/mklines.go | 2 +-
pkgtools/pkglint/files/mkparser.go | 421 +-----------
pkgtools/pkglint/files/mkparser_test.go | 735 --------------------
pkgtools/pkglint/files/mkshparser.go | 4 +-
pkgtools/pkglint/files/mkshparser_test.go | 77 +-
pkgtools/pkglint/files/mkshtypes_test.go | 11 +
pkgtools/pkglint/files/mkshwalker_test.go | 9 +-
pkgtools/pkglint/files/mktypes.go | 2 +-
pkgtools/pkglint/files/mktypes_test.go | 12 +-
pkgtools/pkglint/files/package.go | 46 +-
pkgtools/pkglint/files/package_test.go | 52 +-
pkgtools/pkglint/files/path.go | 76 +-
pkgtools/pkglint/files/path_test.go | 92 ++-
pkgtools/pkglint/files/pkglint.1 | 4 +-
pkgtools/pkglint/files/pkglint.go | 32 +-
pkgtools/pkglint/files/pkglint_test.go | 43 +-
pkgtools/pkglint/files/pkgsrc.go | 97 ++-
pkgtools/pkglint/files/pkgsrc_test.go | 157 ++++-
pkgtools/pkglint/files/pkgver/vercmp_test.go | 4 +-
pkgtools/pkglint/files/plist_test.go | 2 +-
pkgtools/pkglint/files/shell.go | 2 +-
pkgtools/pkglint/files/shell_test.go | 48 +-
pkgtools/pkglint/files/shtokenizer.go | 13 +-
pkgtools/pkglint/files/shtokenizer_test.go | 21 +-
pkgtools/pkglint/files/shtypes_test.go | 6 +-
pkgtools/pkglint/files/substcontext.go | 4 +-
pkgtools/pkglint/files/testnames_test.go | 5 +-
pkgtools/pkglint/files/textproc/lexer_test.go | 4 +-
pkgtools/pkglint/files/trace/tracing_test.go | 4 +-
pkgtools/pkglint/files/util.go | 66 +-
pkgtools/pkglint/files/util_test.go | 59 +-
pkgtools/pkglint/files/varalignblock.go | 2 +-
pkgtools/pkglint/files/vardefs.go | 16 +
pkgtools/pkglint/files/vardefs_test.go | 59 +-
pkgtools/pkglint/files/vartypecheck.go | 7 +-
pkgtools/pkglint/files/vartypecheck_test.go | 7 +-
62 files changed, 3413 insertions(+), 2665 deletions(-)
diffs (truncated from 7982 to 300 lines):
diff -r 11fa75d41a18 -r 9cb95bb7ac17 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Wed Nov 27 21:52:04 2019 +0000
+++ b/pkgtools/pkglint/Makefile Wed Nov 27 22:10:06 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.610 2019/11/23 23:35:55 rillig Exp $
+# $NetBSD: Makefile,v 1.611 2019/11/27 22:10:06 rillig Exp $
-PKGNAME= pkglint-19.3.10
+PKGNAME= pkglint-19.3.11
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r 11fa75d41a18 -r 9cb95bb7ac17 pkgtools/pkglint/PLIST
--- a/pkgtools/pkglint/PLIST Wed Nov 27 21:52:04 2019 +0000
+++ b/pkgtools/pkglint/PLIST Wed Nov 27 22:10:06 2019 +0000
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.17 2019/11/23 23:35:55 rillig Exp $
+@comment $NetBSD: PLIST,v 1.18 2019/11/27 22:10:06 rillig Exp $
bin/pkglint
gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint.a
gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint/getopt.a
@@ -30,8 +30,8 @@
gopkg/src/netbsd.org/pkglint/histogram/histogram.go
gopkg/src/netbsd.org/pkglint/histogram/histogram_test.go
gopkg/src/netbsd.org/pkglint/intqa/ideas.go
-gopkg/src/netbsd.org/pkglint/intqa/testnames.go
-gopkg/src/netbsd.org/pkglint/intqa/testnames_test.go
+gopkg/src/netbsd.org/pkglint/intqa/qa.go
+gopkg/src/netbsd.org/pkglint/intqa/qa_test.go
gopkg/src/netbsd.org/pkglint/licenses.go
gopkg/src/netbsd.org/pkglint/licenses/licenses.go
gopkg/src/netbsd.org/pkglint/licenses/licenses.y
@@ -49,6 +49,8 @@
gopkg/src/netbsd.org/pkglint/lines_test.go
gopkg/src/netbsd.org/pkglint/logging.go
gopkg/src/netbsd.org/pkglint/logging_test.go
+gopkg/src/netbsd.org/pkglint/mklexer.go
+gopkg/src/netbsd.org/pkglint/mklexer_test.go
gopkg/src/netbsd.org/pkglint/mkline.go
gopkg/src/netbsd.org/pkglint/mkline_test.go
gopkg/src/netbsd.org/pkglint/mklinechecker.go
diff -r 11fa75d41a18 -r 9cb95bb7ac17 pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Wed Nov 27 21:52:04 2019 +0000
+++ b/pkgtools/pkglint/files/autofix.go Wed Nov 27 22:10:06 2019 +0000
@@ -29,7 +29,6 @@
diagFormat string // Is logged only if it couldn't be fixed automatically
diagArgs []interface{} //
explanation []string // Is printed together with the diagnostic
- anyway bool // Print the diagnostic even if it cannot be autofixed
}
type autofixAction struct {
@@ -297,15 +296,6 @@
fix.actions = append(fix.actions, autofixAction{sprintf(format, args...), lineno})
}
-// Anyway has the effect of showing the diagnostic even when nothing can
-// be fixed automatically.
-//
-// As usual, the diagnostic is only shown if neither --show-autofix nor
-// --autofix mode is given.
-func (fix *Autofix) Anyway() {
- fix.anyway = !G.Logger.IsAutofix()
-}
-
// Apply does the actual work.
// Depending on the pkglint mode, it either:
//
@@ -330,7 +320,7 @@
fix.autofixShortTerm = autofixShortTerm{}
}
- if !(G.Logger.Relevant(fix.diagFormat) && (len(fix.actions) > 0 || fix.anyway)) {
+ if !(G.Logger.Relevant(fix.diagFormat) && (len(fix.actions) > 0 || !G.Logger.IsAutofix())) {
reset()
return
}
@@ -488,12 +478,12 @@
}
err := tmpName.WriteString(text.String())
if err != nil {
- G.Logger.Errorf(tmpName, "Cannot write: %s", err)
+ G.Logger.TechErrorf(tmpName, "Cannot write: %s", err)
continue
}
err = tmpName.Rename(filename)
if err != nil {
- G.Logger.Errorf(tmpName, "Cannot overwrite with autofixed content: %s", err)
+ G.Logger.TechErrorf(tmpName, "Cannot overwrite with autofixed content: %s", err)
continue
}
autofixed = true
diff -r 11fa75d41a18 -r 9cb95bb7ac17 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go Wed Nov 27 21:52:04 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go Wed Nov 27 22:10:06 2019 +0000
@@ -140,7 +140,7 @@
t := s.Init(c)
t.SetUpCommandLine("-Wall", "--source")
- G.Logger.Opts.LogVerbose = false // For realistic conditions; otherwise all diagnostics are logged.
+ G.Logger.verbose = false // For realistic conditions; otherwise all diagnostics are logged.
t.SetUpPackage("x11/xorg-cf-files",
".include \"../../x11/xorgproto/buildlink3.mk\"")
@@ -173,7 +173,7 @@
t := s.Init(c)
t.SetUpCommandLine("-Wall", "--source", "--explain")
- G.Logger.Opts.LogVerbose = false // For realistic conditions; otherwise all diagnostics are logged.
+ G.Logger.verbose = false // For realistic conditions; otherwise all diagnostics are logged.
t.SetUpPackage("print/tex-bibtex8",
"MAKE_FLAGS+=\tCFLAGS=${CFLAGS.${PKGSRC_COMPILER}}")
@@ -245,7 +245,8 @@
// shown even when they cannot be autofixed.
//
// This is typical when an autofix is provided for simple scenarios,
-// but the code actually found is a little more complicated.
+// but the code actually found is a little more complicated, like needing
+// special escaping for some of the characters or containing linebreaks.
func (s *Suite) Test_Autofix__show_unfixable_diagnostics_in_default_mode(c *check.C) {
t := s.Init(c)
@@ -258,17 +259,11 @@
lines.Lines[0].Warnf("This warning is shown since the --show-autofix option is not given.")
fix := lines.Lines[1].Autofix()
- fix.Warnf("This warning cannot be fixed and is therefore not shown.")
+ fix.Warnf("This warning cannot be fixed, nevertheless it is shown (1).")
fix.Replace("XXX", "TODO")
fix.Apply()
- fix.Warnf("This warning cannot be fixed automatically but should be shown anyway.")
- fix.Replace("XXX", "TODO")
- fix.Anyway()
- fix.Apply()
-
- // If this warning should ever appear it is probably because fix.anyway is not reset properly.
- fix.Warnf("This warning cannot be fixed and is therefore not shown.")
+ fix.Warnf("This warning cannot be fixed, nevertheless it is shown (2).")
fix.Replace("XXX", "TODO")
fix.Apply()
@@ -279,7 +274,8 @@
"WARN: Makefile:1: This warning is shown since the --show-autofix option is not given.",
"",
">\tline2",
- "WARN: Makefile:2: This warning cannot be fixed automatically but should be shown anyway.",
+ "WARN: Makefile:2: This warning cannot be fixed, nevertheless it is shown (1).",
+ "WARN: Makefile:2: This warning cannot be fixed, nevertheless it is shown (2).",
"",
">\tline3",
"WARN: Makefile:3: This warning is also shown.")
@@ -321,7 +317,7 @@
"+\tTODO")
}
-// If an Autofix doesn't do anything, it must not log any diagnostics.
+// If an Autofix doesn't do anything, it nevertheless logs the diagnostics.
func (s *Suite) Test_Autofix__noop_replace(c *check.C) {
t := s.Init(c)
@@ -332,8 +328,14 @@
fix.ReplaceRegex(`\b[A-Z]{3,}\b`, "---censored---", -1)
fix.Apply()
- // No output since there was no all-uppercase word in the text.
- t.CheckOutputEmpty()
+ // This warning is wrong. This test therefore demonstrates that each
+ // autofix must be properly guarded to only apply when it actually
+ // does something.
+ //
+ // As of November 2019 there is no Rollback method since it was not
+ // needed yet.
+ t.CheckOutputLines(
+ "WARN: Makefile:14: All-uppercase words should not be used at all.")
}
func (s *Suite) Test_Autofix_Warnf__duplicate(c *check.C) {
@@ -550,9 +552,7 @@
t := s.Init(c)
lines := func(lines ...string) []string { return lines }
- diagnostics := lines
- autofixes := lines
- test := func(texts []string, rawIndex int, column int, from, to string, diagnostics []string, autofixes []string) {
+ test := func(texts []string, rawIndex int, column int, from, to string, diagnostics ...string) {
mainPart := func() {
mklines := t.NewMkLines("filename.mk", texts...)
@@ -562,17 +562,10 @@
fix := mkline.Autofix()
fix.Notef("Should be appended instead of assigned.")
fix.ReplaceAt(rawIndex, column, from, to)
- fix.Anyway()
fix.Apply()
}
- t.SetUpCommandLine("-Wall")
- mainPart()
- t.CheckOutput(diagnostics)
-
- t.SetUpCommandLine("-Wall", "--autofix")
- mainPart()
- t.CheckOutput(autofixes)
+ t.ExpectDiagnosticsAutofix(mainPart, diagnostics...)
}
test(
@@ -580,10 +573,9 @@
"VAR=value1 \\",
"\tvalue2"),
0, 3, "=", "+=",
- diagnostics(
- "NOTE: filename.mk:1: Should be appended instead of assigned."),
- autofixes(
- "AUTOFIX: filename.mk:1: Replacing \"=\" with \"+=\"."))
+
+ "NOTE: filename.mk:1: Should be appended instead of assigned.",
+ "AUTOFIX: filename.mk:1: Replacing \"=\" with \"+=\".")
// If the text at the precisely given position does not match,
// the note is still printed because of the fix.Anyway(), but
@@ -593,21 +585,19 @@
"VAR=value1 \\",
"\tvalue2"),
0, 3, "?", "+=",
- diagnostics(
- "NOTE: filename.mk:1--2: Should be appended instead of assigned."),
- autofixes(
- nil...))
+
+ "NOTE: filename.mk:1--2: Should be appended instead of assigned.")
// Getting the line number wrong is a strange programming error, and
// there does not need to be any code checking for this in the main code.
t.ExpectPanicMatches(
- func() { test(lines("VAR=value"), 10, 3, "from", "to", nil, nil) },
+ func() { test(lines("VAR=value"), 10, 3, "from", "to", nil...) },
`runtime error: index out of range.*`)
// It is a programming error to replace a string with itself, since that
// would produce confusing diagnostics.
t.ExpectAssert(
- func() { test(lines("VAR=value"), 0, 4, "value", "value", nil, nil) })
+ func() { test(lines("VAR=value"), 0, 4, "value", "value", nil...) })
// Getting the column number wrong may happen when a previous replacement
// has made the string shorter than before, therefore no panic in this case.
@@ -616,10 +606,8 @@
"VAR=value1 \\",
"\tvalue2"),
0, 20, "?", "+=",
- diagnostics(
- "NOTE: filename.mk:1--2: Should be appended instead of assigned."),
- autofixes(
- nil...))
+
+ "NOTE: filename.mk:1--2: Should be appended instead of assigned.")
}
func (s *Suite) Test_Autofix_ReplaceRegex__show_autofix(c *check.C) {
@@ -860,7 +848,7 @@
// With the default command line options, this warning is printed.
// With the --show-autofix option this warning is NOT printed since it
// cannot be fixed automatically.
-func (s *Suite) Test_Autofix_Anyway__options(c *check.C) {
+func (s *Suite) Test_Autofix_Apply__show_autofix_option(c *check.C) {
t := s.Init(c)
t.SetUpCommandLine("--show-autofix")
@@ -870,7 +858,6 @@
fix.Warnf("This autofix doesn't match.")
fix.Replace("doesn't match", "")
- fix.Anyway()
fix.Apply()
t.CheckOutputEmpty()
@@ -879,14 +866,13 @@
fix.Warnf("This autofix doesn't match.")
fix.Replace("doesn't match", "")
- fix.Anyway()
fix.Apply()
t.CheckOutputLines(
"WARN: filename:3: This autofix doesn't match.")
}
-func (s *Suite) Test_Autofix_Anyway__autofix_option(c *check.C) {
+func (s *Suite) Test_Autofix_Apply__autofix_option(c *check.C) {
t := s.Init(c)
t.SetUpCommandLine("--autofix")
@@ -895,17 +881,13 @@
fix := line.Autofix()
fix.Notef("This line is quite short.")
fix.Replace("not found", "needle")
- fix.Anyway()
Home |
Main Index |
Thread Index |
Old Index