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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/03e758200858
branches:  trunk
changeset: 335728:03e758200858
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Jun 30 20:56:18 2019 +0000

description:
pkgtools/pkglint: update to 5.7.14

Changes since 5.7.13:

- Removed the -Cextra command line option since it didn't produce useful
  warnings.

- Removed unwarranted warnings about _WRAP_EXTRA_ARGS.CC being used in
  packages.

- Cleaned up the canonical order of variables in package Makefiles.

- Added a few commands to those that cannot fail, to reduce the number of
  "at the left of the | operator" in shell programs.

- Fixed warnings about "-ggdb" being an unknown shell command.

- Reduced number of warnings about lists being used where a single value
  is expected.

- Replaced unreliable check for invalid CFLAGS and LDFLAGS with a more
  practical check.

- Renamed "RCS tag" to "CVS tag" to make the diagnostics more modern.

- Added warning when PKGNAME or PKGVERSION is used in MASTER_SITES.

- Reworded warning for missing or superfluous PLIST files.

- Lots of other detail changes, refactorings and automatic tests.

diffstat:

 pkgtools/pkglint/Makefile                     |     4 +-
 pkgtools/pkglint/files/alternatives.go        |     4 +-
 pkgtools/pkglint/files/alternatives_test.go   |     2 +-
 pkgtools/pkglint/files/autofix.go             |    50 +-
 pkgtools/pkglint/files/autofix_test.go        |   148 +-
 pkgtools/pkglint/files/buildlink3.go          |    18 +-
 pkgtools/pkglint/files/buildlink3_test.go     |    78 +-
 pkgtools/pkglint/files/category.go            |     8 +-
 pkgtools/pkglint/files/category_test.go       |    31 +-
 pkgtools/pkglint/files/check_test.go          |   159 +-
 pkgtools/pkglint/files/cmd/pkglint/main.go    |     2 +-
 pkgtools/pkglint/files/distinfo.go            |    45 +-
 pkgtools/pkglint/files/distinfo_test.go       |    72 +-
 pkgtools/pkglint/files/files.go               |    10 +-
 pkgtools/pkglint/files/files_test.go          |    34 +-
 pkgtools/pkglint/files/fuzzer_test.go         |     2 +-
 pkgtools/pkglint/files/getopt/getopt_test.go  |    12 +-
 pkgtools/pkglint/files/intqa/testnames.go     |    31 -
 pkgtools/pkglint/files/licenses.go            |     4 +-
 pkgtools/pkglint/files/line.go                |    48 +-
 pkgtools/pkglint/files/line_test.go           |     4 +-
 pkgtools/pkglint/files/linechecker.go         |     2 +-
 pkgtools/pkglint/files/linelexer.go           |    22 +-
 pkgtools/pkglint/files/lines.go               |    36 +-
 pkgtools/pkglint/files/lines_test.go          |     6 +-
 pkgtools/pkglint/files/logging.go             |     2 +-
 pkgtools/pkglint/files/logging_test.go        |     2 +-
 pkgtools/pkglint/files/mkline.go              |   331 +++--
 pkgtools/pkglint/files/mkline_test.go         |   179 ++-
 pkgtools/pkglint/files/mklinechecker.go       |   100 +-
 pkgtools/pkglint/files/mklinechecker_test.go  |   359 ++++--
 pkgtools/pkglint/files/mklines.go             |   247 ++-
 pkgtools/pkglint/files/mklines_test.go        |   388 +++++-
 pkgtools/pkglint/files/mkparser.go            |   324 ++--
 pkgtools/pkglint/files/mkparser_test.go       |   405 ++++++-
 pkgtools/pkglint/files/mkshparser.go          |     4 +-
 pkgtools/pkglint/files/mkshparser_test.go     |     2 +-
 pkgtools/pkglint/files/mkshtypes.go           |     9 +-
 pkgtools/pkglint/files/mkshwalker.go          |    11 +-
 pkgtools/pkglint/files/mkshwalker_test.go     |    58 +-
 pkgtools/pkglint/files/mktokenslexer_test.go  |     1 -
 pkgtools/pkglint/files/mktypes_test.go        |    15 +-
 pkgtools/pkglint/files/options.go             |    20 +-
 pkgtools/pkglint/files/options_test.go        |    32 +-
 pkgtools/pkglint/files/package.go             |   788 ++++++++-----
 pkgtools/pkglint/files/package_test.go        |  1434 ++++++++++++++++++++++--
 pkgtools/pkglint/files/paragraph.go           |    39 +-
 pkgtools/pkglint/files/paragraph_test.go      |    75 +-
 pkgtools/pkglint/files/patches.go             |   152 +-
 pkgtools/pkglint/files/patches_test.go        |   187 +-
 pkgtools/pkglint/files/pkglint.1              |     6 +-
 pkgtools/pkglint/files/pkglint.go             |   329 ++--
 pkgtools/pkglint/files/pkglint_test.go        |   289 ++--
 pkgtools/pkglint/files/pkgsrc.go              |   288 ++--
 pkgtools/pkglint/files/pkgsrc_test.go         |   340 +++++-
 pkgtools/pkglint/files/plist.go               |   119 +-
 pkgtools/pkglint/files/plist_test.go          |   325 ++++-
 pkgtools/pkglint/files/redundantscope.go      |    18 +-
 pkgtools/pkglint/files/redundantscope_test.go |    12 +-
 pkgtools/pkglint/files/shell.go               |    64 +-
 pkgtools/pkglint/files/shell_test.go          |   376 +++++-
 pkgtools/pkglint/files/shtokenizer.go         |    22 +-
 pkgtools/pkglint/files/shtokenizer_test.go    |     2 +-
 pkgtools/pkglint/files/shtypes.go             |     2 +
 pkgtools/pkglint/files/shtypes_test.go        |     7 +
 pkgtools/pkglint/files/substcontext.go        |    14 +-
 pkgtools/pkglint/files/substcontext_test.go   |    38 +-
 pkgtools/pkglint/files/tools.go               |    10 +-
 pkgtools/pkglint/files/tools_test.go          |    36 +-
 pkgtools/pkglint/files/toplevel.go            |     2 +-
 pkgtools/pkglint/files/toplevel_test.go       |    18 +-
 pkgtools/pkglint/files/trace/tracing.go       |     2 +-
 pkgtools/pkglint/files/util.go                |   200 ++-
 pkgtools/pkglint/files/util_test.go           |   156 ++-
 pkgtools/pkglint/files/var.go                 |    22 +-
 pkgtools/pkglint/files/var_test.go            |    19 +-
 pkgtools/pkglint/files/vardefs.go             |    45 +-
 pkgtools/pkglint/files/vardefs_test.go        |    31 +-
 pkgtools/pkglint/files/vartype.go             |    16 +-
 pkgtools/pkglint/files/vartype_test.go        |     8 +-
 pkgtools/pkglint/files/vartypecheck.go        |   134 +-
 pkgtools/pkglint/files/vartypecheck_test.go   |    75 +-
 82 files changed, 6185 insertions(+), 2836 deletions(-)

