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 5.7.5



details:   https://anonhg.NetBSD.org/pkgsrc/rev/a77cddf4320d
branches:  trunk
changeset: 322503:a77cddf4320d
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Apr 20 17:43:24 2019 +0000

description:
pkgtools/pkglint: update to 5.7.5

Changes since 5.7.4:

* Warn about invalid variable uses in directives like
  .if and .for

* Do not warn when a package-settable variable is assigned using the ?=
  operator before including bsd.prefs.mk. This warning only makes sense
  for user-settable and system-provided variables.

* The parser for variable uses like ${VAR:@v@${v:Q}} is more robust now,
  which reduces the number of parse errors and leads to more appropriate
  diagnostics, in cases like ${URL:Mftp://*}, which should really be
  ${URL:Mftp\://*}.

* The valid values for OPSYS are now determined by the files in
  mk/platform instead of allowing arbitrary identifiers. This catches a
  few instances where "Solaris" is used instead of the correct "SunOS".

* Setting USE_LANGUAGES only has an effect if mk/compiler.mk has not yet
  been included. In all other cases, pkglint warns now.

* Missing entries in doc/CHANGES produce a note now. This will lead to
  more accurate statistics for the release notes.

diffstat:

 pkgtools/pkglint/Makefile                       |    5 +-
 pkgtools/pkglint/files/alternatives.go          |    2 +-
 pkgtools/pkglint/files/alternatives_test.go     |    3 +-
 pkgtools/pkglint/files/autofix.go               |   11 +-
 pkgtools/pkglint/files/autofix_test.go          |    4 +-
 pkgtools/pkglint/files/buildlink3.go            |    2 +-
 pkgtools/pkglint/files/buildlink3_test.go       |   16 +
 pkgtools/pkglint/files/category.go              |   14 +-
 pkgtools/pkglint/files/category_test.go         |   10 +
 pkgtools/pkglint/files/check_test.go            |   72 ++-
 pkgtools/pkglint/files/distinfo.go              |    2 +-
 pkgtools/pkglint/files/distinfo_test.go         |   25 +-
 pkgtools/pkglint/files/files_test.go            |   16 +
 pkgtools/pkglint/files/licenses.go              |    4 +-
 pkgtools/pkglint/files/licenses_test.go         |    2 +-
 pkgtools/pkglint/files/linechecker.go           |    2 +-
 pkgtools/pkglint/files/linelexer.go             |    2 +
 pkgtools/pkglint/files/lines_test.go            |    1 +
 pkgtools/pkglint/files/logging_test.go          |   18 +-
 pkgtools/pkglint/files/mkline.go                |  322 +++++++-----
 pkgtools/pkglint/files/mkline_test.go           |  599 +++++++++++++----------
 pkgtools/pkglint/files/mklinechecker.go         |   81 +-
 pkgtools/pkglint/files/mklinechecker_test.go    |  202 +++----
 pkgtools/pkglint/files/mklines.go               |    7 +-
 pkgtools/pkglint/files/mklines_test.go          |    6 +-
 pkgtools/pkglint/files/mklines_varalign_test.go |   28 +-
 pkgtools/pkglint/files/mkparser.go              |  250 +++++----
 pkgtools/pkglint/files/mkparser_test.go         |  201 +++++--
 pkgtools/pkglint/files/mkshwalker.go            |   18 +-
 pkgtools/pkglint/files/mkshwalker_test.go       |  322 +++++++-----
 pkgtools/pkglint/files/mktypes.go               |   44 +-
 pkgtools/pkglint/files/mktypes_test.go          |   30 +-
 pkgtools/pkglint/files/options.go               |  228 +++++---
 pkgtools/pkglint/files/options_test.go          |   31 +
 pkgtools/pkglint/files/package.go               |   88 +++-
 pkgtools/pkglint/files/package_test.go          |  143 ++++-
 pkgtools/pkglint/files/patches.go               |    6 +-
 pkgtools/pkglint/files/pkglint.go               |    5 +-
 pkgtools/pkglint/files/pkglint_test.go          |   60 +-
 pkgtools/pkglint/files/pkgsrc.go                |   36 +-
 pkgtools/pkglint/files/pkgsrc_test.go           |   40 +-
 pkgtools/pkglint/files/plist.go                 |   23 +-
 pkgtools/pkglint/files/plist_test.go            |    2 +-
 pkgtools/pkglint/files/redundantscope.go        |    2 +-
 pkgtools/pkglint/files/redundantscope_test.go   |    5 +-
 pkgtools/pkglint/files/shell.go                 |  168 +++---
 pkgtools/pkglint/files/shell_test.go            |    7 +-
 pkgtools/pkglint/files/shtokenizer.go           |   49 +-
 pkgtools/pkglint/files/shtokenizer_test.go      |  204 ++++---
 pkgtools/pkglint/files/shtypes.go               |    3 +-
 pkgtools/pkglint/files/substcontext.go          |    2 +-
 pkgtools/pkglint/files/substcontext_test.go     |    1 +
 pkgtools/pkglint/files/testnames_test.go        |    1 +
 pkgtools/pkglint/files/tools_test.go            |   19 +-
 pkgtools/pkglint/files/trace/tracing.go         |   12 +-
 pkgtools/pkglint/files/util.go                  |    8 +-
 pkgtools/pkglint/files/util_test.go             |    9 +
 pkgtools/pkglint/files/vardefs.go               |  141 ++++-
 pkgtools/pkglint/files/vardefs_test.go          |   31 +-
 pkgtools/pkglint/files/vartype.go               |   79 ++-
 pkgtools/pkglint/files/vartype_test.go          |   21 +-
 pkgtools/pkglint/files/vartypecheck.go          |   72 +-
 pkgtools/pkglint/files/vartypecheck_test.go     |   28 +-
 63 files changed, 2375 insertions(+), 1470 deletions(-)

diffs (truncated from 8415 to 300 lines):

diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/Makefile Sat Apr 20 17:43:24 2019 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.574 2019/04/16 18:41:18 bsiegert Exp $
+# $NetBSD: Makefile,v 1.575 2019/04/20 17:43:24 rillig Exp $
 
-PKGNAME=       pkglint-5.7.4
-PKGREVISION=   1
+PKGNAME=       pkglint-5.7.5
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/files/alternatives.go
--- a/pkgtools/pkglint/files/alternatives.go    Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/files/alternatives.go    Sat Apr 20 17:43:24 2019 +0000
@@ -48,7 +48,7 @@
                m, wrapper, space, alternative := match3(line.Text, `^([^\t ]+)([ \t]+)([^\t ]+)`)
                if !m {
                        line.Errorf("Invalid line %q.", line.Text)
-                       G.Explain(
+                       line.Explain(
                                sprintf("Run %q for more information.", makeHelp("alternatives")))
                        continue
                }
diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/files/alternatives_test.go
--- a/pkgtools/pkglint/files/alternatives_test.go       Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/files/alternatives_test.go       Sat Apr 20 17:43:24 2019 +0000
@@ -21,6 +21,7 @@
                "bin/echo",
                "bin/vim",
                "sbin/sendmail.exim${EXIMVER}")
+       t.FinishSetUp()
 
        G.Check(".")
 
@@ -73,7 +74,7 @@
        t.CreateFileLines("category/package/ALTERNATIVES",
                "bin/pgm @PREFIX@/bin/gnu-program",
                "bin/pgm @PREFIX@/bin/nb-program")
-       G.Pkgsrc.LoadInfrastructure()
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/files/autofix.go Sat Apr 20 17:43:24 2019 +0000
@@ -299,7 +299,7 @@
                        line.showSource(G.out)
                }
                if logDiagnostic && len(fix.explanation) > 0 {
-                       G.Explain(fix.explanation...)
+                       line.Explain(fix.explanation...)
                }
                if G.Logger.Opts.ShowSource {
                        if !(G.Logger.Opts.Explain && logDiagnostic && len(fix.explanation) > 0) {
@@ -330,7 +330,8 @@
        {
                // Parsing the continuation marker as variable value is cheating but works well.
                text := strings.TrimSuffix(mkline.raw[0].orignl, "\n")
-               _, a := MatchVarassign(text)
+               data := MkLineParser{}.split(nil, text)
+               _, a := MkLineParser{}.MatchVarassign(mkline.Line, text, data)
                if a.value != "\\" {
                        oldWidth = tabWidth(a.valueAlign)
                }
@@ -448,11 +449,11 @@
                G.fileCache.Evict(filename)
                changedLines := changes[filename]
                tmpName := filename + ".pkglint.tmp"
-               text := ""
+               var text strings.Builder
                for _, changedLine := range changedLines {
-                       text += changedLine
+                       text.WriteString(changedLine)
                }
-               err := ioutil.WriteFile(tmpName, []byte(text), 0666)
+               err := ioutil.WriteFile(tmpName, []byte(text.String()), 0666)
                if err != nil {
                        G.Logf(Error, tmpName, "", "Cannot write: %s", "Cannot write: "+err.Error())
                        continue
diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go    Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go    Sat Apr 20 17:43:24 2019 +0000
@@ -1167,8 +1167,8 @@
                "",
                ".for id in ${PRE_XORGPROTO_LIST_MISSING}",
                ".endfor")
-       G.Pkgsrc.LoadInfrastructure()
        t.Chdir(".")
+       t.FinishSetUp()
 
        G.Check("x11/xorg-cf-files")
        G.Check("x11/xorgproto")
@@ -1188,8 +1188,8 @@
 
        t.SetUpPackage("print/tex-bibtex8",
                "MAKE_FLAGS+=\tCFLAGS=${CFLAGS.${PKGSRC_COMPILER}}")
-       G.Pkgsrc.LoadInfrastructure()
        t.Chdir(".")
+       t.FinishSetUp()
 
        G.Check("print/tex-bibtex8")
 
diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go      Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go      Sat Apr 20 17:43:24 2019 +0000
@@ -230,7 +230,7 @@
                                token.Text)
                }
 
-               G.Explain(
+               pkgbaseLine.Explain(
                        "The identifiers in the BUILDLINK_TREE variable should be plain",
                        "strings that do not refer to any variable.",
                        "",
diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Sat Apr 20 17:43:24 2019 +0000
@@ -19,6 +19,7 @@
 
        t.CreateFileDummyBuildlink3("category/package/buildlink3.mk",
                ".include \"../../category/dependency2/buildlink3.mk\"")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -85,6 +86,7 @@
                ".endif\t# HS_X11_BUILDLINK3_MK",
                "",
                "BUILDLINK_TREE+=\t-hs-X11")
+       t.FinishSetUp()
 
        G.Check(".")
 
@@ -124,6 +126,7 @@
                ".endif\t# HS_X11_BUILDLINK3_MK",
                "",
                "BUILDLINK_TREE+=\t-hs-X11")
+       t.FinishSetUp()
 
        G.Check(".")
 
@@ -150,6 +153,7 @@
                ".endif\t# P5_GTK2_BUILDLINK3_MK",
                "",
                "BUILDLINK_TREE+=\t-p5-gtk2")
+       t.FinishSetUp()
 
        G.Check(t.File("x11/p5-gtk2"))
 
@@ -508,6 +512,8 @@
                        "it would be ok in Makefile, Makefile.* or *.mk, but not buildlink3.mk or builtin.mk.",
                "WARN: buildlink3.mk:3: The variable LICENSE should be quoted as part of a shell word.",
                "WARN: buildlink3.mk:8: The variable LICENSE should be quoted as part of a shell word.",
+               "WARN: buildlink3.mk:8: The variable LICENSE should be quoted as part of a shell word.",
+               "WARN: buildlink3.mk:9: The variable LICENSE should be quoted as part of a shell word.",
                "WARN: buildlink3.mk:9: The variable LICENSE should be quoted as part of a shell word.",
                "WARN: buildlink3.mk:13: The variable LICENSE should be quoted as part of a shell word.",
                "WARN: buildlink3.mk:3: Please replace \"${LICENSE}\" with a simple string "+
@@ -523,6 +529,7 @@
                ".if ${X11_TYPE} == modular",
                ".else",
                ".endif")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -537,6 +544,7 @@
        t.CreateFileDummyBuildlink3("category/package/buildlink3.mk",
                "BUILDLINK_ABI_DEPENDS.package+=\tpackage>=1.0:../../category/package",
                "BUILDLINK_API_DEPENDS.package+=\tpackage>=1.5:../../category/package")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -570,6 +578,7 @@
                ".endif # PACKAGE_BUILDLINK3_MK",
                "",
                "BUILDLINK_TREE+=\t-package")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -589,6 +598,7 @@
                "",
                "ABI_VERSION=\t1.0",
                "API_VERSION=\t1.5")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -606,6 +616,7 @@
                "BUILDLINK_API_DEPENDS.package+=\tpackage>=${API_VERSION}",
                "",
                "API_VERSION=\t1.5")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -621,6 +632,7 @@
        t.CreateFileDummyBuildlink3("category/package/buildlink3.mk",
                "BUILDLINK_ABI_DEPENDS.package+=\tpackage-1.*",
                "BUILDLINK_API_DEPENDS.package+=\tpackage-2.*")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -637,6 +649,7 @@
        t.CreateFileDummyBuildlink3("category/package/buildlink3.mk",
                "BUILDLINK_ABI_DEPENDS.package+=\tpackage>=1",
                "BUILDLINK_API_DEPENDS.package+=\tpackage-1.*")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -658,6 +671,7 @@
                "BUILDLINK_DEPMETHOD.other+=\tbuild",
                "",
                "BUILDLINK_API_DEPENDS.other+=\tother>=3")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
