Source-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 20.2.1



details:   https://anonhg.NetBSD.org/pkgsrc/rev/00dc35390288
branches:  trunk
changeset: 435161:00dc35390288
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Jul 01 13:17:41 2020 +0000

description:
pkgtools/pkglint: update to 20.2.1

Changes since 20.2.0:

Don't warn about a possibly redundant PKGNAME=${DISTNAME} assignment if
PKGNAME is defined somewhere else in the package Makefile.

Warn if NO_CONFIGURE=yes and REPLACE_* are combined.

Suggest to replace ${VAR:@l@-l${l}@} with the simpler ${VAR:S,^,-l,},
as well as ${VAR:@l@${l}suffix@} with the simpler ${VAR:=suffix}.

Allow lua in CATEGORIES.

diffstat:

 pkgtools/pkglint/Makefile                      |    4 +-
 pkgtools/pkglint/files/autofix.go              |    1 +
 pkgtools/pkglint/files/check_test.go           |    2 -
 pkgtools/pkglint/files/line.go                 |    4 -
 pkgtools/pkglint/files/mkcondchecker.go        |    4 +-
 pkgtools/pkglint/files/mklexer.go              |   32 +-
 pkgtools/pkglint/files/mklexer_test.go         |   27 +-
 pkgtools/pkglint/files/mkline.go               |    2 +-
 pkgtools/pkglint/files/mkparser_test.go        |    8 +-
 pkgtools/pkglint/files/mkshparser.go           |    6 +-
 pkgtools/pkglint/files/mktokenslexer.go        |    1 +
 pkgtools/pkglint/files/mktokenslexer_test.go   |  468 ++++++++++++++----------
 pkgtools/pkglint/files/mktypes.go              |   41 +-
 pkgtools/pkglint/files/mktypes_test.go         |  131 +++++-
 pkgtools/pkglint/files/mkvarusechecker.go      |   60 ++-
 pkgtools/pkglint/files/mkvarusechecker_test.go |   63 +++
 pkgtools/pkglint/files/package.go              |   70 ++-
 pkgtools/pkglint/files/package_test.go         |   45 ++-
 pkgtools/pkglint/files/pkglint_test.go         |   10 +-
 pkgtools/pkglint/files/plist.go                |   21 +-
 pkgtools/pkglint/files/plist_test.go           |   99 ++++-
 pkgtools/pkglint/files/shell.go                |    2 +-
 pkgtools/pkglint/files/shell.y                 |    1 +
 pkgtools/pkglint/files/shell_test.go           |   27 +
 pkgtools/pkglint/files/shtokenizer_test.go     |    6 +-
 pkgtools/pkglint/files/vartypecheck.go         |    8 +-
 pkgtools/pkglint/files/vartypecheck_test.go    |    1 +
 27 files changed, 831 insertions(+), 313 deletions(-)

diffs (truncated from 1921 to 300 lines):

diff -r 1937a3b7285d -r 00dc35390288 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Wed Jul 01 13:03:38 2020 +0000
+++ b/pkgtools/pkglint/Makefile Wed Jul 01 13:17:41 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.660 2020/06/28 10:19:11 rillig Exp $
+# $NetBSD: Makefile,v 1.661 2020/07/01 13:17:41 rillig Exp $
 
-PKGNAME=       pkglint-20.2.0
+PKGNAME=       pkglint-20.2.1
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 1937a3b7285d -r 00dc35390288 pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Wed Jul 01 13:03:38 2020 +0000
+++ b/pkgtools/pkglint/files/autofix.go Wed Jul 01 13:17:41 2020 +0000
@@ -96,6 +96,7 @@
 
 // Replace replaces "from" with "to", a single time.
 // If the text is not found exactly once, nothing is replaced at all.
+// The diagnostic is given nevertheless, to allow humans to fix it.
 func (fix *Autofix) Replace(from string, to string) {
        fix.ReplaceAfter("", from, to)
 }
