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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/360c5ba6eaf3
branches:  trunk
changeset: 399061:360c5ba6eaf3
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Aug 01 22:38:49 2019 +0000

description:
pkgtools/pkglint: update to 5.7.18

Changes since 5.7.17:

* Added "R" to the list of valid secondary categories.

diffstat:

 pkgtools/pkglint/Makefile                    |   4 +-
 pkgtools/pkglint/files/autofix_test.go       |  42 ++++++++++++++++++++++++++++
 pkgtools/pkglint/files/mkline.go             |   2 +-
 pkgtools/pkglint/files/mkline_test.go        |   9 ++++++
 pkgtools/pkglint/files/util.go               |   7 ----
 pkgtools/pkglint/files/varalignblock.go      |  18 ++++-------
 pkgtools/pkglint/files/varalignblock_test.go |  32 ++++++++++++++++++++-
 pkgtools/pkglint/files/vartypecheck.go       |   2 +-
 8 files changed, 93 insertions(+), 23 deletions(-)

diffs (236 lines):

diff -r 4b9bc7dca2d2 -r 360c5ba6eaf3 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Thu Aug 01 22:37:24 2019 +0000
+++ b/pkgtools/pkglint/Makefile Thu Aug 01 22:38:49 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.589 2019/07/30 18:16:13 rillig Exp $
+# $NetBSD: Makefile,v 1.590 2019/08/01 22:38:49 rillig Exp $
 
-PKGNAME=       pkglint-5.7.17
+PKGNAME=       pkglint-5.7.18
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 4b9bc7dca2d2 -r 360c5ba6eaf3 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go    Thu Aug 01 22:37:24 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go    Thu Aug 01 22:38:49 2019 +0000
@@ -1166,6 +1166,48 @@
        t.CheckEquals(mkline.Value(), "value")
 }
 
+// Pkglint tries to order the diagnostics from top to bottom.
+// Still, it could be possible that in a multiline the second line
+// gets a diagnostic before the first line. This only happens when
+// both replacements happen in the same autofix block, which doesn't
+// happen often.
+//
+// This covers the "action.lineno < first" condition.
+func (s *Suite) Test_Autofix_affectedLinenos__reverse(c *check.C) {
+       t := s.Init(c)
+
+       test := func(diagnostics ...string) {
+               mklines := t.NewMkLines("filename.mk",
+                       "VAR=\tline 1 \\",
+                       "\tline 2")
+               mkline := mklines.mklines[0]
+
+               fix := mkline.Autofix()
+               fix.Warnf("Replacements from bottom to top.")
+               fix.Replace("line 2", "bbb")
+               fix.Replace("line 1", "aaa")
+               fix.Apply()
+
+               t.CheckOutput(diagnostics)
+       }
+
+       t.SetUpCommandLine("--source")
+       test(
+               ">\tVAR=\tline 1 \\",
+               ">\t\tline 2",
+               "WARN: filename.mk:1--2: Replacements from bottom to top.")
+
+       t.SetUpCommandLine("--source", "--show-autofix")
+       test(
+               "WARN: filename.mk:1--2: Replacements from bottom to top.",
+               "AUTOFIX: filename.mk:2: Replacing \"line 2\" with \"bbb\".",
+               "AUTOFIX: filename.mk:1: Replacing \"line 1\" with \"aaa\".",
+               "-\tVAR=\tline 1 \\",
+               "+\tVAR=\taaa \\",
+               "-\t\tline 2",
+               "+\t\tbbb")
+}
+
 // Just for branch coverage.
 func (s *Suite) Test_Autofix_setDiag__no_testing_mode(c *check.C) {
        t := s.Init(c)
diff -r 4b9bc7dca2d2 -r 360c5ba6eaf3 pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go  Thu Aug 01 22:37:24 2019 +0000
+++ b/pkgtools/pkglint/files/mkline.go  Thu Aug 01 22:38:49 2019 +0000
@@ -1591,7 +1591,7 @@
        }
 }
 
-func (*MkLineParser) getRawValueAlign(raw, parsed string) string {
+func (MkLineParser) getRawValueAlign(raw, parsed string) string {
        r := textproc.NewLexer(raw)
        p := textproc.NewLexer(parsed)
        mark := r.Mark()
diff -r 4b9bc7dca2d2 -r 360c5ba6eaf3 pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Thu Aug 01 22:37:24 2019 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Thu Aug 01 22:38:49 2019 +0000
@@ -1737,6 +1737,15 @@
                "")
 }
 
+func (s *Suite) Test_MkLineParser_getRawValueAlign__assertion(c *check.C) {
+       t := s.Init(c)
+
+       var p MkLineParser
+
+       // This is unrealistic; just for code coverage of the assertion.
+       t.ExpectAssert(func() { p.getRawValueAlign("a", "b") })
+}
+
 func (s *Suite) Test_NewMkOperator(c *check.C) {
        t := s.Init(c)
 
diff -r 4b9bc7dca2d2 -r 360c5ba6eaf3 pkgtools/pkglint/files/util.go
--- a/pkgtools/pkglint/files/util.go    Thu Aug 01 22:37:24 2019 +0000
+++ b/pkgtools/pkglint/files/util.go    Thu Aug 01 22:38:49 2019 +0000
@@ -149,13 +149,6 @@
        return strings.Join(keys, " ")
 }
 
