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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0a7c88e8aa68
branches:  trunk
changeset: 339422:0a7c88e8aa68
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Sep 12 21:15:48 2019 +0000

description:
pkgtools/pkglint: update to 5.7.24

Changes since 5.7.23:

* Improved the _VARGROUPS check for ignored variables
* Removed wrong warnings for variable expressions like ${VAR:Dyes:Uno}
* Used correct terminology for the :Q modifier (it's not an operator)

diffstat:

 pkgtools/pkglint/Makefile                    |   4 +-
 pkgtools/pkglint/files/logging.go            |   4 +-
 pkgtools/pkglint/files/logging_test.go       |  12 +++
 pkgtools/pkglint/files/mkline.go             |  17 +++-
 pkgtools/pkglint/files/mkline_test.go        |  26 +++++++-
 pkgtools/pkglint/files/mklinechecker.go      |   8 +-
 pkgtools/pkglint/files/mklinechecker_test.go |   4 +-
 pkgtools/pkglint/files/mktypes.go            |   9 ++
 pkgtools/pkglint/files/shell_test.go         |  10 +-
 pkgtools/pkglint/files/util.go               |   2 +-
 pkgtools/pkglint/files/vardefs.go            |   6 +-
 pkgtools/pkglint/files/vardefs_test.go       |   2 +-
 pkgtools/pkglint/files/vargroups.go          |  50 ++++++--------
 pkgtools/pkglint/files/vargroups_test.go     |  93 +++++++++++++++++++++++++++-
 14 files changed, 192 insertions(+), 55 deletions(-)

diffs (truncated from 528 to 300 lines):

diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/Makefile Thu Sep 12 21:15:48 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.596 2019/09/08 22:47:47 rillig Exp $
+# $NetBSD: Makefile,v 1.597 2019/09/12 21:15:48 rillig Exp $
 
-PKGNAME=       pkglint-5.7.23
+PKGNAME=       pkglint-5.7.24
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/logging.go
--- a/pkgtools/pkglint/files/logging.go Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/logging.go Thu Sep 12 21:15:48 2019 +0000
@@ -180,7 +180,7 @@
 //
 // See Logf for logging arbitrary messages.
 func (l *Logger) Diag(line *Line, level *LogLevel, format string, args ...interface{}) {
-       if l.Opts.ShowAutofix || l.Opts.Autofix {
+       if l.IsAutofix() {
                // In these two cases, the only interesting diagnostics are those that can
                // be fixed automatically. These are logged by Autofix.Apply.
                l.suppressExpl = true
@@ -200,7 +200,7 @@
        }
 
        if l.Opts.ShowSource {
-               if !l.IsAutofix() && line != l.prevLine && level != Fatal {
+               if line != l.prevLine {
                        l.out.Separate()
                }
                l.showSource(line)
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/logging_test.go
--- a/pkgtools/pkglint/files/logging_test.go    Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/logging_test.go    Thu Sep 12 21:15:48 2019 +0000
@@ -1071,3 +1071,15 @@
 
        t.CheckEquals(sb.String(), "a\n\nc\n")
 }
+
+func (s *Suite) Test_SeparatorWriter_Separate__at_the_beginning(c *check.C) {
+       t := s.Init(c)
+
+       var sb strings.Builder
+       wr := NewSeparatorWriter(&sb)
+
+       wr.Separate()
+       wr.WriteLine("a")
+
+       t.CheckEquals(sb.String(), "a\n")
+}
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go  Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/mkline.go  Thu Sep 12 21:15:48 2019 +0000
@@ -920,12 +920,12 @@
        return &MkLine{line, &mkLineDirective{indent, directive, args, trimmedComment, nil, nil, nil}}
 }
 
-// VariableNeedsQuoting determines whether the given variable needs the :Q operator
-// in the given context.
+// VariableNeedsQuoting determines whether the given variable needs the :Q
+// modifier in the given context.
 //
-// This decision depends on many factors, such as whether the type of the context is
-// a list of things, whether the variable is a list, whether it can contain only
-// safe characters, and so on.
+// This decision depends on many factors, such as whether the type of the
+// context is a list of things, whether the variable is a list, whether it
+// can contain only safe characters, and so on.
 func (mkline *MkLine) VariableNeedsQuoting(mklines *MkLines, varuse *MkVarUse, vartype *Vartype, vuc *VarUseContext) (needsQuoting YesNoUnknown) {
        if trace.Tracing {
                defer trace.Call(varuse, vartype, vuc, trace.Result(&needsQuoting))()
@@ -934,6 +934,13 @@
        // TODO: Systematically test this function, each and every case, from top to bottom.
        // TODO: Re-check the order of all these if clauses whether it really makes sense.
 
+       if varuse.HasModifier("D") && varuse.HasModifier("U") {
+               // Take the simple way for now. Handling this kind of
+               // conditional expressions correctly and completely would
+               // require a larger rewrite.
+               return unknown
+       }
+
        vucVartype := vuc.vartype
        if vartype == nil || vucVartype == nil || vartype.basicType == BtUnknown {
                return unknown
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Thu Sep 12 21:15:48 2019 +0000
@@ -648,7 +648,7 @@
        MkLineChecker{mklines, mklines.mklines[1]}.checkVarassign()
 
        t.CheckOutputLines(
-               "NOTE: builtin.mk:2: The :Q operator isn't necessary for ${BUILTIN_PKG.Xfixes} here.")
+               "NOTE: builtin.mk:2: The :Q modifier isn't necessary for ${BUILTIN_PKG.Xfixes} here.")
 }
 
 func (s *Suite) Test_MkLine_VariableNeedsQuoting__command_in_single_quotes(c *check.C) {
@@ -930,7 +930,7 @@
        // for invoking the tool properly (e.g. touch -t).
        // Therefore, no quoting is necessary.
        t.CheckOutputLines(
-               "NOTE: Makefile:3: The :Q operator isn't necessary for ${TOOLS_TAR} here.")
+               "NOTE: Makefile:3: The :Q modifier isn't necessary for ${TOOLS_TAR} here.")
 }
 
 func (s *Suite) Test_MkLine_VariableNeedsQuoting__backticks(c *check.C) {
@@ -1026,6 +1026,28 @@
        t.CheckOutputEmpty()
 }
 
+func (s *Suite) Test_MkLine_VariableNeedsQuoting__D_and_U_modifiers(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpVartypes()
+
+       mklines := t.SetUpFileMkLines("Makefile",
+               MkCvsID,
+               "",
+               "SUBST_CLASSES+=\t\turl2pkg",
+               "SUBST_STAGE.url2pkg=\tpost-configure",
+               "SUBST_FILES.url2pkg=\t*.in",
+               "SUBST_SED.url2pkg=\t-e 's,@PKGSRCDIR@,${BATCH:D/usr/pkg:U${PKGSRCDIR}},'")
+
+       mklines.Check()
+
+       // Since the value of the BATCH variable does not appear in the output,
+       // there should be no warning saying that "BATCH should be quoted".
+       // If any, the variable PKGSRCDIR should be quoted, but that is a safe
+       // variable since it is a pkgsrc-specific directory.
+       t.CheckOutputEmpty()
+}
+
 // As of October 2018, these examples from real pkgsrc end up in the
 // final "unknown" case.
 func (s *Suite) Test_MkLine_VariableNeedsQuoting__uncovered_cases(c *check.C) {
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/mklinechecker.go
--- a/pkgtools/pkglint/files/mklinechecker.go   Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/mklinechecker.go   Thu Sep 12 21:15:48 2019 +0000
@@ -847,11 +847,11 @@
        mod := varUse.Mod()
 
        // In GNU configure scripts, a few variables need to be passed through
-       // the :M* operator before they reach the configure scripts. Otherwise
+       // the :M* modifier before they reach the configure scripts. Otherwise
        // the leading or trailing spaces will lead to strange caching errors
        // since the GNU configure scripts cannot handle these space characters.
        //
-       // When doing checks outside a package, the :M* operator is needed for safety.
+       // When doing checks outside a package, the :M* modifier is needed for safety.
        needMstar := (G.Pkg == nil || G.Pkg.vars.Defined("GNU_CONFIGURE")) &&
                matches(varname, `^(?:.*_)?(?:CFLAGS|CPPFLAGS|CXXFLAGS|FFLAGS|LDFLAGS|LIBS)$`)
 
@@ -958,9 +958,9 @@
                good := "${" + varname + strings.TrimSuffix(mod, ":Q") + "}"
 
                fix := mkline.Line.Autofix()
-               fix.Notef("The :Q operator isn't necessary for ${%s} here.", varname)
+               fix.Notef("The :Q modifier isn't necessary for ${%s} here.", varname)
                fix.Explain(
-                       "Many variables in pkgsrc do not need the :Q operator since they",
+                       "Many variables in pkgsrc do not need the :Q modifier since they",
                        "are not expected to contain whitespace or other special characters.",
                        "Examples for these \"safe\" variables are:",
                        "",
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/mklinechecker_test.go
--- a/pkgtools/pkglint/files/mklinechecker_test.go      Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/mklinechecker_test.go      Thu Sep 12 21:15:48 2019 +0000
@@ -1191,7 +1191,7 @@
 
        t.CheckOutputLines(
                "WARN: module.mk:2: Please use PREFIX instead of LOCALBASE.",
-               "NOTE: module.mk:2: The :Q operator isn't necessary for ${LOCALBASE} here.")
+               "NOTE: module.mk:2: The :Q modifier isn't necessary for ${LOCALBASE} here.")
 }
 
 func (s *Suite) Test_MkLineChecker_checkVarusePermissions(c *check.C) {
@@ -2275,7 +2275,7 @@
        G.Check(pkg)
 
        t.CheckOutputLines(
-               "NOTE: ~/category/package/Makefile:6: The :Q operator isn't necessary for ${HOMEPAGE} here.")
+               "NOTE: ~/category/package/Makefile:6: The :Q modifier isn't necessary for ${HOMEPAGE} here.")
 }
 
 func (s *Suite) Test_MkLineChecker_checkVarUseQuoting__undefined_list_in_word_in_shell_command(c *check.C) {
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/mktypes.go
--- a/pkgtools/pkglint/files/mktypes.go Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/mktypes.go Thu Sep 12 21:15:48 2019 +0000
@@ -159,3 +159,12 @@
        mlen := len(vu.modifiers)
        return mlen > 0 && vu.modifiers[mlen-1].IsQ()
 }
+
+func (vu *MkVarUse) HasModifier(prefix string) bool {
+       for _, mod := range vu.modifiers {
+               if hasPrefix(mod.Text, prefix) {
+                       return true
+               }
+       }
+       return false
+}
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/shell_test.go
--- a/pkgtools/pkglint/files/shell_test.go      Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/shell_test.go      Thu Sep 12 21:15:48 2019 +0000
@@ -180,7 +180,7 @@
                        "before using a semicolon (after \"uname=`uname`\") to separate commands.")
 
        test("echo ${PKGNAME:Q}", // VucQuotPlain
-               "NOTE: filename.mk:1: The :Q operator isn't necessary for ${PKGNAME} here.")
+               "NOTE: filename.mk:1: The :Q modifier isn't necessary for ${PKGNAME} here.")
 
        test("echo \"${CFLAGS:Q}\"", // VucQuotDquot
                "WARN: filename.mk:1: The :Q modifier should not be used inside double quotes.",
@@ -316,7 +316,7 @@
        ck.CheckShellCommandLine("echo ${PKGNAME:Q}")
 
        t.CheckOutputLines(
-               "NOTE: Makefile:1: The :Q operator isn't necessary for ${PKGNAME} here.")
+               "NOTE: Makefile:1: The :Q modifier isn't necessary for ${PKGNAME} here.")
 }
 
 func (s *Suite) Test_ShellLineChecker_CheckShellCommandLine__show_autofix(c *check.C) {
@@ -332,7 +332,7 @@
        ck.CheckShellCommandLine("echo ${PKGNAME:Q}")
 
        t.CheckOutputLines(
-               "NOTE: Makefile:1: The :Q operator isn't necessary for ${PKGNAME} here.",
+               "NOTE: Makefile:1: The :Q modifier isn't necessary for ${PKGNAME} here.",
                "AUTOFIX: Makefile:1: Replacing \"${PKGNAME:Q}\" with \"${PKGNAME}\".")
 }
 
