pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint Updated pkglint to 5.4.14.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b910c6a3356b
branches:  trunk
changeset: 356013:b910c6a3356b
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Dec 17 13:35:32 2016 +0000

description:
Updated pkglint to 5.4.14.

Changes since 5.4.13:

* Pkglint can fix $(VARIABLES) in parentheses to ${VARIABLES} in braces
  automatically

diffstat:

 pkgtools/pkglint/Makefile               |   4 ++--
 pkgtools/pkglint/files/files.go         |   2 +-
 pkgtools/pkglint/files/mkparser.go      |  10 +++++++---
 pkgtools/pkglint/files/mkparser_test.go |  23 ++++++++++++++++++++++-
 4 files changed, 32 insertions(+), 7 deletions(-)

diffs (83 lines):

diff -r 25a9b8d8ea2c -r b910c6a3356b pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Dec 17 13:33:08 2016 +0000
+++ b/pkgtools/pkglint/Makefile Sat Dec 17 13:35:32 2016 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.503 2016/12/13 00:58:06 rillig Exp $
+# $NetBSD: Makefile,v 1.504 2016/12/17 13:35:32 rillig Exp $
 
-PKGNAME=       pkglint-5.4.13
+PKGNAME=       pkglint-5.4.14
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r 25a9b8d8ea2c -r b910c6a3356b pkgtools/pkglint/files/files.go
--- a/pkgtools/pkglint/files/files.go   Sat Dec 17 13:33:08 2016 +0000
+++ b/pkgtools/pkglint/files/files.go   Sat Dec 17 13:35:32 2016 +0000
@@ -33,7 +33,7 @@
 func getLogicalLine(fname string, rawLines []*RawLine, pindex *int) *Line {
        { // Handle the common case efficiently
                index := *pindex
-               rawLine := rawLines[*pindex]
+               rawLine := rawLines[index]
                textnl := rawLine.textnl
                if hasSuffix(textnl, "\n") && !hasSuffix(textnl, "\\\n") {
                        *pindex = index + 1
diff -r 25a9b8d8ea2c -r b910c6a3356b pkgtools/pkglint/files/mkparser.go
--- a/pkgtools/pkglint/files/mkparser.go        Sat Dec 17 13:33:08 2016 +0000
+++ b/pkgtools/pkglint/files/mkparser.go        Sat Dec 17 13:35:32 2016 +0000
@@ -58,11 +58,15 @@
                varnameMark := repl.Mark()
                varname := p.Varname()
                if varname != "" {
-                       if usingRoundParen && p.EmitWarnings {
-                               p.Line.Warnf("Please use curly braces {} instead of round parentheses () for %s.", varname)
-                       }
                        modifiers := p.VarUseModifiers(varname, closing)
                        if repl.AdvanceStr(closing) {
+                               if usingRoundParen && p.EmitWarnings {
+                                       parenVaruse := repl.Since(mark)
+                                       bracesVaruse := "${" + parenVaruse[2:len(parenVaruse)-1] + "}"
+                                       if !p.Line.AutofixReplace(parenVaruse, bracesVaruse) {
+                                               p.Line.Warnf("Please use curly braces {} instead of round parentheses () for %s.", varname)
+                                       }
+                               }
                                return &MkVarUse{varname, modifiers}
                        }
                }
diff -r 25a9b8d8ea2c -r b910c6a3356b pkgtools/pkglint/files/mkparser_test.go
--- a/pkgtools/pkglint/files/mkparser_test.go   Sat Dec 17 13:33:08 2016 +0000
+++ b/pkgtools/pkglint/files/mkparser_test.go   Sat Dec 17 13:35:32 2016 +0000
@@ -110,7 +110,7 @@
 
        checkRest("${VAR)", nil, "${VAR)") // Opening brace, closing parenthesis
        checkRest("$(VAR}", nil, "$(VAR}") // Opening parenthesis, closing brace
-       c.Check(s.Output(), equals, "WARN: Please use curly braces {} instead of round parentheses () for VAR.\n")
+       c.Check(s.Output(), equals, "")    // Warnings are only printed for balanced expressions.
 
        check("${PLIST_SUBST_VARS:@var@${var}=${${var}:Q}@}", varuse("PLIST_SUBST_VARS", "@var@${var}=${${var}:Q}@"))
        check("${PLIST_SUBST_VARS:@var@${var}=${${var}:Q}}", varuse("PLIST_SUBST_VARS", "@var@${var}=${${var}:Q}")) // Missing @ at the end
@@ -209,3 +209,24 @@
                NewTree("not", NewTree("empty", varuse("PKG_OPTIONS", "Msndfile"))),
                " || defined(PKG_OPTIONS:Msamplerate)")
 }
+
+func (s *Suite) Test_MkParser__varuse_parentheses_autofix(c *check.C) {
+       s.Init(c)
+       s.UseCommandLine("--autofix")
+       G.globalData.InitVartypes()
+       filename := s.CreateTmpFile("Makefile", "")
+       mklines := s.NewMkLines(filename,
+               mkrcsid,
+               "COMMENT=$(P1) $(P2)) $(P3:Q) ${BRACES}")
+
+       mklines.Check()
+
+       c.Check(s.Output(), equals, ""+
+               "AUTOFIX: ~/Makefile:2: Replacing \"$(P1)\" with \"${P1}\".\n"+
+               "AUTOFIX: ~/Makefile:2: Replacing \"$(P2)\" with \"${P2}\".\n"+
+               "AUTOFIX: ~/Makefile:2: Replacing \"$(P3:Q)\" with \"${P3:Q}\".\n"+
+               "AUTOFIX: ~/Makefile: Has been auto-fixed. Please re-run pkglint.\n")
+       c.Check(s.LoadTmpFile("Makefile"), equals, ""+
+               mkrcsid+"\n"+
+               "COMMENT=${P1} ${P2}) ${P3:Q} ${BRACES}\n")
+}



Home | Main Index | Thread Index | Old Index