diff -r 1937a3b7285d -r 00dc35390288 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Wed Jul 01 13:03:38 2020 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Wed Jul 01 13:17:41 2020 +0000
@@ -119,8 +119,6 @@
        ck.Configure("mkshparser.go", "*", "*", -intqa.EMissingTest)     // TODO
        ck.Configure("mkshtypes.go", "*", "*", -intqa.EMissingTest)      // TODO
        ck.Configure("mkshwalker.go", "*", "*", -intqa.EMissingTest)     // TODO
-       ck.Configure("mktokenslexer.go", "*", "*", -intqa.EMissingTest)  // TODO
-       ck.Configure("mktypes.go", "*", "*", -intqa.EMissingTest)        // TODO
        ck.Configure("options.go", "*", "*", -intqa.EMissingTest)        // TODO
        ck.Configure("package.go", "*", "*", -intqa.EMissingTest)        // TODO
        ck.Configure("paragraph.go", "*", "*", -intqa.EMissingTest)      // TODO
diff -r 1937a3b7285d -r 00dc35390288 pkgtools/pkglint/files/line.go
--- a/pkgtools/pkglint/files/line.go    Wed Jul 01 13:03:38 2020 +0000
+++ b/pkgtools/pkglint/files/line.go    Wed Jul 01 13:17:41 2020 +0000
@@ -53,8 +53,6 @@
 
 // Line represents a line of text from a file.
 type Line struct {
-       // TODO: Consider storing pointers to the Filename and Basename instead of strings to save memory.
-       //  But first find out where and why pkglint needs so much memory (200 MB for a full recursive run over pkgsrc + wip).
        Location Location
        Basename RelPath // the last component of the Filename
 
@@ -66,8 +64,6 @@
        raw  []*RawLine // contains the original text including trailing newline
        fix  *Autofix   // any changes that pkglint would like to apply to the line
        once Once
-
-       // XXX: Filename and Basename could be replaced with a pointer to a Lines object.
 }
 
 func NewLine(filename CurrPath, lineno int, text string, rawLine *RawLine) *Line {
diff -r 1937a3b7285d -r 00dc35390288 pkgtools/pkglint/files/mkcondchecker.go
--- a/pkgtools/pkglint/files/mkcondchecker.go   Wed Jul 01 13:03:38 2020 +0000
+++ b/pkgtools/pkglint/files/mkcondchecker.go   Wed Jul 01 13:17:41 2020 +0000
@@ -141,7 +141,7 @@
                        continue
                }
 
