pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/pkgtools/pkglint



Module Name:    pkgsrc
Committed By:   rillig
Date:           Thu Aug  1 22:38:49 UTC 2019

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: autofix_test.go mkline.go mkline_test.go
            util.go varalignblock.go varalignblock_test.go vartypecheck.go

Log Message:
pkgtools/pkglint: update to 5.7.18

Changes since 5.7.17:

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


To generate a diff of this commit:
cvs rdiff -u -r1.589 -r1.590 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.27 -r1.28 pkgsrc/pkgtools/pkglint/files/autofix_test.go
cvs rdiff -u -r1.55 -r1.56 pkgsrc/pkgtools/pkglint/files/mkline.go
cvs rdiff -u -r1.62 -r1.63 pkgsrc/pkgtools/pkglint/files/mkline_test.go
cvs rdiff -u -r1.49 -r1.50 pkgsrc/pkgtools/pkglint/files/util.go
cvs rdiff -u -r1.1 -r1.2 pkgsrc/pkgtools/pkglint/files/varalignblock.go \
    pkgsrc/pkgtools/pkglint/files/varalignblock_test.go
cvs rdiff -u -r1.60 -r1.61 pkgsrc/pkgtools/pkglint/files/vartypecheck.go

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.589 pkgsrc/pkgtools/pkglint/Makefile:1.590
--- pkgsrc/pkgtools/pkglint/Makefile:1.589      Tue Jul 30 18:16:13 2019
+++ pkgsrc/pkgtools/pkglint/Makefile    Thu Aug  1 22:38:49 2019
@@ -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/}

Index: pkgsrc/pkgtools/pkglint/files/autofix_test.go
diff -u pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.27 pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.28
--- pkgsrc/pkgtools/pkglint/files/autofix_test.go:1.27  Sun Jul 14 21:25:47 2019
+++ pkgsrc/pkgtools/pkglint/files/autofix_test.go       Thu Aug  1 22:38:49 2019
@@ -1166,6 +1166,48 @@ func (s *Suite) Test_Autofix_Apply__text
        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)

Index: pkgsrc/pkgtools/pkglint/files/mkline.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline.go:1.55 pkgsrc/pkgtools/pkglint/files/mkline.go:1.56
--- pkgsrc/pkgtools/pkglint/files/mkline.go:1.55        Sun Jul 14 21:25:47 2019
+++ pkgsrc/pkgtools/pkglint/files/mkline.go     Thu Aug  1 22:38:49 2019
@@ -1591,7 +1591,7 @@ func (p MkLineParser) MatchVarassign(lin
        }
 }
 
-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()

Index: pkgsrc/pkgtools/pkglint/files/mkline_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.62 pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.63
--- pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.62   Tue Jul 30 18:16:13 2019
+++ pkgsrc/pkgtools/pkglint/files/mkline_test.go        Thu Aug  1 22:38:49 2019
@@ -1737,6 +1737,15 @@ func (s *Suite) Test_MkLineParser_MatchV
                "")
 }
 
+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)
 

Index: pkgsrc/pkgtools/pkglint/files/util.go
diff -u pkgsrc/pkgtools/pkglint/files/util.go:1.49 pkgsrc/pkgtools/pkglint/files/util.go:1.50
--- pkgsrc/pkgtools/pkglint/files/util.go:1.49  Sun Jul 14 21:25:47 2019
+++ pkgsrc/pkgtools/pkglint/files/util.go       Thu Aug  1 22:38:49 2019
@@ -149,13 +149,6 @@ func keysJoined(m map[string]bool) strin
        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

Index: pkgsrc/pkgtools/pkglint/files/varalignblock.go
diff -u pkgsrc/pkgtools/pkglint/files/varalignblock.go:1.1 pkgsrc/pkgtools/pkglint/files/varalignblock.go:1.2
--- pkgsrc/pkgtools/pkglint/files/varalignblock.go:1.1  Sun Jul 14 21:25:47 2019
+++ pkgsrc/pkgtools/pkglint/files/varalignblock.go      Thu Aug  1 22:38:49 2019
@@ -209,10 +209,12 @@ func (*VaralignBlock) split(textnl strin
                                continue
                        }
 
-                       assert(lexer.SkipByte('\\'))
-                       if !lexer.EOF() {
-                               lexer.Skip(1)
+                       if len(lexer.Rest()) < 2 {
+                               break
                        }
+
+                       assert(lexer.SkipByte('\\'))
+                       lexer.Skip(1)
                }
 
                valueSpace := lexer.Since(mark)
@@ -278,15 +280,13 @@ func (va *VaralignBlock) Finish() {
 
        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 @@ func (*VaralignBlock) optimalWidth(infos
        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 @@ func (l *varalignLine) commentedOut() bo
        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.
Index: pkgsrc/pkgtools/pkglint/files/varalignblock_test.go
diff -u pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.1 pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.2
--- pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.1     Sun Jul 14 21:25:47 2019
+++ pkgsrc/pkgtools/pkglint/files/varalignblock_test.go Thu Aug  1 22:38:49 2019
@@ -2320,7 +2320,6 @@ func (s *Suite) Test_VaralignBlock_Proce
 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 @@ func (s *Suite) Test_VaralignBlock_Proce
                "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 @@ func (s *Suite) Test_VaralignBlock_split
                        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.
        //

Index: pkgsrc/pkgtools/pkglint/files/vartypecheck.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.60 pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.61
--- pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.60  Tue Jul 30 18:16:13 2019
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck.go       Thu Aug  1 22:38:49 2019
@@ -184,7 +184,7 @@ func (cv *VartypeCheck) Category() {
                "kde", "korean",
                "linux", "local",
                "packages", "perl5", "plan9", "python",
-               "ruby",
+               "R", "ruby",
                "scm",
                "tcl", "tk",
                "windowmaker",



Home | Main Index | Thread Index | Old Index