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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/4024e566cf03
branches:  trunk
changeset: 405149:4024e566cf03
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Nov 23 23:35:55 2019 +0000

description:
pkgtools/pkglint: update to 19.3.10

Changes since 19.3.9:

In diagnostics for suggested package updates, the exact line of doc/TODO
is mentioned. If a suggested update has an additional comment, the
brackets around that comment are not output anymore.

The check for defined but not used variables has been improved for the
edge case of defining a variable in the package Makefile and using it
in the buildlink3.mk file of the same package, which just doesn't work.

Makefile fragments in patches/ directories are now completely ignored.
It was a hypothetical case anyway.

Comparing PKGSRC_COMPILER using the == or != operators is now considered
an error instead of a warning. The common cases can be autofixed.

diffstat:

 pkgtools/pkglint/Makefile                     |    4 +-
 pkgtools/pkglint/PLIST                        |    4 +-
 pkgtools/pkglint/files/alternatives.go        |   10 +-
 pkgtools/pkglint/files/autofix.go             |   14 +-
 pkgtools/pkglint/files/autofix_test.go        |    8 +-
 pkgtools/pkglint/files/buildlink3.go          |    7 +-
 pkgtools/pkglint/files/buildlink3_test.go     |    2 +-
 pkgtools/pkglint/files/category.go            |   22 +-
 pkgtools/pkglint/files/category_test.go       |    4 +-
 pkgtools/pkglint/files/check_test.go          |  143 +++---
 pkgtools/pkglint/files/distinfo.go            |   53 +-
 pkgtools/pkglint/files/files.go               |   17 +-
 pkgtools/pkglint/files/fuzzer_test.go         |    3 +-
 pkgtools/pkglint/files/licenses.go            |    8 +-
 pkgtools/pkglint/files/licenses_test.go       |    2 +-
 pkgtools/pkglint/files/line.go                |   27 +-
 pkgtools/pkglint/files/linelexer.go           |   50 +-
 pkgtools/pkglint/files/lines.go               |    9 +-
 pkgtools/pkglint/files/logging.go             |    9 +-
 pkgtools/pkglint/files/mkline.go              |   88 ++--
 pkgtools/pkglint/files/mkline_test.go         |   68 +-
 pkgtools/pkglint/files/mklinechecker.go       |   80 ++-
 pkgtools/pkglint/files/mklinechecker_test.go  |   74 +++-
 pkgtools/pkglint/files/mklineparser.go        |    2 +-
 pkgtools/pkglint/files/mklineparser_test.go   |    4 +-
 pkgtools/pkglint/files/mklines.go             |    6 +-
 pkgtools/pkglint/files/mklines_test.go        |    4 +-
 pkgtools/pkglint/files/mkparser.go            |    2 +
 pkgtools/pkglint/files/package.go             |  245 ++++++-----
 pkgtools/pkglint/files/package_test.go        |  122 ++++-
 pkgtools/pkglint/files/patches.go             |    2 +-
 pkgtools/pkglint/files/path.go                |  162 +++++++
 pkgtools/pkglint/files/path_test.go           |  535 ++++++++++++++++++++++++++
 pkgtools/pkglint/files/pkglint.go             |   95 ++--
 pkgtools/pkglint/files/pkglint_test.go        |   18 +-
 pkgtools/pkglint/files/pkgsrc.go              |  129 +++---
 pkgtools/pkglint/files/pkgsrc_test.go         |   48 +-
 pkgtools/pkglint/files/plist.go               |   27 +-
 pkgtools/pkglint/files/redundantscope.go      |    8 +-
 pkgtools/pkglint/files/redundantscope_test.go |    4 +-
 pkgtools/pkglint/files/shell.go               |    4 +-
 pkgtools/pkglint/files/shell_test.go          |    5 +-
 pkgtools/pkglint/files/shtokenizer.go         |    1 +
 pkgtools/pkglint/files/testnames_test.go      |    1 +
 pkgtools/pkglint/files/textproc/lexer.go      |    2 +-
 pkgtools/pkglint/files/tools.go               |    2 +-
 pkgtools/pkglint/files/tools_test.go          |    2 +-
 pkgtools/pkglint/files/toplevel.go            |   14 +-
 pkgtools/pkglint/files/trace/tracing.go       |    4 +-
 pkgtools/pkglint/files/util.go                |  123 ++---
 pkgtools/pkglint/files/util_test.go           |   52 +-
 pkgtools/pkglint/files/vardefs.go             |   17 +-
 pkgtools/pkglint/files/vardefs_test.go        |    2 +-
 pkgtools/pkglint/files/vartypecheck.go        |   21 +-
 pkgtools/pkglint/files/vartypecheck_test.go   |    6 +-
 55 files changed, 1615 insertions(+), 760 deletions(-)

