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.7
details: https://anonhg.NetBSD.org/pkgsrc/rev/bc450552c36d
branches: trunk
changeset: 404687:bc450552c36d
user: rillig <rillig%pkgsrc.org@localhost>
date: Sun Nov 17 01:26:25 2019 +0000
description:
pkgtools/pkglint: update to 19.3.7
Changes since 19.3.6:
Improved variable value alignment.
Fixed wrong warning about comment lines that were interpreted as shell
commands before.
Warn when the first category of a package doesn't correspond to the
path in the filesystem. This affects 603 packages.
No longer warn about deprecated BUILDLINK_TRANSFORM.${OPSYS}. The
deprecation warning was meant for BUILDLINK_TRANSFORM.${pkgbase}, but
since pkglint cannot distinguish between these, the warnings were wrong.
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/PLIST | 3 +-
pkgtools/pkglint/files/alternatives.go | 2 +-
pkgtools/pkglint/files/autofix.go | 123 +-
pkgtools/pkglint/files/autofix_test.go | 1278 +++---
pkgtools/pkglint/files/buildlink3_test.go | 242 +-
pkgtools/pkglint/files/check_test.go | 21 +-
pkgtools/pkglint/files/distinfo_test.go | 612 +-
pkgtools/pkglint/files/files.go | 70 +-
pkgtools/pkglint/files/files_test.go | 116 +-
pkgtools/pkglint/files/getopt/getopt_test.go | 4 +-
pkgtools/pkglint/files/histogram/histogram_test.go | 7 +
pkgtools/pkglint/files/intqa/ideas.go | 5 -
pkgtools/pkglint/files/intqa/testnames.go | 493 +-
pkgtools/pkglint/files/intqa/testnames_test.go | 261 +
pkgtools/pkglint/files/licenses/licenses_test.go | 5 +-
pkgtools/pkglint/files/linelexer_test.go | 30 +-
pkgtools/pkglint/files/logging.go | 196 +-
pkgtools/pkglint/files/logging_test.go | 1360 +++---
pkgtools/pkglint/files/mkline.go | 20 +-
pkgtools/pkglint/files/mkline_test.go | 1347 ++---
pkgtools/pkglint/files/mklinechecker.go | 1434 +++---
pkgtools/pkglint/files/mklinechecker_test.go | 3491 +++++++++--------
pkgtools/pkglint/files/mklineparser.go | 6 +-
pkgtools/pkglint/files/mklineparser_test.go | 4 +-
pkgtools/pkglint/files/mklines.go | 642 +-
pkgtools/pkglint/files/mklines_test.go | 1873 ++++----
pkgtools/pkglint/files/mkparser.go | 40 +-
pkgtools/pkglint/files/mkparser_test.go | 402 +-
pkgtools/pkglint/files/mkshparser.go | 2 -
pkgtools/pkglint/files/mkshparser_test.go | 57 +-
pkgtools/pkglint/files/mktypes_test.go | 158 +-
pkgtools/pkglint/files/options_test.go | 180 +-
pkgtools/pkglint/files/package.go | 1050 ++--
pkgtools/pkglint/files/package_test.go | 3961 ++++++++++---------
pkgtools/pkglint/files/patches_test.go | 52 +-
pkgtools/pkglint/files/pkglint.go | 119 +-
pkgtools/pkglint/files/pkglint_test.go | 1138 ++--
pkgtools/pkglint/files/pkgsrc.go | 1022 ++--
pkgtools/pkglint/files/pkgsrc_test.go | 858 ++--
pkgtools/pkglint/files/pkgver/vercmp_test.go | 65 +-
pkgtools/pkglint/files/plist.go | 20 +-
pkgtools/pkglint/files/plist_test.go | 390 +-
pkgtools/pkglint/files/redundantscope.go | 4 +-
pkgtools/pkglint/files/redundantscope_test.go | 6 +-
pkgtools/pkglint/files/shell.go | 1040 ++--
pkgtools/pkglint/files/shell_test.go | 1969 +++++----
pkgtools/pkglint/files/shtokenizer_test.go | 290 +-
pkgtools/pkglint/files/substcontext_test.go | 44 +-
pkgtools/pkglint/files/testnames_test.go | 14 +-
pkgtools/pkglint/files/textproc/lexer_test.go | 20 +-
pkgtools/pkglint/files/tools_test.go | 406 +-
pkgtools/pkglint/files/toplevel_test.go | 84 +-
pkgtools/pkglint/files/trace/tracing_test.go | 5 +-
pkgtools/pkglint/files/util.go | 36 +-
pkgtools/pkglint/files/util_test.go | 856 ++--
pkgtools/pkglint/files/var.go | 24 +-
pkgtools/pkglint/files/var_test.go | 172 +-
pkgtools/pkglint/files/varalignblock.go | 224 +-
pkgtools/pkglint/files/varalignblock_test.go | 1232 +++--
pkgtools/pkglint/files/vardefs.go | 6 +-
pkgtools/pkglint/files/vardefs_test.go | 82 +-
pkgtools/pkglint/files/vargroups.go | 2 +-
pkgtools/pkglint/files/vartype.go | 30 +-
pkgtools/pkglint/files/vartype_test.go | 77 +-
pkgtools/pkglint/files/vartypecheck.go | 94 +-
pkgtools/pkglint/files/vartypecheck_test.go | 2 +-
67 files changed, 15387 insertions(+), 14495 deletions(-)
diffs (truncated from 33573 to 300 lines):
diff -r f9f1a3476cb0 -r bc450552c36d pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Nov 16 22:22:45 2019 +0000
+++ b/pkgtools/pkglint/Makefile Sun Nov 17 01:26:25 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.606 2019/11/04 18:44:21 rillig Exp $
+# $NetBSD: Makefile,v 1.607 2019/11/17 01:26:25 rillig Exp $
-PKGNAME= pkglint-19.3.6
+PKGNAME= pkglint-19.3.7
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r f9f1a3476cb0 -r bc450552c36d pkgtools/pkglint/PLIST
--- a/pkgtools/pkglint/PLIST Sat Nov 16 22:22:45 2019 +0000
+++ b/pkgtools/pkglint/PLIST Sun Nov 17 01:26:25 2019 +0000
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.15 2019/10/26 09:51:47 rillig Exp $
+@comment $NetBSD: PLIST,v 1.16 2019/11/17 01:26:25 rillig Exp $
bin/pkglint
gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint.a
gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint/getopt.a
@@ -31,6 +31,7 @@
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/licenses.go
gopkg/src/netbsd.org/pkglint/licenses/licenses.go
gopkg/src/netbsd.org/pkglint/licenses/licenses.y
diff -r f9f1a3476cb0 -r bc450552c36d pkgtools/pkglint/files/alternatives.go
--- a/pkgtools/pkglint/files/alternatives.go Sat Nov 16 22:22:45 2019 +0000
+++ b/pkgtools/pkglint/files/alternatives.go Sun Nov 17 01:26:25 2019 +0000
@@ -25,7 +25,7 @@
checkPlistAlternative := func(line *Line, alternative string) {
relImplementation := strings.Replace(alternative, "@PREFIX@/", "", 1)
plistName := replaceAll(relImplementation, `@(\w+)@`, "${$1}")
- if plist.Files[plistName] != nil || G.Pkg.vars.Defined("ALTERNATIVES_SRC") {
+ if plist.Files[plistName] != nil || G.Pkg.vars.IsDefined("ALTERNATIVES_SRC") {
return
}
diff -r f9f1a3476cb0 -r bc450552c36d pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Sat Nov 16 22:22:45 2019 +0000
+++ b/pkgtools/pkglint/files/autofix.go Sun Nov 17 01:26:25 2019 +0000
@@ -4,6 +4,7 @@
"io/ioutil"
"netbsd.org/pkglint/regex"
"os"
+ "path/filepath"
"strconv"
"strings"
)
@@ -127,20 +128,20 @@
// ReplaceAt replaces the text "from" with "to", a single time.
// But only if the text at the given position is indeed "from".
-func (fix *Autofix) ReplaceAt(rawIndex int, textIndex int, from string, to string) {
+func (fix *Autofix) ReplaceAt(rawIndex int, textIndex int, from string, to string) (modified bool, replaced string) {
assert(from != to)
fix.assertRealLine()
if fix.skip() {
- return
+ return false, ""
}
rawLine := fix.line.raw[rawIndex]
if textIndex >= len(rawLine.textnl) || !hasPrefix(rawLine.textnl[textIndex:], from) {
- return
+ return false, ""
}
- replaced := rawLine.textnl[:textIndex] + to + rawLine.textnl[textIndex+len(from):]
+ replaced = rawLine.textnl[:textIndex] + to + rawLine.textnl[textIndex+len(from):]
if G.Logger.IsAutofix() {
rawLine.textnl = replaced
@@ -157,7 +158,7 @@
}
}
fix.Describef(rawLine.Lineno, "Replacing %q with %q.", from, to)
- return
+ return true, replaced
}
// ReplaceRegex replaces the first howOften or all occurrences (if negative)
@@ -215,44 +216,6 @@
})
}
-// Custom runs a custom fix action, unless the fix is skipped anyway
-// because of the --only option.
-//
-// The fixer function must check whether it can actually fix something,
-// and if so, call Describef to describe the actual fix.
-//
-// If showAutofix and autofix are both false, the fix must only be
-// described by calling Describef. No observable modification must be done,
-// not even in memory.
-//
-// If showAutofix is true but autofix is false, the fix should be done in
-// memory as far as possible. For example, changing the text of Line.raw
-// is appropriate, but changing files in the file system is not.
-//
-// Only if autofix is true, fixes other than modifying the current Line
-// should be done persistently, such as changes to the file system.
-//
-// In any case, changes to the current Line will be written back to disk
-// by SaveAutofixChanges, after fixing all the lines in the file at once.
-func (fix *Autofix) Custom(fixer func(showAutofix, autofix bool)) {
- // Contrary to the fixes that modify the line text, this one
- // can be run even on dummy lines (like those standing for a
- // file at whole), for example to fix the permissions of the file.
-
- if fix.skip() {
- return
- }
-
- fixer(G.Logger.Opts.ShowAutofix, G.Logger.Opts.Autofix)
-}
-
-// Describef is used while Autofix.Custom is called to remember a description
-// of the actual fix for logging it later when Apply is called.
-// Describef may be called multiple times before calling Apply.
-func (fix *Autofix) Describef(lineno int, format string, args ...interface{}) {
- fix.actions = append(fix.actions, autofixAction{sprintf(format, args...), lineno})
-}
-
// InsertBefore prepends a line before the current line.
// The newline is added internally.
func (fix *Autofix) InsertBefore(text string) {
@@ -298,6 +261,44 @@
}
}
+// Custom runs a custom fix action, unless the fix is skipped anyway
+// because of the --only option.
+//
+// The fixer function must check whether it can actually fix something,
+// and if so, call Describef to describe the actual fix.
+//
+// If showAutofix and autofix are both false, the fix must only be
+// described by calling Describef. No observable modification must be done,
+// not even in memory.
+//
+// If showAutofix is true but autofix is false, the fix should be done in
+// memory as far as possible. For example, changing the text of Line.raw
+// is appropriate, but changing files in the file system is not.
+//
+// Only if autofix is true, fixes other than modifying the current Line
+// should be done persistently, such as changes to the file system.
+//
+// In any case, changes to the current Line will be written back to disk
+// by SaveAutofixChanges, after fixing all the lines in the file at once.
+func (fix *Autofix) Custom(fixer func(showAutofix, autofix bool)) {
+ // Contrary to the fixes that modify the line text, this one
+ // can be run even on dummy lines (like those standing for a
+ // file at whole), for example to fix the permissions of the file.
+
+ if fix.skip() {
+ return
+ }
+
+ fixer(G.Logger.Opts.ShowAutofix, G.Logger.Opts.Autofix)
+}
+
+// Describef is used while Autofix.Custom is called to remember a description
+// of the actual fix for logging it later when Apply is called.
+// Describef may be called multiple times before calling Apply.
+func (fix *Autofix) Describef(lineno int, format string, args ...interface{}) {
+ 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.
//
@@ -373,6 +374,21 @@
reset()
}
+func (fix *Autofix) setDiag(level *LogLevel, format string, args []interface{}) {
+ if G.Testing && format != SilentAutofixFormat {
+ assertf(
+ hasSuffix(format, "."),
+ "Autofix: format %q must end with a period.",
+ format)
+ }
+ assert(fix.level == nil) // Autofix can only have a single diagnostic.
+ assert(fix.diagFormat == "") // Autofix can only have a single diagnostic.
+
+ fix.level = level
+ fix.diagFormat = format
+ fix.diagArgs = args
+}
+
func (fix *Autofix) affectedLinenos() string {
if len(fix.actions) == 0 {
return fix.line.Linenos()
@@ -401,21 +417,6 @@
}
}
-func (fix *Autofix) setDiag(level *LogLevel, format string, args []interface{}) {
- if G.Testing && format != SilentAutofixFormat {
- assertf(
- hasSuffix(format, "."),
- "Autofix: format %q must end with a period.",
- format)
- }
- assert(fix.level == nil) // Autofix can only have a single diagnostic.
- assert(fix.diagFormat == "") // Autofix can only have a single diagnostic.
-
- fix.level = level
- fix.diagFormat = format
- fix.diagArgs = args
-}
-
// skip returns whether this autofix should be skipped because
// its message is matched by one of the --only command line options.
func (fix *Autofix) skip() bool {
@@ -452,6 +453,12 @@
return
}
+ if G.Testing {
+ abs := abspath(lines.Filename)
+ absTmp := abspath(filepath.ToSlash(os.TempDir()))
+ assertf(hasPrefix(abs, absTmp), "%q must be inside %q", abs, absTmp)
+ }
+
changes := make(map[string][]string)
changed := make(map[string]bool)
for _, line := range lines.Lines {
diff -r f9f1a3476cb0 -r bc450552c36d pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go Sat Nov 16 22:22:45 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go Sun Nov 17 01:26:25 2019 +0000
@@ -7,16 +7,6 @@
"strings"
)
-func (s *Suite) Test_Autofix_Warnf__duplicate(c *check.C) {
- t := s.Init(c)
-
- line := t.NewLine("DESCR", 1, "Description of the package")
-
- fix := line.Autofix()
- fix.Warnf("Warning 1.")
- t.ExpectAssert(func() { fix.Warnf("Warning 2.") })
-}
-
func (s *Suite) Test_Autofix__default_leaves_line_unchanged(c *check.C) {
t := s.Init(c)
@@ -81,318 +71,6 @@
t.CheckEquals(fix.modified, true)
}
-func (s *Suite) Test_Autofix_ReplaceAfter__autofix_in_continuation_line(c *check.C) {
- t := s.Init(c)
-
- t.SetUpCommandLine("--autofix", "--source")
- mklines := t.SetUpFileMkLines("Makefile",
- "# line 1 \\",
- "continuation 1 \\",
- "continuation 2")
-
- fix := mklines.lines.Lines[0].Autofix()
- fix.Warnf("Line should be replaced with Row.")
- fix.ReplaceAfter("", "line", "row")
- fix.Apply()
-
- t.CheckOutputLines(
- "AUTOFIX: ~/Makefile:1: Replacing \"line\" with \"row\".",
- "-\t# line 1 \\",
- "+\t# row 1 \\",
- "\tcontinuation 1 \\",
- "\tcontinuation 2")
-}
-
-func (s *Suite) Test_Autofix_ReplaceAfter__autofix_several_times_in_continuation_line(c *check.C) {
- t := s.Init(c)
-
- t.SetUpCommandLine("--autofix", "--source")
- mklines := t.SetUpFileMkLines("Makefile",
- "# line 1 \\",
- "continuation 1 \\",
- "continuation 2")
-
- fix := mklines.lines.Lines[0].Autofix()
- fix.Warnf("N should be replaced with V.")
- fix.ReplaceAfter("", "n", "v")
- fix.Apply()
-
- // Nothing is logged or fixed because the "n" appears more than once,
- // and as of June 2019, pkglint doesn't know which occurrence is the
- // correct one.
- t.CheckOutputEmpty()
-}
-
-func (s *Suite) Test_Autofix_ReplaceAfter__autofix_one_time(c *check.C) {
Home |
Main Index |
Thread Index |
Old Index