diffs (truncated from 18268 to 300 lines):

diff -r de007267c691 -r 03e758200858 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Jun 30 20:53:23 2019 +0000
+++ b/pkgtools/pkglint/Makefile Sun Jun 30 20:56:18 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.585 2019/06/10 19:51:57 rillig Exp $
+# $NetBSD: Makefile,v 1.586 2019/06/30 20:56:18 rillig Exp $
 
-PKGNAME=       pkglint-5.7.13
+PKGNAME=       pkglint-5.7.14
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r de007267c691 -r 03e758200858 pkgtools/pkglint/files/alternatives.go
--- a/pkgtools/pkglint/files/alternatives.go    Sun Jun 30 20:53:23 2019 +0000
+++ b/pkgtools/pkglint/files/alternatives.go    Sun Jun 30 20:56:18 2019 +0000
@@ -16,13 +16,13 @@
                plist = G.Pkg.Plist
        }
 
-       checkPlistWrapper := func(line Line, wrapper string) {
+       checkPlistWrapper := func(line *Line, wrapper string) {
                if plist.Files[wrapper] {
                        line.Errorf("Alternative wrapper %q must not appear in the PLIST.", wrapper)
                }
        }
 
-       checkPlistAlternative := func(line Line, alternative string) {
+       checkPlistAlternative := func(line *Line, alternative string) {
                relImplementation := strings.Replace(alternative, "@PREFIX@/", "", 1)
                plistName := replaceAll(relImplementation, `@(\w+)@`, "${$1}")
                if plist.Files[plistName] || G.Pkg.vars.Defined("ALTERNATIVES_SRC") {
diff -r de007267c691 -r 03e758200858 pkgtools/pkglint/files/alternatives_test.go
--- a/pkgtools/pkglint/files/alternatives_test.go       Sun Jun 30 20:53:23 2019 +0000
+++ b/pkgtools/pkglint/files/alternatives_test.go       Sun Jun 30 20:56:18 2019 +0000
@@ -17,7 +17,7 @@
                "highscores   @VARBASE@/game/scores",
                "sbin/init /sbin/init")
        t.CreateFileLines("PLIST",
-               PlistRcsID,
+               PlistCvsID,
                "bin/echo",
                "bin/vim",
                "sbin/sendmail.exim${EXIMVER}")
diff -r de007267c691 -r 03e758200858 pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Sun Jun 30 20:53:23 2019 +0000
+++ b/pkgtools/pkglint/files/autofix.go Sun Jun 30 20:56:18 2019 +0000
@@ -13,7 +13,7 @@
 // The modifications are kept in memory only,
 // until they are written to disk by SaveAutofixChanges.
 type Autofix struct {
-       line        Line
+       line        *Line
        linesBefore []string // Newly inserted lines, including \n
        linesAfter  []string // Newly inserted lines, including \n
        // Whether an actual fix has been applied (or, without --show-autofix,
@@ -51,7 +51,10 @@
 // Since these are not really diagnostics, duplicates are not suppressed.
 const AutofixFormat = "AutofixFormat"
 
-func NewAutofix(line Line) *Autofix {
+func NewAutofix(line *Line) *Autofix {
+       // FIXME: replacing the returned value with
+       //  &Autofix{line: line, autofixShortTerm: autofixShortTerm{anyway: true}}
+       //  makes some tests output source code without diagnostic.
        return &Autofix{line: line}
 }
 
@@ -75,9 +78,7 @@
        // Since a silent fix doesn't have a diagnostic, its explanation would
        // not provide any clue as to what diagnostic it belongs. That would
        // be confusing, therefore this case is not allowed.
-       assertf(
-               fix.diagFormat != SilentAutofixFormat,
-               "Autofix: Silent fixes cannot have an explanation.")
+       assert(fix.diagFormat != SilentAutofixFormat)
 
        fix.explanation = explanation
 }
@@ -95,8 +96,19 @@
                return
        }
 
+       prefixFrom := prefix + from
+       prefixTo := prefix + to
+
+       n := 0
        for _, rawLine := range fix.line.raw {
-               replaced := strings.Replace(rawLine.textnl, prefix+from, prefix+to, 1)
+               n += strings.Count(rawLine.textnl, prefixFrom)
+       }
+       if n != 1 {
+               return
+       }
+
+       for _, rawLine := range fix.line.raw {
+               replaced := strings.Replace(rawLine.textnl, prefixFrom, prefixTo, 1)
                if replaced != rawLine.textnl {
                        if G.Logger.IsAutofix() {
                                rawLine.textnl = replaced
@@ -108,7 +120,7 @@
                                // TODO: Do this properly by parsing the whole line again,
                                //  and ideally everything that depends on the parsed line.
                                //  This probably requires a generic notification mechanism.
-                               fix.line.Text = strings.Replace(fix.line.Text, prefix+from, prefix+to, 1)
+                               fix.line.Text = strings.Replace(fix.line.Text, prefixFrom, prefixTo, 1)
                        }
                        fix.Describef(rawLine.Lineno, "Replacing %q with %q.", from, to)
                        return
@@ -274,11 +286,10 @@
 func (fix *Autofix) Apply() {
        line := fix.line
 
+       // Each autofix must have a log level and a diagnostic.
        // To fix this assertion, call one of Autofix.Errorf, Autofix.Warnf
        // or Autofix.Notef before calling Apply.
-       assertf(
-               fix.level != nil,
-               "Each autofix must have a log level and a diagnostic.")
+       assert(fix.level != nil)
 
        reset := func() {
                if len(fix.actions) > 0 {
@@ -339,14 +350,14 @@
        reset()
 }
 
-func (fix *Autofix) Realign(mkline MkLine, newWidth int) {
+func (fix *Autofix) Realign(mkline *MkLine, newWidth int) {
 
        // XXX: Check whether this method can be implemented as Custom fix.
        // This complicated code should not be in the Autofix type.
 
        fix.assertRealLine()
-       assertf(mkline.IsMultiline(), "Line must be a multiline.")
-       assertf(mkline.IsVarassign() || mkline.IsCommentedVarassign(), "Line must be a variable assignment.")
+       assert(mkline.IsMultiline())
+       assert(mkline.IsVarassign() || mkline.IsCommentedVarassign())
 
        if fix.skip() {
                return
@@ -409,8 +420,8 @@
                        "Autofix: format %q must end with a period.",
                        format)
        }
-       assertf(fix.level == nil, "Autofix can only have a single diagnostic.")
-       assertf(fix.diagFormat == "", "Autofix can only have a single diagnostic.")
+       assert(fix.level == nil)     // Autofix can only have a single diagnostic.
+       assert(fix.diagFormat == "") // Autofix can only have a single diagnostic.
 
        fix.level = level
        fix.diagFormat = format
@@ -418,22 +429,21 @@
 }
 
 func (fix *Autofix) skip() bool {
-       assertf(
-               fix.diagFormat != "",
-               "Autofix: The diagnostic must be given before the action.")
+       assert(fix.diagFormat != "") // The diagnostic must be given before the action.
+
        // This check is necessary for the --only command line option.
        return !G.Logger.shallBeLogged(fix.diagFormat)
 }
 
 func (fix *Autofix) assertRealLine() {
-       assertf(fix.line.firstLine >= 1, "Cannot autofix this line since it is not a real line.")
+       assert(fix.line.firstLine >= 1) // Cannot autofix this line since it is not a real line.
 }
 
 // SaveAutofixChanges writes the given lines back into their files,
 // applying the autofix changes.
 // The lines may come from different files.
 // Only files that actually have changed lines are saved.
-func SaveAutofixChanges(lines Lines) (autofixed bool) {
+func SaveAutofixChanges(lines *Lines) (autofixed bool) {
        if trace.Tracing {
                defer trace.Call0()()
        }
diff -r de007267c691 -r 03e758200858 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go    Sun Jun 30 20:53:23 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go    Sun Jun 30 20:56:18 2019 +0000
@@ -14,9 +14,7 @@
 
        fix := line.Autofix()
        fix.Warnf("Warning 1.")
-       t.ExpectPanic(
-               func() { fix.Warnf("Warning 2.") },
-               "Pkglint internal error: Autofix can only have a single diagnostic.")
+       t.ExpectAssert(func() { fix.Warnf("Warning 2.") })
 }
 
 func (s *Suite) Test_Autofix__default_leaves_line_unchanged(c *check.C) {
@@ -58,7 +56,7 @@
 
        fix := line.Autofix()
        fix.Warnf("Row should be replaced with line.")
-       fix.ReplaceAfter("", "row", "line")
+       fix.ReplaceAfter("", "# row", "# line")
        fix.ReplaceRegex(`row \d+`, "the above line", -1)
        fix.InsertBefore("above")
        fix.InsertAfter("below")
@@ -70,7 +68,7 @@
                "below\n")
        t.CheckOutputLines(
                "WARN: ~/Makefile:1--2: Row should be replaced with line.",
-               "AUTOFIX: ~/Makefile:1: Replacing \"row\" with \"line\".",
+               "AUTOFIX: ~/Makefile:1: Replacing \"# row\" with \"# line\".",
                "AUTOFIX: ~/Makefile:2: Replacing \"row 1\" with \"the above line\".",
                "AUTOFIX: ~/Makefile:1: Inserting a line \"above\" before this line.",
                "AUTOFIX: ~/Makefile:2: Inserting a line \"below\" after this line.",
@@ -83,7 +81,29 @@
        c.Check(fix.modified, equals, true)
 }
 
-func (s *Suite) Test_Autofix_ReplaceAfter__autofix(c *check.C) {
+func (s *Suite) Test_Autofix_ReplaceAfter__autofix_in_continuation_line(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpCommandLine("--autofix", "--source")
+       mklines := t.SetUpFileMkLines("Makefile",
+               "# line 1 \\",
+               "continuation 1 \\",
+               "continuation 2")
+
+       fix := mklines.lines.Lines[0].Autofix()
+       fix.Warnf("Line should be replaced with Row.")
+       fix.ReplaceAfter("", "line", "row")
+       fix.Apply()
+
+       t.CheckOutputLines(
+               "AUTOFIX: ~/Makefile:1: Replacing \"line\" with \"row\".",
+               "-\t# line 1 \\",
+               "+\t# row 1 \\",
+               "\tcontinuation 1 \\",
+               "\tcontinuation 2")
+}
+
+func (s *Suite) Test_Autofix_ReplaceAfter__autofix_several_times_in_continuation_line(c *check.C) {
        t := s.Init(c)
 
        t.SetUpCommandLine("--autofix", "--source")
@@ -97,12 +117,25 @@
        fix.ReplaceAfter("", "n", "v")
        fix.Apply()
 
-       t.CheckOutputLines(
-               "AUTOFIX: ~/Makefile:1: Replacing \"n\" with \"v\".",
-               "-\t# line 1 \\",
-               "+\t# live 1 \\",
-               "\tcontinuation 1 \\",
-               "\tcontinuation 2")
+       // Nothing is logged or fixed because the "n" appears more than once,
+       // and as of June 2019, pkglint doesn't know which occurrence is the
+       // correct one.
+       t.CheckOutputEmpty()
+}
+
+func (s *Suite) Test_Autofix_ReplaceAfter__autofix_one_time(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpCommandLine("--autofix", "--source")
+       mklines := t.SetUpFileMkLines("Makefile",
+               MkCvsID,
+               "VAR=\t$$(var) $(var)")
+
+       mklines.Check()
+
+       // Nothing is replaced since, as of June 2019, pkglint doesn't
+       // know which of the two "$(var)" should be replaced.
+       t.CheckOutputEmpty()
 }
 
 func (s *Suite) Test_Autofix_ReplaceRegex__show_autofix(c *check.C) {
@@ -157,19 +190,19 @@
 
        // After calling fix.Apply above, the autofix is ready to be used again.
        fix.Warnf("Use Y instead of X.")
-       fix.Replace("X", "Y")
+       fix.Replace("XXX", "YYY")
        fix.Apply()
 
        t.CheckOutputLines(
-               "AUTOFIX: ~/Makefile:2: Replacing \"X\" with \"Y\".",
+               "AUTOFIX: ~/Makefile:2: Replacing \"XXX\" with \"YYY\".",
                "-\tline2",
-               "+\tYXXe2")
+               "+\tYYYe2")
 
        SaveAutofixChanges(lines)
 
        t.CheckFileLines("Makefile",
                "line1",
-               "YXXe2",
+               "YYYe2",
                "line3")
 }
 
@@ -188,7 +221,7 @@
        fix.Apply()
 



Home | Main Index | Thread Index | Old Index