diffs (truncated from 5457 to 300 lines):

diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/Makefile Sat Nov 23 23:35:55 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.609 2019/11/19 06:51:38 rillig Exp $
+# $NetBSD: Makefile,v 1.610 2019/11/23 23:35:55 rillig Exp $
 
-PKGNAME=       pkglint-19.3.9
+PKGNAME=       pkglint-19.3.10
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/PLIST
--- a/pkgtools/pkglint/PLIST    Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/PLIST    Sat Nov 23 23:35:55 2019 +0000
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.16 2019/11/17 01:26:25 rillig Exp $
+@comment $NetBSD: PLIST,v 1.17 2019/11/23 23:35:55 rillig Exp $
 bin/pkglint
 gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint.a
 gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint/getopt.a
@@ -77,6 +77,8 @@
 gopkg/src/netbsd.org/pkglint/paragraph_test.go
 gopkg/src/netbsd.org/pkglint/patches.go
 gopkg/src/netbsd.org/pkglint/patches_test.go
+gopkg/src/netbsd.org/pkglint/path.go
+gopkg/src/netbsd.org/pkglint/path_test.go
 gopkg/src/netbsd.org/pkglint/pkglint.0
 gopkg/src/netbsd.org/pkglint/pkglint.1
 gopkg/src/netbsd.org/pkglint/pkglint.go
diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/files/alternatives.go
--- a/pkgtools/pkglint/files/alternatives.go    Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/files/alternatives.go    Sat Nov 23 23:35:55 2019 +0000
@@ -5,7 +5,7 @@
        "strings"
 )
 
