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.0



details:   https://anonhg.NetBSD.org/pkgsrc/rev/08f791ffd44c
branches:  trunk
changeset: 340357:08f791ffd44c
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue Oct 01 21:37:59 2019 +0000

description:
pkgtools/pkglint: update to 19.3.0

Changes since 5.7.24:

* There is no need to ask the dummy MAINTAINER from url2pkg whether
  committing changes is ok.

* When autofixing a condition like !empty(PKGPATH:Mliteral), don't
  generate unnecessary parentheses around ${PKGPATH} == literal.

* In a _VARGROUPS section, the public variables should be listed
  before the private variables, to put important things first.

* When pkglint suggests to be run again with the -e, -fs or -F options,
  repeat the whole command line, to allow for copy-and-paste.

* The checks for PKGPATH are fixed and enhanced. It is not a relative
  path like in ../../category/package, but relative to the pkgsrc root.

* Unintended file globbing in sed commands such as s,.*,any, gets a
  warning.

* MASTER_SITES should normally end with a slash, in rare cases an
  equals sign or a colon are correct, too.

* Detect redundant directories in INSTALLATION_DIRS.

diffstat:

 pkgtools/pkglint/Makefile                     |    5 +-
 pkgtools/pkglint/files/alternatives.go        |    2 +-
 pkgtools/pkglint/files/category.go            |    2 +-
 pkgtools/pkglint/files/check_test.go          |   16 +-
 pkgtools/pkglint/files/distinfo.go            |    8 +-
 pkgtools/pkglint/files/distinfo_test.go       |    4 +-
 pkgtools/pkglint/files/licenses_test.go       |   47 +-
 pkgtools/pkglint/files/logging.go             |   17 +-
 pkgtools/pkglint/files/logging_test.go        |   45 ++-
 pkgtools/pkglint/files/mkline.go              |  165 ++++++++---
 pkgtools/pkglint/files/mkline_test.go         |  103 +++++++-
 pkgtools/pkglint/files/mklinechecker.go       |   35 +-
 pkgtools/pkglint/files/mklinechecker_test.go  |   98 ++++--
 pkgtools/pkglint/files/mklines_test.go        |    1 +
 pkgtools/pkglint/files/mkparser.go            |   10 +-
 pkgtools/pkglint/files/mkparser_test.go       |   18 +
 pkgtools/pkglint/files/mktokenslexer.go       |    4 +-
 pkgtools/pkglint/files/mktokenslexer_test.go  |   57 ++-
 pkgtools/pkglint/files/mktypes_test.go        |    2 +-
 pkgtools/pkglint/files/package.go             |   14 +-
 pkgtools/pkglint/files/package_test.go        |   22 +-
 pkgtools/pkglint/files/pkglint.go             |    6 +-
 pkgtools/pkglint/files/pkglint_test.go        |   10 +-
 pkgtools/pkglint/files/pkgsrc.go              |   14 +-
 pkgtools/pkglint/files/pkgsrc_test.go         |   12 +-
 pkgtools/pkglint/files/shell.go               |   10 +-
 pkgtools/pkglint/files/shell_test.go          |   36 ++-
 pkgtools/pkglint/files/substcontext.go        |    2 +-
 pkgtools/pkglint/files/textproc/lexer.go      |    7 +
 pkgtools/pkglint/files/textproc/lexer_test.go |   10 +
 pkgtools/pkglint/files/tools_test.go          |    2 +-
 pkgtools/pkglint/files/toplevel.go            |    4 +-
 pkgtools/pkglint/files/toplevel_test.go       |   10 +-
 pkgtools/pkglint/files/util.go                |   28 +-
 pkgtools/pkglint/files/util_test.go           |   17 +-
 pkgtools/pkglint/files/vardefs.go             |  134 ++++----
 pkgtools/pkglint/files/vargroups.go           |   32 +-
 pkgtools/pkglint/files/vargroups_test.go      |   40 ++-
 pkgtools/pkglint/files/vartype.go             |   20 +-
 pkgtools/pkglint/files/vartypecheck.go        |  205 ++++++++++++--
 pkgtools/pkglint/files/vartypecheck_test.go   |  359 +++++++++++++++++--------
 41 files changed, 1156 insertions(+), 477 deletions(-)

