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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e0dd8b89c050
branches:  trunk
changeset: 357282:e0dd8b89c050
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue Jan 17 22:37:27 2017 +0000

description:
Updated pkglint to 5.4.16.

Changes since 5.4.15:

* updated vardefs from mk/defaults/mk.conf from v1.118 (2006) to v1.269
  Gone:
  * PKG_SUFX
  * USETBL
  * PKGSRC_SHOW_PATCH_ERRORMSG
  * USE_XPKGWEDGE
  * PKGVULNDIR
  Adjusted:
  * USE_GAMESGROUP
  * BIN_INSTALL_FLAG -> BIN_INSTALL_FLAGS

* fixed license parsing to be more realistic
  (the previous version didn't handle parentheses correctly)

* lots of housekeeping
  * moved some code to separate packages, allowing re-use
  * separated Line checks into LineChecker type
  * separated MkLine checks into MkLineChecker type
  * made Line an interface, for further refactorings

diffstat:

 pkgtools/pkglint/Makefile                         |     4 +-
 pkgtools/pkglint/files/buildlink3.go              |    27 +-
 pkgtools/pkglint/files/category.go                |    15 +-
 pkgtools/pkglint/files/check_test.go              |    18 +-
 pkgtools/pkglint/files/distinfo.go                |    35 +-
 pkgtools/pkglint/files/expecter.go                |    37 +-
 pkgtools/pkglint/files/files.go                   |    22 +-
 pkgtools/pkglint/files/files_test.go              |     2 +-
 pkgtools/pkglint/files/getopt/getopt_test.go      |     3 +-
 pkgtools/pkglint/files/globaldata.go              |    60 +-
 pkgtools/pkglint/files/globaldata_test.go         |     5 +-
 pkgtools/pkglint/files/globalvars.go              |    15 +-
 pkgtools/pkglint/files/histogram/histogram.go     |    55 +
 pkgtools/pkglint/files/license.y                  |    35 -
 pkgtools/pkglint/files/licenses.go                |    95 +-
 pkgtools/pkglint/files/licenses/licenses.go       |    96 +
 pkgtools/pkglint/files/licenses/licenses.y        |    37 +
 pkgtools/pkglint/files/licenses/licenses_test.go  |   106 +
 pkgtools/pkglint/files/licenses_test.go           |     5 -
 pkgtools/pkglint/files/line.go                    |   179 +-
 pkgtools/pkglint/files/line_test.go               |    37 +-
 pkgtools/pkglint/files/linechecker.go             |    81 +
 pkgtools/pkglint/files/linechecker_test.go        |    38 +
 pkgtools/pkglint/files/logging.go                 |     7 +-
 pkgtools/pkglint/files/mkline.go                  |  1141 +--------------------
 pkgtools/pkglint/files/mkline_test.go             |   332 +-----
 pkgtools/pkglint/files/mklinechecker.go           |  1118 ++++++++++++++++++++
 pkgtools/pkglint/files/mklinechecker_test.go      |   255 ++++
 pkgtools/pkglint/files/mklines.go                 |    52 +-
 pkgtools/pkglint/files/mklines_test.go            |     4 +-
 pkgtools/pkglint/files/mkparser.go                |    44 +-
 pkgtools/pkglint/files/mkshparser.go              |    15 +-
 pkgtools/pkglint/files/mkshtypes.go               |     7 +-
 pkgtools/pkglint/files/package.go                 |   130 +-
 pkgtools/pkglint/files/parser.go                  |    57 +-
 pkgtools/pkglint/files/patches.go                 |    91 +-
 pkgtools/pkglint/files/patches_test.go            |     2 +-
 pkgtools/pkglint/files/pkglint.go                 |    89 +-
 pkgtools/pkglint/files/pkglint_test.go            |     5 +-
 pkgtools/pkglint/files/pkgver/vercmp_test.go      |     2 +-
 pkgtools/pkglint/files/plist.go                   |    34 +-
 pkgtools/pkglint/files/regex.go                   |   112 --
 pkgtools/pkglint/files/regex/regex.go             |   146 ++
 pkgtools/pkglint/files/shell.go                   |   144 +-
 pkgtools/pkglint/files/shell_test.go              |    10 +-
 pkgtools/pkglint/files/shtokenizer.go             |    94 +-
 pkgtools/pkglint/files/substcontext.go            |     2 +-
 pkgtools/pkglint/files/textproc/prefixreplacer.go |   136 ++
 pkgtools/pkglint/files/toplevel.go                |    10 +-
 pkgtools/pkglint/files/trace/tracing.go           |   114 ++
 pkgtools/pkglint/files/util.go                    |   317 +----
 pkgtools/pkglint/files/util_test.go               |     6 +-
 pkgtools/pkglint/files/vardefs.go                 |   241 ++++-
 pkgtools/pkglint/files/vartypecheck.go            |    80 +-
 pkgtools/pkglint/files/vartypecheck_test.go       |    11 +-
 55 files changed, 3217 insertions(+), 2598 deletions(-)

diffs (truncated from 8868 to 300 lines):

diff -r 524e4d00101c -r e0dd8b89c050 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Tue Jan 17 19:44:32 2017 +0000
+++ b/pkgtools/pkglint/Makefile Tue Jan 17 22:37:27 2017 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.508 2017/01/11 23:20:13 tron Exp $
+# $NetBSD: Makefile,v 1.509 2017/01/17 22:37:27 rillig Exp $
 
-PKGNAME=       pkglint-5.4.15
+PKGNAME=       pkglint-5.4.16
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r 524e4d00101c -r e0dd8b89c050 pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go      Tue Jan 17 19:44:32 2017 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go      Tue Jan 17 22:37:27 2017 +0000
@@ -2,12 +2,13 @@
 
 import (
        "netbsd.org/pkglint/pkgver"
+       "netbsd.org/pkglint/trace"
        "strings"
 )
 
 func ChecklinesBuildlink3Mk(mklines *MkLines) {
-       if G.opts.Debug {
-               defer tracecall1(mklines.lines[0].Fname)()
+       if trace.Tracing {
+               defer trace.Call1(mklines.lines[0].Filename())()
        }
 
        mklines.Check()
@@ -17,7 +18,7 @@
        for exp.AdvanceIfPrefix("#") {
                line := exp.PreviousLine()
                // See pkgtools/createbuildlink/files/createbuildlink
-               if hasPrefix(line.Text, "# XXX This file was created automatically") {
+               if hasPrefix(line.Text(), "# XXX This file was created automatically") {
                        line.Errorf("This comment indicates unfinished work (url2pkg).")
                }
        }
@@ -31,7 +32,7 @@
        }
 
        pkgbaseLine, pkgbase := exp.CurrentLine(), ""
-       var abiLine, apiLine *Line
+       var abiLine, apiLine Line
        var abi, api *DependencyPattern
 
        // First paragraph: Introduction of the package identifier
@@ -42,7 +43,7 @@
        pkgbase = exp.m[1]
        if containsVarRef(pkgbase) {
                warned := false
-               for _, pair := range []struct{ varuse, simple string }{
+               for _, pair := range [...]struct{ varuse, simple string }{
                        {"${PYPKGPREFIX}", "py"},
                        {"${RUBY_BASE}", "ruby"},
                        {"${RUBY_PKGPREFIX}", "ruby"},
@@ -133,16 +134,16 @@
                                }
                                doCheck = true
                        }
-                       if doCheck && abi != nil && api != nil && abi.pkgbase != api.pkgbase && !hasPrefix(api.pkgbase, "{") {
+                       if doCheck && abi != nil && api != nil && abi.Pkgbase != api.Pkgbase && !hasPrefix(api.Pkgbase, "{") {
                                abiLine.Warnf("Package name mismatch between ABI %q and API %q (from %s).",
-                                       abi.pkgbase, api.pkgbase, apiLine.ReferenceFrom(abiLine))
+                                       abi.Pkgbase, api.Pkgbase, apiLine.ReferenceFrom(abiLine))
                        }
                        if doCheck {
-                               if abi != nil && abi.lower != "" && !containsVarRef(abi.lower) {
-                                       if api != nil && api.lower != "" && !containsVarRef(api.lower) {
-                                               if pkgver.Compare(abi.lower, api.lower) < 0 {
+                               if abi != nil && abi.Lower != "" && !containsVarRef(abi.Lower) {
+                                       if api != nil && api.Lower != "" && !containsVarRef(api.Lower) {
+                                               if pkgver.Compare(abi.Lower, api.Lower) < 0 {
                                                        abiLine.Warnf("ABI version %q should be at least API version %q (see %s).",
-                                                               abi.lower, api.lower, apiLine.ReferenceFrom(abiLine))
+                                                               abi.Lower, api.Lower, apiLine.ReferenceFrom(abiLine))
                                                }
                                        }
                                }
@@ -175,8 +176,8 @@
                        }
 
                } else {
-                       if G.opts.Debug {
-                               traceStep1("Unchecked line %s in third paragraph.", exp.CurrentLine().linenos())
+                       if trace.Tracing {
+                               trace.Step1("Unchecked line %s in third paragraph.", exp.CurrentLine().Linenos())
                        }
                        exp.Advance()
                }
diff -r 524e4d00101c -r e0dd8b89c050 pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Tue Jan 17 19:44:32 2017 +0000
+++ b/pkgtools/pkglint/files/category.go        Tue Jan 17 22:37:27 2017 +0000
@@ -1,12 +1,13 @@
 package main
 
 import (
+       "netbsd.org/pkglint/trace"
        "sort"
 )
 
 func CheckdirCategory() {
-       if G.opts.Debug {
-               defer tracecall1(G.CurrentDir)()
+       if trace.Tracing {
+               defer trace.Call1(G.CurrentDir)()
        }
 
        lines := LoadNonemptyLines(G.CurrentDir+"/Makefile", true)
@@ -23,7 +24,7 @@
        exp.ExpectEmptyLine()
 
        if exp.AdvanceIfMatches(`^COMMENT=\t*(.*)`) {
-               mklines.mklines[exp.index-1].CheckValidCharactersInValue(`[- '(),/0-9A-Za-z]`)
+               MkLineChecker{mklines.mklines[exp.index-1]}.CheckValidCharactersInValue(`[- '(),/0-9A-Za-z]`)
        } else {
                exp.CurrentLine().Errorf("COMMENT= line expected.")
        }
@@ -31,7 +32,7 @@
 
        type subdir struct {
                name   string
-               line   *Line
+               line   Line
                active bool
        }
 
@@ -46,7 +47,7 @@
        prevSubdir := ""
        for !exp.EOF() {
                line := exp.CurrentLine()
-               text := line.Text
+               text := line.Text()
 
                if m, commentFlag, indentation, name, comment := match4(text, `^(#?)SUBDIR\+=(\s*)(\S+)\s*(?:#\s*(.*?)\s*|)$`); m {
                        commentedOut := commentFlag == "#"
@@ -71,7 +72,7 @@
                        exp.Advance()
 
                } else {
-                       if line.Text != "" {
+                       if line.Text() != "" {
                                line.Errorf("SUBDIR+= line or empty line expected.")
                        }
                        break
@@ -95,7 +96,7 @@
 
        var subdirs []string
 
-       var line *Line
+       var line Line
        mActive := false
 
        for !(mAtend && fAtend) {
diff -r 524e4d00101c -r e0dd8b89c050 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Tue Jan 17 19:44:32 2017 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Tue Jan 17 22:37:27 2017 +0000
@@ -11,6 +11,8 @@
        "testing"
 
        check "gopkg.in/check.v1"
+       "netbsd.org/pkglint/textproc"
+       "netbsd.org/pkglint/trace"
 )
 
 var equals = check.Equals
@@ -79,8 +81,8 @@
        return rawlines[:j]
 }
 
-func (s *Suite) NewLines(fname string, texts ...string) []*Line {
-       result := make([]*Line, len(texts))
+func (s *Suite) NewLines(fname string, texts ...string) []Line {
+       result := make([]Line, len(texts))
        for i, text := range texts {
                textnl := text + "\n"
                result[i] = NewLine(fname, i+1, text, s.NewRawLines(i+1, textnl))
@@ -93,15 +95,15 @@
 }
 
 func (s *Suite) BeginDebugToStdout() {
-       G.debugOut = os.Stdout
        G.logOut = os.Stdout
-       G.opts.Debug = true
+       trace.Out = os.Stdout
+       trace.Tracing = true
 }
 
 func (s *Suite) EndDebugToStdout() {
-       G.debugOut = &s.stdout
        G.logOut = &s.stdout
-       G.opts.Debug = false
+       trace.Out = &s.stdout
+       trace.Tracing = false
 }
 
 func (s *Suite) UseCommandLine(args ...string) {
@@ -185,7 +187,8 @@
 
 func (s *Suite) SetUpTest(c *check.C) {
        G = GlobalVars{Testing: true}
-       G.logOut, G.logErr, G.debugOut = &s.stdout, &s.stderr, &s.stdout
+       textproc.Testing = true
+       G.logOut, G.logErr, trace.Out = &s.stdout, &s.stderr, &s.stdout
        s.checkC = c
        s.UseCommandLine( /* no arguments */ )
        s.checkC = nil
@@ -194,6 +197,7 @@
 
 func (s *Suite) TearDownTest(c *check.C) {
        G = GlobalVars{}
+       textproc.Testing = false
        if out := s.Output(); out != "" {
                fmt.Fprintf(os.Stderr, "Unchecked output in %q; check with: c.Check(s.Output(), equals, %q)", c.TestName(), out)
        }
diff -r 524e4d00101c -r e0dd8b89c050 pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Tue Jan 17 19:44:32 2017 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Tue Jan 17 22:37:27 2017 +0000
@@ -5,15 +5,16 @@
        "crypto/sha1"
        "fmt"
        "io/ioutil"
+       "netbsd.org/pkglint/trace"
        "strings"
 )
 
-func ChecklinesDistinfo(lines []*Line) {
-       if G.opts.Debug {
-               defer tracecall1(lines[0].Fname)()
+func ChecklinesDistinfo(lines []Line) {
+       if trace.Tracing {
+               defer trace.Call1(lines[0].Filename())()
        }
 
-       fname := lines[0].Fname
+       fname := lines[0].Filename()
        patchesDir := "patches"
        patchesDirSet := false
        if G.Pkg != nil && contains(fname, "lang/php") {
@@ -26,8 +27,8 @@
        if G.Pkg != nil && !patchesDirSet && dirExists(G.CurrentDir+"/"+G.Pkg.Patchdir) {
                patchesDir = G.Pkg.Patchdir
        }
-       if G.opts.Debug {
-               traceStep1("patchesDir=%q", patchesDir)
+       if trace.Tracing {
+               trace.Step1("patchesDir=%q", patchesDir)
        }
 
        ck := &distinfoLinesChecker{
@@ -45,15 +46,15 @@
        distinfoIsCommitted bool
 
        patches          map[string]bool // "patch-aa" => true
-       currentFirstLine *Line
+       currentFirstLine Line
        currentFilename  string
        isPatch          bool
        algorithms       []string
 }
 
-func (ck *distinfoLinesChecker) checkLines(lines []*Line) {
-       lines[0].CheckRcsid(``, "")
-       if 1 < len(lines) && lines[1].Text != "" {
+func (ck *distinfoLinesChecker) checkLines(lines []Line) {
+       LineChecker{lines[0]}.CheckRcsid(``, "")
+       if 1 < len(lines) && lines[1].Text() != "" {
                lines[1].Notef("Empty line expected.")
        }
 
@@ -61,7 +62,7 @@
                if i < 2 {
                        continue
                }
-               m, alg, filename, hash := match3(line.Text, `^(\w+) \((\w[^)]*)\) = (.*)(?: bytes)?$`)
+               m, alg, filename, hash := match3(line.Text(), `^(\w+) \((\w[^)]*)\) = (.*)(?: bytes)?$`)
                if !m {
                        line.Errorf("Invalid line.")
                        continue
@@ -78,7 +79,7 @@
        ck.onFilenameChange(NewLineEOF(ck.distinfoFilename), "")
 }
 
-func (ck *distinfoLinesChecker) onFilenameChange(line *Line, nextFname string) {
+func (ck *distinfoLinesChecker) onFilenameChange(line Line, nextFname string) {
        currentFname := ck.currentFilename
        if currentFname != "" {
                algorithms := strings.Join(ck.algorithms, ", ")
@@ -105,7 +106,7 @@
        ck.algorithms = nil
 }
 
-func (ck *distinfoLinesChecker) checkPatchSha1(line *Line, patchFname, distinfoSha1Hex string) {
+func (ck *distinfoLinesChecker) checkPatchSha1(line Line, patchFname, distinfoSha1Hex string) {
        patchBytes, err := ioutil.ReadFile(G.CurrentDir + "/" + patchFname)
        if err != nil {
                line.Errorf("%s does not exist.", patchFname)
@@ -130,8 +131,8 @@



Home | Main Index | Thread Index | Old Index