@@ -674,6 +688,7 @@
        t.SetUpPackage("category/package")
        t.CreateFileDummyBuildlink3("category/package/buildlink3.mk")
        t.DisableTracing()
+       t.FinishSetUp()
 
        G.Check(t.File("category/package/buildlink3.mk"))
 
@@ -687,6 +702,7 @@
                "DISTNAME=\t# empty",
                "PKGNAME=\t# empty, to force mkbase to be empty")
        t.CreateFileDummyBuildlink3("category/package/buildlink3.mk")
+       t.FinishSetUp()
 
        G.Check(t.File("category/package"))
 
diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/files/category.go        Sat Apr 20 17:43:24 2019 +0000
@@ -1,6 +1,10 @@
 package pkglint
 
-import "netbsd.org/pkglint/textproc"
+import (
+       "fmt"
+       "netbsd.org/pkglint/textproc"
+       "strings"
+)
 
 func CheckdirCategory(dir string) {
        if trace.Tracing {
@@ -25,18 +29,18 @@
                lex := textproc.NewLexer(mkline.Value())
                valid := textproc.NewByteSet("--- '(),/0-9A-Za-z")
                invalid := valid.Inverse()
-               uni := ""
+               var uni strings.Builder
 
                for !lex.EOF() {
                        _ = lex.NextBytesSet(valid)
                        ch := lex.NextByteSet(invalid)
                        if ch != -1 {
-                               uni += sprintf(" %U", ch)
+                               _, _ = fmt.Fprintf(&uni, " %U", ch)
                        }
                }
 
-               if uni != "" {
-                       mkline.Warnf("%s contains invalid characters (%s).", mkline.Varname(), uni[1:])
+               if uni.Len() > 0 {
+                       mkline.Warnf("%s contains invalid characters (%s).", mkline.Varname(), uni.String()[1:])
                }
 
        } else {
diff -r eb6eb93a8d05 -r a77cddf4320d pkgtools/pkglint/files/category_test.go
--- a/pkgtools/pkglint/files/category_test.go   Sat Apr 20 17:27:49 2019 +0000
+++ b/pkgtools/pkglint/files/category_test.go   Sat Apr 20 17:43:24 2019 +0000
@@ -83,6 +83,7 @@
                "\t${RUN}wip-specific-command",
                "",
                ".include \"../mk/misc/category.mk\"")
+       t.FinishSetUp()
 
        G.Check(t.File("wip"))
 
@@ -117,6 +118,7 @@
                "#SUBDIR+=\tcommented-without-reason",
                "",
                ".include \"../mk/misc/category.mk\"")
+       t.FinishSetUp()
 
        CheckdirCategory(t.File("category"))
 
@@ -147,6 +149,7 @@
                "SUBDIR+=\tonly-in-makefile",



Home | Main Index | Thread Index | Old Index