diffs (truncated from 3669 to 300 lines):

diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/Makefile Tue Oct 01 21:37:59 2019 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.598 2019/09/26 20:10:51 bsiegert Exp $
+# $NetBSD: Makefile,v 1.599 2019/10/01 21:37:59 rillig Exp $
 
-PKGNAME=       pkglint-5.7.24
-PKGREVISION=   1
+PKGNAME=       pkglint-19.3.0
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/files/alternatives.go
--- a/pkgtools/pkglint/files/alternatives.go    Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/files/alternatives.go    Tue Oct 01 21:37:59 2019 +0000
@@ -49,7 +49,7 @@
                if !m {
                        line.Errorf("Invalid line %q.", line.Text)
                        line.Explain(
-                               sprintf("Run %q for more information.", makeHelp("alternatives")))
+                               sprintf("Run %q for more information.", bmakeHelp("alternatives")))
                        continue
                }
 
diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/files/category.go        Tue Oct 01 21:37:59 2019 +0000
@@ -158,7 +158,7 @@
                var recurseInto []string
                for _, msub := range mSubdirs {
                        if !msub.line.IsCommentedVarassign() {
-                               recurseInto = append(recurseInto, dir+"/"+msub.name)
+                               recurseInto = append(recurseInto, joinPath(dir, msub.name))
                        }
                }
                G.Todo = append(recurseInto, G.Todo...)
diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Tue Oct 01 21:37:59 2019 +0000
@@ -125,6 +125,7 @@
 type Tester struct {
        c        *check.C // Only usable during the test method itself
        testName string
+       argv     []string // from the last invocation of Tester.SetUpCommandLine
 
        stdout  bytes.Buffer
        stderr  bytes.Buffer
@@ -149,7 +150,9 @@
        prevTracing := trace.Tracing
        defer func() { trace.Tracing = prevTracing }()
 
-       exitcode := G.ParseCommandLine(append([]string{"pkglint"}, args...))
+       argv := append([]string{"pkglint"}, args...)
+       t.argv = argv
+       exitcode := G.ParseCommandLine(argv)
        if exitcode != -1 && exitcode != 0 {
                t.CheckOutputEmpty()
                t.c.Fatalf("Cannot parse command line: %#v", args)
@@ -516,7 +519,7 @@
        if t.relCwd != "" {
                return path.Clean(relativeFileName)
        }
-       return path.Clean(t.tmpdir + "/" + relativeFileName)
+       return path.Clean(joinPath(t.tmpdir, relativeFileName))
 }
 
 // Copy copies a file inside the temporary directory.
@@ -1155,3 +1158,12 @@
 // development.
 func (t *Tester) Use(functions ...interface{}) {
 }
+
+func (t *Tester) Shquote(format string, rels ...string) string {
+       var subs []interface{}
+       for _, rel := range rels {
+               quoted := shquote(path.Join(t.tmpdir, rel))
+               subs = append(subs, strings.Replace(quoted, t.tmpdir, "~", -1))
+       }
+       return sprintf(format, subs...)
+}
diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Tue Oct 01 21:37:59 2019 +0000
@@ -67,7 +67,7 @@
                        return no
                case ck.pkg == nil:
                        return unknown
-               case fileExists(ck.pkg.File(ck.patchdir + "/" + prevFilename)):
+               case fileExists(ck.pkg.File(joinPath(ck.patchdir, prevFilename))):
                        return yes
                default:
                        return no
@@ -195,7 +195,7 @@
 
        distdir := G.Pkgsrc.File("distfiles")
 
-       distfile := cleanpath(distdir + "/" + info.filename())
+       distfile := cleanpath(joinPath(distdir, info.filename()))
        if !fileExists(distfile) {
 
                // It's a rare situation that the explanation is generated
@@ -315,7 +315,7 @@
                if file.Mode().IsRegular() && ck.infos[patchName].isPatch != yes && hasPrefix(patchName, "patch-") {
                        line := NewLineWhole(ck.lines.Filename)
                        line.Errorf("Patch %q is not recorded. Run %q.",
-                               line.PathToFile(ck.pkg.File(ck.patchdir+"/"+patchName)),
+                               line.PathToFile(ck.pkg.File(joinPath(ck.patchdir, patchName))),
                                bmake("makepatchsum"))
                }
        }
@@ -371,7 +371,7 @@
        hash := info.hash
        line := info.line
 
-       patchFileName := ck.patchdir + "/" + patchName
+       patchFileName := joinPath(ck.patchdir, patchName)
        resolvedPatchFileName := ck.pkg.File(patchFileName)
        if ck.distinfoIsCommitted && !isCommitted(resolvedPatchFileName) {
                line.Warnf("%s is registered in distinfo but not added to CVS.", line.PathToFile(resolvedPatchFileName))
diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go   Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go   Tue Oct 01 21:37:59 2019 +0000
@@ -177,7 +177,7 @@
                "",
                ".include \"../mk/misc/category.mk\"")
 
-       t.Main("-r", "-Wall", "-Call", t.File("."))
+       t.Main("-r", "-Wall", "-Call", ".")
 
        t.CheckOutputLines(
                "ERROR: ~/category/package1/distinfo:3: "+
@@ -201,7 +201,7 @@
 
                "WARN: ~/licenses/gnu-gpl-v2: This license seems to be unused.",
                "8 errors and 1 warning found.",
-               "(Run \"pkglint -e\" to show explanations.)")
+               t.Shquote("(Run \"pkglint -e -r -Wall -Call %s\" to show explanations.)", "."))
 
        // Ensure that hex.DecodeString does not waste memory here.
        t.CheckEquals(len(G.InterPackage.hashes["SHA512:distfile-1.0.tar.gz"].hash), 8)
diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/files/licenses_test.go
--- a/pkgtools/pkglint/files/licenses_test.go   Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/files/licenses_test.go   Tue Oct 01 21:37:59 2019 +0000
@@ -9,39 +9,38 @@
 
        t.CreateFileLines("licenses/gnu-gpl-v2",
                "The licenses for most software are designed to take away ...")
-       mkline := t.NewMkLine("Makefile", 7, "LICENSE=dummy")
 
-       licenseChecker := LicenseChecker{nil, mkline}
-       licenseChecker.Check("gpl-v2", opAssign)
+       test := func(licenseValue string, diagnostics ...string) {
+               mklines := t.NewMkLines("Makefile",
+                       "LICENSE=\t"+licenseValue)
 
-       t.CheckOutputLines(
-               "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.")
-
-       licenseChecker.Check("no-profit shareware", opAssign)
+               mklines.ForEach(func(mkline *MkLine) {
+                       (&LicenseChecker{mklines, mkline}).Check(mkline.Value(), opAssign)
+               })
 
-       t.CheckOutputLines(
-               "ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".")
+               t.CheckOutput(diagnostics)
+       }
 
-       licenseChecker.Check("no-profit AND shareware", opAssign)
+       test("gpl-v2",
+               "WARN: Makefile:1: License file ~/licenses/gpl-v2 does not exist.")
 
-       t.CheckOutputLines(
-               "WARN: Makefile:7: License file ~/licenses/no-profit does not exist.",
-               "ERROR: Makefile:7: License \"no-profit\" must not be used.",
-               "WARN: Makefile:7: License file ~/licenses/shareware does not exist.",
-               "ERROR: Makefile:7: License \"shareware\" must not be used.")
+       test("no-profit shareware",
+               "ERROR: Makefile:1: Parse error for license condition \"no-profit shareware\".")
 
-       licenseChecker.Check("gnu-gpl-v2", opAssign)
+       test("no-profit AND shareware",
+               "WARN: Makefile:1: License file ~/licenses/no-profit does not exist.",
+               "ERROR: Makefile:1: License \"no-profit\" must not be used.",
+               "WARN: Makefile:1: License file ~/licenses/shareware does not exist.",
+               "ERROR: Makefile:1: License \"shareware\" must not be used.")
 
-       t.CheckOutputEmpty()
-
-       licenseChecker.Check("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", opAssign)
+       test("gnu-gpl-v2",
+               nil...)
 
-       t.CheckOutputLines(
-               "ERROR: Makefile:7: AND and OR operators in license conditions can only be combined using parentheses.")
+       test("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2",
+               "ERROR: Makefile:1: AND and OR operators in license conditions can only be combined using parentheses.")
 
-       licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign)
-
-       t.CheckOutputEmpty()
+       test("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2",
+               nil...)
 }
 
 func (s *Suite) Test_LicenseChecker_checkName__LICENSE_FILE(c *check.C) {
diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/files/logging.go
--- a/pkgtools/pkglint/files/logging.go Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/files/logging.go Tue Oct 01 21:37:59 2019 +0000
@@ -6,6 +6,7 @@
        "netbsd.org/pkglint/histogram"
        "netbsd.org/pkglint/textproc"
        "path"
+       "strings"
 )
 
 type Logger struct {
@@ -118,7 +119,7 @@
        l.out.WriteLine("")
 }
 
