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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/30ce9c8edd0d
branches:  trunk
changeset: 345490:30ce9c8edd0d
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Fri Dec 13 01:39:23 2019 +0000

description:
pkgtools/pkglint: update to 19.3.17

Changes since 19.3.16:

Pkglint now handles SUBST blocks correctly, even those in which some of
the variables are defined conditionally. It correctly reports those that
are missing in at least one of the possible branches.

PKG_JVM is no longer marked as deprecated. It was once package-settable.
Since 2002 it is system-provided, and the package-settable counterpart
is PKG_JVM_DEFAULT. This does not fit into pkglint's simple model of
deprecating variables since the variable name is still valid, it should
just not be defined by packages anymore.

The alignment of variable assignments has been fixed in some edge cases.
In continuation lines where the backslash is beyond column 72, the
whitespace before the continuation backslash is fixed to a single space.

diffstat:

 pkgtools/pkglint/Makefile                     |     4 +-
 pkgtools/pkglint/PLIST                        |     4 +-
 pkgtools/pkglint/files/buildlink3_test.go     |    18 +
 pkgtools/pkglint/files/check_test.go          |    49 +-
 pkgtools/pkglint/files/intqa/qa_test.go       |     3 +
 pkgtools/pkglint/files/line.go                |     8 +
 pkgtools/pkglint/files/mkalign.go             |   233 +++
 pkgtools/pkglint/files/mkalign_test.go        |   236 +++
 pkgtools/pkglint/files/mkassignchecker.go     |     2 +-
 pkgtools/pkglint/files/mklexer.go             |    35 +-
 pkgtools/pkglint/files/mklexer_test.go        |    51 +-
 pkgtools/pkglint/files/mkline.go              |     4 +-
 pkgtools/pkglint/files/mklineparser.go        |     4 +-
 pkgtools/pkglint/files/mklineparser_test.go   |     2 +-
 pkgtools/pkglint/files/mklines.go             |    21 +-
 pkgtools/pkglint/files/mklines_test.go        |     4 +-
 pkgtools/pkglint/files/mkshparser.go          |     4 +-
 pkgtools/pkglint/files/mkshparser_test.go     |     2 +-
 pkgtools/pkglint/files/mktypes.go             |    32 +-
 pkgtools/pkglint/files/mktypes_test.go        |    42 +
 pkgtools/pkglint/files/package_test.go        |     1 -
 pkgtools/pkglint/files/path.go                |     2 +-
 pkgtools/pkglint/files/pkglint.1              |     2 +-
 pkgtools/pkglint/files/pkgsrc.go              |     4 -
 pkgtools/pkglint/files/pkgsrc_test.go         |     4 +-
 pkgtools/pkglint/files/redundantscope_test.go |     2 +-
 pkgtools/pkglint/files/shell.go               |     4 +-
 pkgtools/pkglint/files/shell_test.go          |    28 +-
 pkgtools/pkglint/files/shtokenizer.go         |    10 +-
 pkgtools/pkglint/files/shtokenizer_test.go    |    16 +-
 pkgtools/pkglint/files/shtypes_test.go        |     4 +-
 pkgtools/pkglint/files/substcontext.go        |   674 +++++++--
 pkgtools/pkglint/files/substcontext_test.go   |  1584 ++++++++++++++++--------
 pkgtools/pkglint/files/textproc/lexer.go      |     2 +
 pkgtools/pkglint/files/util.go                |    73 +-
 pkgtools/pkglint/files/util_test.go           |    87 +-
 pkgtools/pkglint/files/varalignblock.go       |   699 +++++-----
 pkgtools/pkglint/files/varalignblock_test.go  |  1017 +++++++++++++--
 pkgtools/pkglint/files/vardefs.go             |   131 +-
 pkgtools/pkglint/files/vargroups_test.go      |     2 +-
 pkgtools/pkglint/files/vartype.go             |     7 +-
 pkgtools/pkglint/files/vartype_test.go        |     2 +-
 pkgtools/pkglint/files/vartypecheck.go        |    14 +-
 pkgtools/pkglint/files/vartypecheck_test.go   |    36 +-
 44 files changed, 3652 insertions(+), 1511 deletions(-)

diffs (truncated from 6860 to 300 lines):

diff -r ac0215e13a93 -r 30ce9c8edd0d pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Fri Dec 13 00:47:23 2019 +0000
+++ b/pkgtools/pkglint/Makefile Fri Dec 13 01:39:23 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.616 2019/12/09 20:38:15 rillig Exp $
+# $NetBSD: Makefile,v 1.617 2019/12/13 01:39:23 rillig Exp $
 