-func imin(a, b int) int {
-       if a < b {
-               return a
-       }
-       return b
-}
-
 func imax(a, b int) int {
        if a > b {
                return a
diff -r 4b9bc7dca2d2 -r 360c5ba6eaf3 pkgtools/pkglint/files/varalignblock.go
--- a/pkgtools/pkglint/files/varalignblock.go   Thu Aug 01 22:37:24 2019 +0000
+++ b/pkgtools/pkglint/files/varalignblock.go   Thu Aug 01 22:38:49 2019 +0000
@@ -209,10 +209,12 @@
                                continue
                        }
 
+                       if len(lexer.Rest()) < 2 {
+                               break
+                       }
+
                        assert(lexer.SkipByte('\\'))
-                       if !lexer.EOF() {
-                               lexer.Skip(1)
-                       }
+                       lexer.Skip(1)
                }
 
                valueSpace := lexer.Since(mark)
@@ -278,15 +280,13 @@
 
        newWidth := va.optimalWidth(infos)
 
-       multiEmpty := false
        for _, info := range infos {
                if info.rawIndex == 0 {
                        va.indentDiffSet = false
                        va.indentDiff = 0
-                       multiEmpty = info.multiEmpty
                }
 
-               if newWidth > 0 || multiEmpty && info.rawIndex > 0 {
+               if newWidth > 0 || info.rawIndex > 0 {
                        va.realign(info, newWidth)
                }
        }
@@ -302,6 +302,7 @@
        longest := 0 // The longest seen varnameOpWidth
        var longestLine *MkLine
        secondLongest := 0 // The second-longest seen varnameOpWidth
+
        for _, info := range infos {
                if info.multiEmpty || info.rawIndex > 0 {
                        continue
@@ -591,11 +592,6 @@
        return hasPrefix(l.parts.leadingComment, "#")
 }
 
-func (l *varalignLine) outlier(width int) bool {
-       assert(width == width&-8)
-       return l.varnameOpSpaceWidth() > width+8
-}
-
 // canonicalInitial returns whether the space between the assignment
 // operator and the value has its canonical form, which is either
 // at least one tab, or a single space, but only for lines that stick out.
diff -r 4b9bc7dca2d2 -r 360c5ba6eaf3 pkgtools/pkglint/files/varalignblock_test.go
--- a/pkgtools/pkglint/files/varalignblock_test.go      Thu Aug 01 22:37:24 2019 +0000
+++ b/pkgtools/pkglint/files/varalignblock_test.go      Thu Aug 01 22:38:49 2019 +0000
@@ -2320,7 +2320,6 @@
 func (s *Suite) Test_VaralignBlock_Process__only_spaces(c *check.C) {
        t := s.Init(c)
 
-       t.SetUpCommandLine("-Wspace")
        mklines := t.NewMkLines("file.mk",
                "SUBST_CLASSES+= aaaaaaaa",
                "SUBST_STAGE.aaaaaaaa= pre-configure",
@@ -2340,6 +2339,22 @@
                "NOTE: file.mk:4: This variable value should be aligned with tabs, not spaces, to column 33.")
 }
 
+func (s *Suite) Test_VaralignBlock_realignMultiEmptyInitial(c *check.C) {
+       t := s.Init(c)
+
+       mklines := t.NewMkLines("filename.mk",
+               MkCvsID,
+               "VAR=\t${VAR}",
+               // FIXME: It's not possible to align with tabs to column 21.
+               "LONG_VARIABLE_NAME=    \t        \\",
+               "\t${LONG_VARIABLE_NAME}")
+
+       mklines.Check()
+
+       t.CheckOutputLines(
+               "NOTE: filename.mk:3: This variable value should be aligned with tabs, not spaces, to column 21.")
+}
+
 func (s *Suite) Test_VaralignBlock_split(c *check.C) {
        t := s.Init(c)
 
@@ -2516,6 +2531,21 @@
                        continuation:      "",
                })
 
+       // In practice it doesn't really happen that the last line of a file
+       // ends in a backslash and at the same time it doesn't have the usual
+       // newline ending.
+       test("    value \\", false,
+               varalignSplitResult{
+                       leadingComment:    "",
+                       varnameOp:         "",
+                       spaceBeforeValue:  "    ",
+                       value:             "value",
+                       spaceAfterValue:   " ",
+                       trailingComment:   "",
+                       spaceAfterComment: "",
+                       continuation:      "\\",
+               })
+
        // Commented variable assignments are only valid if they
        // directly follow the comment sign.
        //
diff -r 4b9bc7dca2d2 -r 360c5ba6eaf3 pkgtools/pkglint/files/vartypecheck.go
--- a/pkgtools/pkglint/files/vartypecheck.go    Thu Aug 01 22:37:24 2019 +0000
+++ b/pkgtools/pkglint/files/vartypecheck.go    Thu Aug 01 22:38:49 2019 +0000
@@ -184,7 +184,7 @@
                "kde", "korean",
                "linux", "local",
                "packages", "perl5", "plan9", "python",
-               "ruby",
+               "R", "ruby",
                "scm",
                "tcl", "tk",
                "windowmaker",



Home | Main Index | Thread Index | Old Index