-               switch modifier.Text {
+               switch modifier.String() {
                default:
                        return
                case "O", "u":
@@ -256,7 +256,7 @@
        fix := ck.MkLine.Autofix()
        fix.Notef("%s can be compared using the simpler \"%s\" "+
                "instead of matching against %q.",
-               varname, to, ":"+modifier.Text)
+               varname, to, ":"+modifier.String()) // TODO: Quoted
        fix.Explain(
                "This variable has a single value, not a list of values.",
                "Therefore it feels strange to apply list operators like :M and :N onto it.",
diff -r 1937a3b7285d -r 00dc35390288 pkgtools/pkglint/files/mklexer.go
--- a/pkgtools/pkglint/files/mklexer.go Wed Jul 01 13:03:38 2020 +0000
+++ b/pkgtools/pkglint/files/mklexer.go Wed Jul 01 13:17:41 2020 +0000
@@ -226,7 +226,7 @@
        for lexer.SkipByte(':') || mayOmitColon {
                modifier := p.varUseModifier(varname, closing)
                if modifier != "" {
-                       modifiers = append(modifiers, MkVarUseModifier{modifier})
+                       modifiers = append(modifiers, modifier)
                }
                mayOmitColon = modifier != "" && (modifier[0] == 'S' || modifier[0] == 'C')
        }
@@ -235,7 +235,7 @@
 
 // varUseModifier parses a single variable modifier such as :Q or :S,from,to,.
 // The actual parsing starts after the leading colon.
-func (p *MkLexer) varUseModifier(varname string, closing byte) string {
+func (p *MkLexer) varUseModifier(varname string, closing byte) MkVarUseModifier {
        lexer := p.lexer
        mark := lexer.Mark()
 
@@ -260,32 +260,32 @@
                        "tu", // To uppercase
                        "tw", // Causes the value to be treated as list of words
                        "u":  // Remove adjacent duplicate words (like uniq(1))
-                       return mod
+                       return MkVarUseModifier(mod)
                }
 
-               if hasPrefix(mod, "ts") {
+               if MkVarUseModifier(mod).HasPrefix("ts") {
                        return p.varUseModifierTs(mod, closing, lexer, varname, mark)
                }
 
        case 'D', 'U':
-               return p.varUseText(closing)
+               return MkVarUseModifier(p.varUseText(closing))
 
        case 'M', 'N':
                return p.varUseModifierMatch(closing)
 
        case 'C', 'S':
                if ok, _, _, _, _ := p.varUseModifierSubst(closing); ok {
-                       return lexer.Since(mark)
+                       return MkVarUseModifier(lexer.Since(mark))
                }
 
        case '@':
                if p.varUseModifierAt(lexer, varname) {
-                       return lexer.Since(mark)
+                       return MkVarUseModifier(lexer.Since(mark))
                }
 
        case '[':
                if lexer.SkipRegexp(regcomp(`^\[(?:[-.\d]+|#)\]`)) {
-                       return lexer.Since(mark)
+                       return MkVarUseModifier(lexer.Since(mark))
                }
 
        case '?':
@@ -293,7 +293,7 @@
                p.varUseText(closing)
                if lexer.SkipByte(':') {
                        p.varUseText(closing)
-                       return lexer.Since(mark)
+                       return MkVarUseModifier(lexer.Since(mark))
                }
 
        case ':':
@@ -328,7 +328,7 @@
                        "but even these have only local consequences.")
 
                p.varUseText(closing)
-               return lexer.Since(mark)
+               return MkVarUseModifier(lexer.Since(mark))
        }
 
        // ${SOURCES:%.c=%.o}
@@ -342,14 +342,14 @@
                                "The :from=to modifier consumes all the text until the end of the variable.",
                                "There cannot be any further modifiers after it.")
                }
-               return modifier
+               return MkVarUseModifier(modifier)
        }
 
        // ${:!uname -a!:[2]}
        lexer.Reset(mark)
        modifier = p.varUseText(closing)
        if hasPrefix(modifier, "!") && hasSuffix(modifier, "!") {
-               return modifier
+               return MkVarUseModifier(modifier)
        }
 
        if modifier != "" {
@@ -365,7 +365,7 @@
 // It is only extracted from varUseModifier to make the latter smaller.
 func (p *MkLexer) varUseModifierTs(
        mod string, closing byte, lexer *textproc.Lexer, varname string,
-       mark textproc.LexerMark) string {
+       mark textproc.LexerMark) MkVarUseModifier {
 
        // See devel/bmake/files/var.c:/case 't'
        sep := mod[2:] + p.varUseText(closing)
@@ -383,13 +383,13 @@
                        "or an escape sequence like \\t or \\n or an octal or decimal escape",
                        "sequence; see the bmake man page for further details.")
        }
-       return lexer.Since(mark)
+       return MkVarUseModifier(lexer.Since(mark))
 }
 
 // varUseModifierMatch parses an :M or :N pattern.
 //
 // See devel/bmake/files/var.c:/^ApplyModifiers/, case 'M'.
-func (p *MkLexer) varUseModifierMatch(closing byte) string {
+func (p *MkLexer) varUseModifierMatch(closing byte) MkVarUseModifier {
        lexer := p.lexer
        mark := lexer.Mark()
        lexer.Skip(1)
@@ -427,7 +427,7 @@
                re := regex.Pattern(condStr(closing == '}', `\\([:}])`, `\\([:)])`))
                arg = replaceAll(arg, re, "$1")
        }
-       return arg
+       return MkVarUseModifier(arg)
 }
 
 // varUseModifierSubst parses a :S,from,to, or a :C,from,to, modifier.
diff -r 1937a3b7285d -r 00dc35390288 pkgtools/pkglint/files/mklexer_test.go
--- a/pkgtools/pkglint/files/mklexer_test.go    Wed Jul 01 13:03:38 2020 +0000
+++ b/pkgtools/pkglint/files/mklexer_test.go    Wed Jul 01 13:17:41 2020 +0000
@@ -605,8 +605,9 @@
 
        varUse := p.VarUse()
 