-PKGNAME=       pkglint-19.3.16
+PKGNAME=       pkglint-19.3.17
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r ac0215e13a93 -r 30ce9c8edd0d pkgtools/pkglint/PLIST
--- a/pkgtools/pkglint/PLIST    Fri Dec 13 00:47:23 2019 +0000
+++ b/pkgtools/pkglint/PLIST    Fri Dec 13 01:39:23 2019 +0000
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.20 2019/12/08 00:06:38 rillig Exp $
+@comment $NetBSD: PLIST,v 1.21 2019/12/13 01:39:23 rillig Exp $
 bin/pkglint
 gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint.a
 gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint/getopt.a
@@ -49,6 +49,8 @@
 gopkg/src/netbsd.org/pkglint/lineslexer_test.go
 gopkg/src/netbsd.org/pkglint/logging.go
 gopkg/src/netbsd.org/pkglint/logging_test.go
+gopkg/src/netbsd.org/pkglint/mkalign.go
+gopkg/src/netbsd.org/pkglint/mkalign_test.go
 gopkg/src/netbsd.org/pkglint/mkassignchecker.go
 gopkg/src/netbsd.org/pkglint/mkassignchecker_test.go
 gopkg/src/netbsd.org/pkglint/mkcondchecker.go
diff -r ac0215e13a93 -r 30ce9c8edd0d pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Fri Dec 13 00:47:23 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Fri Dec 13 01:39:23 2019 +0000
@@ -856,9 +856,13 @@
        CheckLinesBuildlink3Mk(mklines)
 
        t.CheckOutputLines(
+               "ERROR: x11/php-wxwidgets/buildlink3.mk:3: "+
+                       "Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: x11/php-wxwidgets/buildlink3.mk:8: "+
                        "To use PHP_PKG_PREFIX at load time, "+
                        ".include \"../../mk/bsd.fast.prefs.mk\" first.",
+               "ERROR: x11/php-wxwidgets/buildlink3.mk:13: "+
+                       "Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: x11/php-wxwidgets/buildlink3.mk:3: "+
                        "Please use \"php\" instead of \"${PHP_PKG_PREFIX}\" "+
                        "(also in other variables in this file).")
@@ -888,9 +892,13 @@
        CheckLinesBuildlink3Mk(mklines)
 
        t.CheckOutputLines(
+               "ERROR: x11/py-wxwidgets/buildlink3.mk:3: "+
+                       "Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: x11/py-wxwidgets/buildlink3.mk:8: "+
                        "To use PYPKGPREFIX at load time, "+
                        ".include \"../../mk/bsd.fast.prefs.mk\" first.",
+               "ERROR: x11/py-wxwidgets/buildlink3.mk:13: "+
+                       "Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: x11/py-wxwidgets/buildlink3.mk:3: "+
                        "Please use \"py\" instead of \"${PYPKGPREFIX}\" "+
                        "(also in other variables in this file).")
@@ -920,9 +928,13 @@
        CheckLinesBuildlink3Mk(mklines)
 
        t.CheckOutputLines(
+               "ERROR: x11/ruby1-wxwidgets/buildlink3.mk:3: "+
+                       "Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: x11/ruby1-wxwidgets/buildlink3.mk:8: "+
                        "To use RUBY_BASE at load time, "+
                        ".include \"../../mk/bsd.fast.prefs.mk\" first.",
+               "ERROR: x11/ruby1-wxwidgets/buildlink3.mk:13: "+
+                       "Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: x11/ruby1-wxwidgets/buildlink3.mk:3: "+
                        "Please use \"ruby\" instead of \"${RUBY_BASE}\" "+
                        "(also in other variables in this file).")
@@ -952,9 +964,13 @@
        CheckLinesBuildlink3Mk(mklines)
 
        t.CheckOutputLines(
+               "ERROR: x11/ruby2-wxwidgets/buildlink3.mk:3: "+
+                       "Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: x11/ruby2-wxwidgets/buildlink3.mk:8: "+
                        "To use RUBY_PKGPREFIX at load time, "+
                        ".include \"../../mk/bsd.fast.prefs.mk\" first.",
+               "ERROR: x11/ruby2-wxwidgets/buildlink3.mk:13: "+
+                       "Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: x11/ruby2-wxwidgets/buildlink3.mk:3: "+
                        "Please use \"ruby\" instead of \"${RUBY_PKGPREFIX}\" "+
                        "(also in other variables in this file).")
@@ -984,6 +1000,7 @@
        CheckLinesBuildlink3Mk(mklines)
 
        t.CheckOutputLines(
+               "ERROR: buildlink3.mk:3: Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "WARN: buildlink3.mk:3: LICENSE should not be used in this file; "+
                        "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.",
@@ -991,6 +1008,7 @@
                "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.",
+               "ERROR: buildlink3.mk:13: Identifiers for BUILDLINK_TREE must not refer to other variables.",
                "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 "+
                        "(also in other variables in this file).")