-func CheckFileAlternatives(filename string) {
+func CheckFileAlternatives(filename Path) {
        lines := Load(filename, NotEmpty|LogErrors)
        if lines == nil {
                return
@@ -16,7 +16,7 @@
                plist = G.Pkg.Plist
        }
 
-       checkPlistWrapper := func(line *Line, wrapper string) {
+       checkPlistWrapper := func(line *Line, wrapper Path) {
                if plist.Files[wrapper] != nil {
                        line.Errorf("Alternative wrapper %q must not appear in the PLIST.", wrapper)
                }
@@ -25,10 +25,10 @@
        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.IsDefined("ALTERNATIVES_SRC") {
+               if plist.Files[NewPath(plistName)] != nil || G.Pkg.vars.IsDefined("ALTERNATIVES_SRC") {
                        return
                }
-               if plist.Files[strings.Replace(plistName, "${PKGMANDIR}", "man", 1)] != nil {
+               if plist.Files[NewPath(strings.Replace(plistName, "${PKGMANDIR}", "man", 1))] != nil {
                        return
                }
 
@@ -57,7 +57,7 @@
                }
 
                if plist.Files != nil {
-                       checkPlistWrapper(line, wrapper)
+                       checkPlistWrapper(line, NewPath(wrapper))
                        checkPlistAlternative(line, alternative)
                }
 
diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/files/autofix.go Sat Nov 23 23:35:55 2019 +0000
@@ -1,10 +1,8 @@
 package pkglint
 
 import (
-       "io/ioutil"
        "netbsd.org/pkglint/regex"
        "os"
-       "path/filepath"
        "strconv"
        "strings"
 )
@@ -455,12 +453,12 @@
 
        if G.Testing {
                abs := abspath(lines.Filename)
-               absTmp := abspath(filepath.ToSlash(os.TempDir()))
-               assertf(hasPrefix(abs, absTmp), "%q must be inside %q", abs, absTmp)
+               absTmp := abspath(NewPathSlash(os.TempDir()))
+               assertf(abs.HasPrefixPath(absTmp), "%q must be inside %q", abs, absTmp)
        }
 
-       changes := make(map[string][]string)
-       changed := make(map[string]bool)
+       changes := make(map[Path][]string)
+       changed := make(map[Path]bool)
        for _, line := range lines.Lines {
                chlines := changes[line.Filename]
                if fix := line.autofix; fix != nil {
@@ -488,12 +486,12 @@
                for _, changedLine := range changedLines {
                        text.WriteString(changedLine)
                }
-               err := ioutil.WriteFile(tmpName, []byte(text.String()), 0666)
+               err := tmpName.WriteString(text.String())
                if err != nil {
                        G.Logger.Errorf(tmpName, "Cannot write: %s", err)
                        continue
                }
-               err = os.Rename(tmpName, filename)
+               err = tmpName.Rename(filename)
                if err != nil {
                        G.Logger.Errorf(tmpName, "Cannot overwrite with autofixed content: %s", err)
                        continue
diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go    Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go    Sat Nov 23 23:35:55 2019 +0000
@@ -1282,7 +1282,7 @@
        t.SetUpCommandLine("--autofix")
        lines := t.SetUpFileLines("subdir/file.txt",
                "line 1")
-       _ = os.RemoveAll(t.File("subdir"))
+       _ = os.RemoveAll(t.File("subdir").String())
 
        fix := lines.Lines[0].Autofix()
        fix.Warnf("Should start with an uppercase letter.")
@@ -1308,7 +1308,7 @@
                "line 1")
 
        // As long as the file is kept open, it cannot be overwritten or deleted.
-       openFile, err := os.OpenFile(t.File("subdir/file.txt"), 0, 0666)
+       openFile, err := os.OpenFile(t.File("subdir/file.txt").String(), 0, 0666) // TODO: replace with Path.Open
        defer func() { assertNil(openFile.Close(), "") }()
        c.Check(err, check.IsNil)
 
@@ -1336,8 +1336,8 @@
        lines := t.SetUpFileLines("file.txt",
                "line 1")
 
-       c.Check(os.RemoveAll(t.File("file.txt")), check.IsNil)
-       c.Check(os.MkdirAll(t.File("file.txt"), 0777), check.IsNil)
+       c.Check(os.RemoveAll(t.File("file.txt").String()), check.IsNil)
+       c.Check(os.MkdirAll(t.File("file.txt").String(), 0777), check.IsNil)
 
        fix := lines.Lines[0].Autofix()
        fix.Warnf("Should start with an uppercase letter.")
diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go      Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go      Sat Nov 23 23:35:55 2019 +0000
@@ -2,7 +2,6 @@
 
 import (
        "netbsd.org/pkglint/pkgver"
-       "path"
        "strings"
 )
 
@@ -21,7 +20,7 @@
 func (ck *Buildlink3Checker) Check() {
        mklines := ck.mklines
        if trace.Tracing {
-               defer trace.Call1(mklines.lines.Filename)()
+               defer trace.Call(mklines.lines.Filename)()
        }
 
        mklines.Check()
@@ -40,7 +39,7 @@
 
        if llex.SkipRegexp(`^BUILDLINK_DEPMETHOD\.([^\t ]+)\?=.*$`) {
                llex.PreviousLine().Warnf("This line belongs inside the .ifdef block.")
-               for llex.SkipString("") {
+               for llex.SkipText("") {
                }
        }
 
@@ -100,7 +99,7 @@
                return
        }
 
-       base, name := trimCommon(pkgbase, path.Base(path.Dir(mkline.Filename)))
+       base, name := trimCommon(pkgbase, mkline.Filename.Dir().Base())
        if base == "" && matches(name, `^(\d*|-cvs|-fossil|-git|-hg|-svn|-devel|-snapshot)$`) {
                return
        }
diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Sat Nov 23 23:35:55 2019 +0000
@@ -599,7 +599,7 @@
 
        G.InterPackage.Enable()
 
-       test := func(pkgbase, pkgpath string, diagnostics ...string) {
+       test := func(pkgbase string, pkgpath Path, diagnostics ...string) {
                mkline := t.NewMkLine(t.File(pkgpath+"/buildlink3.mk"), 123, "")
 
                (*Buildlink3Checker).checkUniquePkgbase(nil, pkgbase, mkline)
diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/files/category.go        Sat Nov 23 23:35:55 2019 +0000
@@ -6,12 +6,12 @@
        "strings"
 )
 
-func CheckdirCategory(dir string) {
+func CheckdirCategory(dir Path) {
        if trace.Tracing {
-               defer trace.Call1(dir)()
+               defer trace.Call(dir)()
        }
 
-       mklines := LoadMk(dir+"/Makefile", NotEmpty|LogErrors)
+       mklines := LoadMk(dir.JoinNoClean("Makefile"), NotEmpty|LogErrors) // TODO: Remove the "./" here already
        if mklines == nil {
                return
        }
@@ -49,7 +49,7 @@
        mlex.SkipEmptyOrNote()
 
        type subdir struct {
-               name string
+               name Path
                line *MkLine
        }
 
@@ -67,7 +67,7 @@
                if (mkline.IsVarassignMaybeCommented()) && mkline.Varname() == "SUBDIR" {
                        mlex.Skip()
 
-                       name := mkline.Value()
+                       name := mkline.Value() // TODO: Maybe NewPath here already
                        if mkline.IsCommentedVarassign() && !mkline.HasComment() {
                                mkline.Warnf("%q commented out without giving a reason.", name)
                        }
@@ -78,12 +78,12 @@
                        seen[name] = mkline
 
                        if len(mSubdirs) > 0 {
-                               if prev := mSubdirs[len(mSubdirs)-1].name; name < prev {
+                               if prev := mSubdirs[len(mSubdirs)-1].name; name < prev.String() {
                                        mkline.Warnf("%q should come before %q.", name, prev)
                                }
                        }
 
-                       mSubdirs = append(mSubdirs, subdir{name, mkline})
+                       mSubdirs = append(mSubdirs, subdir{NewPath(name), mkline})
 
                } else {
                        if !mkline.IsEmpty() {
@@ -96,8 +96,8 @@
        // To prevent unnecessary warnings about subdirectories that are
        // in one list but not in the other, generate the sets of
        // subdirs of each list.
-       fCheck := make(map[string]bool)
-       mCheck := make(map[string]bool)
+       fCheck := make(map[Path]bool)
+       mCheck := make(map[Path]bool)
        for _, fsub := range fSubdirs {
                fCheck[fsub] = true
        }
@@ -122,7 +122,7 @@
 
                                fix := line.Autofix()
                                fix.Errorf("%q exists in the file system but not in the Makefile.", fCurrent)
-                               fix.InsertBefore("SUBDIR+=\t" + fCurrent)
+                               fix.InsertBefore("SUBDIR+=\t" + fCurrent.String())
                                fix.Apply()
                        }
                        fRest = fRest[1:]
@@ -155,7 +155,7 @@
        mklines.SaveAutofixChanges()
 
        if G.Opts.Recursive {
-               var recurseInto []string
+               var recurseInto []Path
                for _, msub := range mSubdirs {
                        if !msub.line.IsCommentedVarassign() {
                                recurseInto = append(recurseInto, joinPath(dir, msub.name))
diff -r 85d8d4c839eb -r 4024e566cf03 pkgtools/pkglint/files/category_test.go
--- a/pkgtools/pkglint/files/category_test.go   Sat Nov 23 23:33:56 2019 +0000
+++ b/pkgtools/pkglint/files/category_test.go   Sat Nov 23 23:35:55 2019 +0000
@@ -208,12 +208,12 @@
        // It is only removed in Pkglint.Main, therefore it stays there even
        // after the call to CheckdirCategory. This is a bit unrealistic,
        // but close enough for this test.
-       t.CheckDeepEquals(G.Todo.entries, []string{"."})
+       t.CheckDeepEquals(G.Todo.entries, []Path{"."})
 
        CheckdirCategory(".")
 
        t.CheckOutputEmpty()
-       t.CheckDeepEquals(G.Todo.entries, []string{"./package", "."})
+       t.CheckDeepEquals(G.Todo.entries, []Path{"./package", "."})
 }
 
 // Ensures that a directory in the file system can be added at the very



Home | Main Index | Thread Index | Old Index