-func (l *Logger) ShowSummary() {
+func (l *Logger) ShowSummary(args []string) {
        if l.Opts.Quiet || l.Opts.Autofix {
                return
        }
@@ -147,14 +148,22 @@
                l.out.WriteLine("Looks fine.")
        }
 
+       commandLine := func(arg string) string {
+               argv := append([]string{args[0], arg}, args[1:]...)
+               for i := range argv {
+                       argv[i] = shquote(argv[i])
+               }
+               return strings.Join(argv, " ")
+       }
+
        if l.explanationsAvailable && !l.Opts.Explain {
-               l.out.WriteLine("(Run \"pkglint -e\" to show explanations.)")
+               l.out.WriteLine(sprintf("(Run \"%s\" to show explanations.)", commandLine("-e")))
        }
        if l.autofixAvailable {
                if !l.Opts.ShowAutofix {
-                       l.out.WriteLine("(Run \"pkglint -fs\" to show what can be fixed automatically.)")
+                       l.out.WriteLine(sprintf("(Run \"%s\" to show what can be fixed automatically.)", commandLine("-fs")))
                }
-               l.out.WriteLine("(Run \"pkglint -F\" to automatically fix some issues.)")
+               l.out.WriteLine(sprintf("(Run \"%s\" to automatically fix some issues.)", commandLine("-F")))
        }
 }
 
diff -r fb864bcaf36d -r 08f791ffd44c pkgtools/pkglint/files/logging_test.go
--- a/pkgtools/pkglint/files/logging_test.go    Tue Oct 01 21:30:04 2019 +0000
+++ b/pkgtools/pkglint/files/logging_test.go    Tue Oct 01 21:37:59 2019 +0000
@@ -591,7 +591,7 @@
        // Neither the warning nor the corresponding explanation are logged.
        line.Warnf("Filtered warning.")
        line.Explain("Explanation for the above warning.")
-       G.Logger.ShowSummary()
+       G.Logger.ShowSummary(t.argv)
 
        // Since the above warning is filtered out by the --only option,
        // adding --explain to the options would not show any explanation.
@@ -603,13 +603,13 @@
 
        line.Warnf("This warning is interesting.")
        line.Explain("This explanation is available.")
-       G.Logger.ShowSummary()
+       G.Logger.ShowSummary(t.argv)
 
        t.CheckEquals(G.Logger.explanationsAvailable, true)
        t.CheckOutputLines(
                "WARN: Makefile:27: This warning is interesting.",
                "1 warning found.",
-               "(Run \"pkglint -e\" to show explanations.)")
+               "(Run \"pkglint -e --only interesting\" to show explanations.)")
 }
 
 func (s *Suite) Test_Logger_ShowSummary__looks_fine(c *check.C) {
@@ -617,7 +617,7 @@
 
        logger := Logger{out: NewSeparatorWriter(&t.stdout)}
 
-       logger.ShowSummary()
+       logger.ShowSummary([]string{"pkglint"})
 
        t.CheckOutputLines(
                "Looks fine.")
@@ -630,7 +630,7 @@
        logger.Logf(Error, "", "", ".", ".")
        logger.Logf(Warn, "", "", ".", ".")
 
-       logger.ShowSummary()
+       logger.ShowSummary([]string{"pkglint"})
 
        t.CheckOutputLines(
                "ERROR: .",
@@ -648,7 +648,7 @@



Home | Main Index | Thread Index | Old Index