diff -r ac0215e13a93 -r 30ce9c8edd0d pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Fri Dec 13 00:47:23 2019 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Fri Dec 13 01:39:23 2019 +0000
@@ -9,6 +9,7 @@
        "netbsd.org/pkglint/regex"
        "os"
        "regexp"
+       "strconv"
        "strings"
        "testing"
 
@@ -139,10 +140,13 @@
        ck.Configure("tools.go", "*", "*", -intqa.EMissingTest)          // TODO
        ck.Configure("util.go", "*", "*", -intqa.EMissingTest)           // TODO
        ck.Configure("var.go", "*", "*", -intqa.EMissingTest)            // TODO
-       ck.Configure("varalignblock.go", "*", "*", -intqa.EMissingTest)  // TODO
-       ck.Configure("vardefs.go", "*", "*", -intqa.EMissingTest)        // TODO
-       ck.Configure("vargroups.go", "*", "*", -intqa.EMissingTest)      // TODO
-       ck.Configure("vartype.go", "*", "*", -intqa.EMissingTest)        // TODO
+
+       ck.Configure("varalignblock.go", "*", "*", -intqa.EMissingTest)            // TODO
+       ck.Configure("varalignblock.go", "varalignLine", "*", +intqa.EMissingTest) // TODO: remove as redundant
+
+       ck.Configure("vardefs.go", "*", "*", -intqa.EMissingTest)   // TODO
+       ck.Configure("vargroups.go", "*", "*", -intqa.EMissingTest) // TODO
+       ck.Configure("vartype.go", "*", "*", -intqa.EMissingTest)   // TODO
 
        // For now, don't require tests for all the test code.
        // Having good coverage for the main code is more important.
@@ -165,6 +169,7 @@
        // The Suite type is used for testing all parts of pkglint.
        // Therefore its test methods may be everywhere.
        ck.Configure("*.go", "Suite", "*", -intqa.EMethodsSameFile)
+       ck.Configure("*.go", "Tester", "*", -intqa.EMethodsSameFile)
 
        ck.Check()
 }
@@ -858,10 +863,20 @@
        return t.c.Check(actual, check.Equals, expected)
 }
 
+func (t *Tester) CheckEqualsf(actual interface{}, expected interface{}, format string, args ...interface{}) bool {
+       return t.c.Check(actual, check.Equals, expected,
+               check.Commentf(format, args...))
+}
+
 func (t *Tester) CheckDeepEquals(actual interface{}, expected interface{}) bool {
        return t.c.Check(actual, check.DeepEquals, expected)
 }
 