@@ -479,10 +479,10 @@
                nil...)
 
        test("\"${DISTINFO_FILE:Q}\"", true,
-               "NOTE: filename.mk:1: The :Q operator isn't necessary for ${DISTINFO_FILE} here.")
+               "NOTE: filename.mk:1: The :Q modifier isn't necessary for ${DISTINFO_FILE} here.")
 
        test("embed${DISTINFO_FILE:Q}ded", true,
-               "NOTE: filename.mk:1: The :Q operator isn't necessary for ${DISTINFO_FILE} here.")
+               "NOTE: filename.mk:1: The :Q modifier isn't necessary for ${DISTINFO_FILE} here.")
 
        test("s,\\.,,", true,
                nil...)
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/util.go
--- a/pkgtools/pkglint/files/util.go    Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/util.go    Thu Sep 12 21:15:48 2019 +0000
@@ -267,7 +267,7 @@
        case ".", "..", "CVS", ".svn", ".git", ".hg", ".idea":
                return true
        }
-       return false
+       return hasPrefix(filename, ".#")
 }
 
 func dirglob(dirname string) []string {
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/vardefs.go
--- a/pkgtools/pkglint/files/vardefs.go Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/vardefs.go Thu Sep 12 21:15:48 2019 +0000
@@ -305,7 +305,7 @@
 func (reg *VarTypeRegistry) infralist(varname string, basicType *BasicType) {
        reg.acllist(varname, basicType,
                List,
-               "*: set, append")
+               "*: set, append, use")
 }
 
 // compilerLanguages reads the available languages that are typically