-       t.CheckDeepEquals(varUse.modifiers, []MkVarUseModifier{
-               {"R"}, {"E"}, {"Ox"}, {"tA"}, {"tW"}, {"tw"}})
+       t.CheckDeepEquals(
+               varUse.modifiers,
+               []MkVarUseModifier{"R", "E", "Ox", "tA", "tW", "tw"})
 }
 
 func (s *Suite) Test_MkLexer_varUseModifier__S_parse_error(c *check.C) {
@@ -617,7 +618,7 @@
 
        mod := p.varUseModifier("VAR", '}')
 
-       t.CheckEquals(mod, "")
+       t.CheckEquals(mod, MkVarUseModifier(""))
        // XXX: The "S," has just disappeared.
        t.CheckEquals(p.Rest(), "}")
 
@@ -634,7 +635,7 @@
 
        modifier := p.varUseModifier("VAR", '}')
 
-       t.CheckEquals(modifier, "tsabc")
+       t.CheckEquals(modifier, MkVarUseModifier("tsabc"))
        t.CheckEquals(p.Rest(), "}")
        t.CheckOutputLines(
                "WARN: filename.mk:123: Invalid separator \"abc\" for :ts modifier of \"VAR\".",
@@ -652,7 +653,7 @@
 
        modifier := p.varUseModifier("VAR", '}')
 
-       t.CheckEquals(modifier, "tsabc")
+       t.CheckEquals(modifier, MkVarUseModifier("tsabc"))
        t.CheckEquals(p.Rest(), "}")
 }
 
@@ -664,7 +665,7 @@
 
        modifier := p.varUseModifier("VAR", '}')
 
-       t.CheckEquals(modifier, "")
+       t.CheckEquals(modifier, MkVarUseModifier(""))
        t.CheckEquals(p.Rest(), "")
 
        t.CheckOutputLines(
@@ -725,7 +726,7 @@
 func (s *Suite) Test_MkLexer_varUseModifier__eq_suffix_replacement(c *check.C) {
        t := s.Init(c)
 
-       test := func(input, modifier, rest string, diagnostics ...string) {
+       test := func(input string, modifier MkVarUseModifier, rest string, diagnostics ...string) {
                line := t.NewLine("filename.mk", 123, "")
                p := NewMkLexer(input, line)
 
@@ -762,7 +763,7 @@
 func (s *Suite) Test_MkLexer_varUseModifier__assigment(c *check.C) {
        t := s.Init(c)
 
-       test := func(varname, input, modifier, rest string, diagnostics ...string) {
+       test := func(varname, input string, modifier MkVarUseModifier, rest string, diagnostics ...string) {
                line := t.NewLine("filename.mk", 123, "")
                p := NewMkLexer(input, line)
 
@@ -807,7 +808,7 @@
 func (s *Suite) Test_MkLexer_varUseModifierTs(c *check.C) {
        t := s.Init(c)
 
-       test := func(input string, closing byte, mod string, rest string, diagnostics ...string) {
+       test := func(input string, closing byte, mod MkVarUseModifier, rest string, diagnostics ...string) {
                diag := t.NewLine("filename.mk", 123, "")
                lex := NewMkLexer(input, diag)
                mark := lex.lexer.Mark()
@@ -851,7 +852,7 @@
 func (s *Suite) Test_MkLexer_varUseModifierMatch(c *check.C) {
        t := s.Init(c)
 
-       testClosing := func(input string, closing byte, modifier, rest string, diagnostics ...string) {
+       testClosing := func(input string, closing byte, modifier MkVarUseModifier, rest string, diagnostics ...string) {
                line := t.NewLine("filename.mk", 123, "")
                p := NewMkLexer(input, line)
 
@@ -862,10 +863,10 @@
                t.CheckOutput(diagnostics)
        }
 
-       test := func(input, modifier, rest string, diagnostics ...string) {
+       test := func(input string, modifier MkVarUseModifier, rest string, diagnostics ...string) {
                testClosing(input, '}', modifier, rest, diagnostics...)



Home | Main Index | Thread Index | Old Index