+func (t *Tester) CheckDeepEqualsf(actual interface{}, expected interface{}, format string, args ...interface{}) bool {
+       return t.c.Check(actual, check.DeepEquals, expected,
+               check.Commentf(format, args...))
+}
+
 // InternalErrorf reports a consistency error in the tests.
 func (t *Tester) InternalErrorf(format string, args ...interface{}) {
        // It is not possible to panic here since check.v1 would then
@@ -1097,7 +1112,6 @@
 func (t *Tester) CheckOutputLinesMatching(pattern regex.Pattern, expectedLines ...string) {
        output := t.Output()
        var actualLines []string
-       actualLines = append(actualLines)
        for _, line := range strings.Split(strings.TrimSuffix(output, "\n"), "\n") {
                if matches(line, pattern) {
                        actualLines = append(actualLines, line)
@@ -1302,6 +1316,22 @@
        t.CheckDeepEquals(detabbedLines, lines)
 }
 
+// CheckDotColumns verifies that each appearance of "..34" is indeed
+// right-aligned at column 34, taking tabs into account.
+// Columns are zero-based.
+func (t *Tester) CheckDotColumns(lines ...string) {
+       for index, line := range lines {
+               ms := regcomp(`\.\.(\d+)`).FindAllStringSubmatchIndex(line, -1)
+               for _, m := range ms {
+                       prefix := line[:m[1]]
+                       width := tabWidth(prefix)
+                       num, err := strconv.Atoi(line[m[2]:m[3]])
+                       assertNil(err, "")
+                       t.CheckEqualsf(num, width, "lines[%d]", index)
+               }
+       }
+}
+
 // Use marks all passed functions as used for the Go compiler.
 //
 // This means that the test cases that follow do not have to use each of them,
@@ -1341,3 +1371,12 @@
        _, _ = fmt.Fprintf(&msg, "\n")
        _, _ = os.Stderr.WriteString(msg.String())
 }
+
+// SplitStringsBool unpacks the given varargs into a string slice and a bool.
+func (t *Tester) SplitStringsBool(data []interface{}) ([]string, bool) {
+       var strs []string
+       for _, text := range data[:len(data)-1] {
+               strs = append(strs, text.(string))
+       }
+       return strs, data[len(data)-1].(bool)
+}
diff -r ac0215e13a93 -r 30ce9c8edd0d pkgtools/pkglint/files/intqa/qa_test.go
--- a/pkgtools/pkglint/files/intqa/qa_test.go   Fri Dec 13 00:47:23 2019 +0000
+++ b/pkgtools/pkglint/files/intqa/qa_test.go   Fri Dec 13 01:39:23 2019 +0000
@@ -722,6 +722,9 @@
 func (s *Suite) Test_Value_Method(c *check.C) {
        _ = s.Init(c)
 
+       // To make it appear actually used to golangci-lint.
+       _ = Value{}
+
        // Just for code coverage of checkTestFile, to have a piece of code
        // that lives in the same file as its test.
 }
diff -r ac0215e13a93 -r 30ce9c8edd0d pkgtools/pkglint/files/line.go
--- a/pkgtools/pkglint/files/line.go    Fri Dec 13 00:47:23 2019 +0000
+++ b/pkgtools/pkglint/files/line.go    Fri Dec 13 01:39:23 2019 +0000
@@ -16,6 +16,7 @@
 import (
        "netbsd.org/pkglint/regex"
        "strconv"
+       "strings"
 )
 
 type RawLine struct {
@@ -36,6 +37,13 @@
 
 func (rline *RawLine) String() string { return sprintf("%d:%s", rline.Lineno, rline.textnl) }
 
+func (rline *RawLine) text() string {
+       // TODO: use this method everywhere
+       // TODO: add orig()
+       // TODO: export these two functions
+       return strings.TrimSuffix(rline.textnl, "\n")
+}
+
 type Location struct {
        Filename  CurrPath
        firstLine int32 // zero means the whole file, -1 means EOF
diff -r ac0215e13a93 -r 30ce9c8edd0d pkgtools/pkglint/files/mkalign.go
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkglint/files/mkalign.go Fri Dec 13 01:39:23 2019 +0000
@@ -0,0 +1,233 @@
+package pkglint
+
+type MkAlignFile struct {
+       Paras []*MkAlignPara
+}
+
+func (f *MkAlignFile) AlignParas() {
+       //  #.  Ein einzelner Absatz, der einen Tab weniger eingerückt ist als die übrigen,
+       //      darf auf die Einrückung der anderen Absätze angeglichen werden,
+       //      sofern der Absatz dadurch nicht zu breit wird.
+       panic("implement me")
+}
+
+type MkAlignPara struct {
+}
+
+func (p *MkAlignPara) IsAligned() bool {
+       //  #.  Das Ausrichten mit mehr als 1 Tab ist erlaubt, wenn die Ausrichtung einheitlich ist.
+
+       //  #.  Wenn VarOp über die Ausrichtung hinausragt (Ausrei�er),
+       //      darf zwischen VarOp und Wert statt der Ausrichtung 1 Leerzeichen sein.
+
+       //  #.  Das Verhältnis zwischen Tab-Zeilen und hinausragenden Zeilen muss ausgewogen sein.
+       //      Nicht zu viele hinausragende Zeilen. (Noch zu definieren.)
+       //      Möglicher Ansatz: Anteil der Leerfläche?
+
+       panic("implement me")
+}
+
+func (p *MkAlignPara) IsOutlier(line *MkAlignLine) bool {
+       //  #.  Wenn VarOp über die Ausrichtung hinausragt (Ausrei�er),
+       //      darf zwischen VarOp und Wert statt der Ausrichtung 1 Leerzeichen sein.
+       panic("implement me")
+}
+
+// ValueAlignment returns the column at which all values of the paragraph
+// are aligned, or false if they aren't.
+//
+//  #.  Die Werte aller Zeilen sind mit Tabs an einer gemeinsamen vertikalen Linie
+//      (Ausrichtung) ausgerichtet.
+func (p *MkAlignPara) ValueAlignment() (bool, int) {
+       panic("implement me")
+}
+
+func (p *MkAlignPara) MinValueAlignment() int {
+       //  #.  Die minimale Ausrichtung ergibt sich aus der maximalen Breite von # und VarOp
+       //      aller Zeilen, gerundet zum nächsten Tabstopp.
+       //      Dabei zählen auch Zeilen mit, die rechts von VarOp komplett leer sind.
+       panic("implement me")
+}
+



Home | Main Index | Thread Index | Old Index