@@ -1043,6 +1043,7 @@
        reg.pkg("DYNAMIC_SITES_CMD", BtShellCommand)
        reg.pkg("DYNAMIC_SITES_SCRIPT", BtPathname)
        reg.sysbl3("ECHO", BtShellCommand)
+       reg.sysbl3("ECHO_BUILDLINK_MSG", BtShellCommand)
        reg.sysbl3("ECHO_MSG", BtShellCommand)
        reg.sysbl3("ECHO_N", BtShellCommand)
        reg.pkg("EGDIR", BtPathname) // Not defined anywhere but used in many places like this.
@@ -1588,6 +1589,7 @@
        reg.syslist("TOOLS_NOOP", BtTool)
        reg.sys("TOOLS_PATH.*", BtPathname)
        reg.sysload("TOOLS_PLATFORM.*", BtShellCommand)
+       reg.sysload("TOOLS_SHELL", BtShellCommand)
        reg.syslist("TOUCH_FLAGS", BtShellWord)
        reg.pkglist("UAC_REQD_EXECS", BtPrefixPathname)
        reg.pkglistbl3("UNLIMIT_RESOURCES",
@@ -1675,7 +1677,7 @@
        reg.infralist("_SYS_VARS.*", BtVariableName)
        reg.infralist("_DEF_VARS.*", BtVariableName)
        reg.infralist("_USE_VARS.*", BtVariableName)
-       reg.infralist("_IGN_VARS.*", BtVariableName)
+       reg.infralist("_IGN_VARS.*", BtVariableNamePattern)
        reg.infralist("_SORTED_VARS.*", BtVariableNamePattern)
        reg.infralist("_LISTED_VARS.*", BtVariableNamePattern)
 }
diff -r beaed5b3d69d -r 0a7c88e8aa68 pkgtools/pkglint/files/vardefs_test.go
--- a/pkgtools/pkglint/files/vardefs_test.go    Thu Sep 12 21:07:01 2019 +0000
+++ b/pkgtools/pkglint/files/vardefs_test.go    Thu Sep 12 21:15:48 2019 +0000
@@ -185,7 +185,7 @@
 



Home | Main Index | Thread Index | Old Index