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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/bc6496ed5f0c
branches:  trunk
changeset: 373413:bc6496ed5f0c
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Jan 01 18:04:15 2018 +0000

description:
Updated pkglint to 5.4.22.

Changes since 5.4.21:
* Refactoring: moved packages line and linechecks back into main
* Fixed panic when autofixing package Makefiles
* Removed apache22
* Added a bit of inline documentation

diffstat:

 pkgtools/pkglint/Makefile                             |    4 +-
 pkgtools/pkglint/files/buildlink3.go                  |   10 +-
 pkgtools/pkglint/files/category.go                    |   12 +-
 pkgtools/pkglint/files/check_test.go                  |    7 +-
 pkgtools/pkglint/files/distinfo.go                    |   26 +--
 pkgtools/pkglint/files/expecter.go                    |  111 +++++++++++++++++
 pkgtools/pkglint/files/files.go                       |   28 ++-
 pkgtools/pkglint/files/files_test.go                  |   28 ++++-
 pkgtools/pkglint/files/globaldata.go                  |   27 ++--
 pkgtools/pkglint/files/globalvars.go                  |    5 +-
 pkgtools/pkglint/files/line.go                        |   59 +++------
 pkgtools/pkglint/files/line/line.go                   |   30 ----
 pkgtools/pkglint/files/line_test.go                   |   16 +-
 pkgtools/pkglint/files/linechecker.go                 |  106 +++++++++++++++++
 pkgtools/pkglint/files/linechecker_test.go            |   45 +++++++
 pkgtools/pkglint/files/linechecks/linechecker.go      |  109 -----------------
 pkgtools/pkglint/files/linechecks/linechecker_test.go |   76 ------------
 pkgtools/pkglint/files/mkline.go                      |   59 +--------
 pkgtools/pkglint/files/mkline_test.go                 |   28 ++--
 pkgtools/pkglint/files/mklinechecker.go               |   25 +--
 pkgtools/pkglint/files/mklinechecker_test.go          |    2 +-
 pkgtools/pkglint/files/mklines.go                     |   12 +-
 pkgtools/pkglint/files/mkparser.go                    |    3 +-
 pkgtools/pkglint/files/mkshparser.go                  |    3 +-
 pkgtools/pkglint/files/mkshtypes.go                   |   30 ++++-
 pkgtools/pkglint/files/mkshwalker.go                  |    2 +
 pkgtools/pkglint/files/mktypes.go                     |    4 +
 pkgtools/pkglint/files/package.go                     |   49 +++----
 pkgtools/pkglint/files/parser.go                      |    5 +-
 pkgtools/pkglint/files/patches.go                     |   41 +++---
 pkgtools/pkglint/files/patches_test.go                |    2 +-
 pkgtools/pkglint/files/pkglint.go                     |   34 ++--
 pkgtools/pkglint/files/plist.go                       |   26 +--
 pkgtools/pkglint/files/shell.go                       |   22 +-
 pkgtools/pkglint/files/shtokenizer.go                 |    3 +-
 pkgtools/pkglint/files/textproc/expecter.go           |  112 ------------------
 pkgtools/pkglint/files/textproc/prefixreplacer.go     |    1 +
 pkgtools/pkglint/files/toplevel.go                    |    5 +-
 pkgtools/pkglint/files/util.go                        |    9 +-
 pkgtools/pkglint/files/vardefs.go                     |    3 +
 pkgtools/pkglint/files/vartypecheck.go                |   14 +-
 pkgtools/pkglint/files/vartypecheck_test.go           |    6 +-
 42 files changed, 554 insertions(+), 645 deletions(-)

diffs (truncated from 2673 to 300 lines):

diff -r 193acb3a283b -r bc6496ed5f0c pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Mon Jan 01 17:43:20 2018 +0000
+++ b/pkgtools/pkglint/Makefile Mon Jan 01 18:04:15 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.518 2017/10/08 22:31:13 rillig Exp $
+# $NetBSD: Makefile,v 1.519 2018/01/01 18:04:15 rillig Exp $
 
-PKGNAME=       pkglint-5.4.21
+PKGNAME=       pkglint-5.4.22
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r 193acb3a283b -r bc6496ed5f0c pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go      Mon Jan 01 17:43:20 2018 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go      Mon Jan 01 18:04:15 2018 +0000
@@ -1,26 +1,24 @@
 package main
 
 import (
-       "netbsd.org/pkglint/line"
        "netbsd.org/pkglint/pkgver"
-       "netbsd.org/pkglint/textproc"
        "netbsd.org/pkglint/trace"
        "strings"
 )
 
 func ChecklinesBuildlink3Mk(mklines *MkLines) {
        if trace.Tracing {
-               defer trace.Call1(mklines.lines[0].Filename())()
+               defer trace.Call1(mklines.lines[0].Filename)()
        }
 
        mklines.Check()
 
-       exp := textproc.NewExpecter(mklines.lines)
+       exp := NewExpecter(mklines.lines)
 
        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).")
                }
        }
@@ -34,7 +32,7 @@
        }
 
        pkgbaseLine, pkgbase := exp.CurrentLine(), ""
-       var abiLine, apiLine line.Line
+       var abiLine, apiLine Line
        var abi, api *DependencyPattern
 
        // First paragraph: Introduction of the package identifier
diff -r 193acb3a283b -r bc6496ed5f0c pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Mon Jan 01 17:43:20 2018 +0000
+++ b/pkgtools/pkglint/files/category.go        Mon Jan 01 18:04:15 2018 +0000
@@ -1,8 +1,6 @@
 package main
 
 import (
-       "netbsd.org/pkglint/line"
-       "netbsd.org/pkglint/textproc"
        "netbsd.org/pkglint/trace"
        "sort"
 )
@@ -20,7 +18,7 @@
        mklines := NewMkLines(lines)
        mklines.Check()
 
-       exp := textproc.NewExpecter(lines)
+       exp := NewExpecter(lines)
        for exp.AdvanceIfPrefix("#") {
        }
        exp.ExpectEmptyLine(G.opts.WarnSpace)
@@ -34,7 +32,7 @@
 
        type subdir struct {
                name   string
-               line   line.Line
+               line   Line
                active bool
        }
 
@@ -49,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 == "#"
@@ -74,7 +72,7 @@
                        exp.Advance()
 
                } else {
-                       if line.Text() != "" {
+                       if line.Text != "" {
                                line.Errorf("SUBDIR+= line or empty line expected.")
                        }
                        break
@@ -98,7 +96,7 @@
 
        var subdirs []string
 
-       var line line.Line
+       var line Line
        mActive := false
 
        for !(mAtend && fAtend) {
diff -r 193acb3a283b -r bc6496ed5f0c pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Mon Jan 01 17:43:20 2018 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Mon Jan 01 18:04:15 2018 +0000
@@ -11,7 +11,6 @@
        "testing"
 
        check "gopkg.in/check.v1"
-       "netbsd.org/pkglint/line"
        "netbsd.org/pkglint/textproc"
        "netbsd.org/pkglint/trace"
 )
@@ -37,7 +36,7 @@
 
 func (s *Suite) c() *check.C {
        if s.checkC == nil {
-               panic("Must call Suite.Init before accessing check.C.")
+               panic("Suite.Init must be called before accessing check.C.")
        }
        return s.checkC
 }
@@ -94,8 +93,8 @@
        return rawlines[:j]
 }
 
-func (s *Suite) NewLines(fname string, texts ...string) []line.Line {
-       result := make([]line.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))
diff -r 193acb3a283b -r bc6496ed5f0c pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Mon Jan 01 17:43:20 2018 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Mon Jan 01 18:04:15 2018 +0000
@@ -5,18 +5,16 @@
        "crypto/sha1"
        "fmt"
        "io/ioutil"
-       "netbsd.org/pkglint/line"
-       "netbsd.org/pkglint/linechecks"
        "netbsd.org/pkglint/trace"
        "strings"
 )
 
-func ChecklinesDistinfo(lines []line.Line) {
+func ChecklinesDistinfo(lines []Line) {
        if trace.Tracing {
-               defer trace.Call1(lines[0].Filename())()
+               defer trace.Call1(lines[0].Filename)()
        }
 
-       fname := lines[0].Filename()
+       fname := lines[0].Filename
        patchesDir := "patches"
        patchesDirSet := false
        if G.Pkg != nil && contains(fname, "lang/php") {
@@ -48,15 +46,15 @@
        distinfoIsCommitted bool
 
        patches          map[string]bool // "patch-aa" => true
-       currentFirstLine line.Line
+       currentFirstLine Line
        currentFilename  string
        isPatch          bool
        algorithms       []string
 }
 
-func (ck *distinfoLinesChecker) checkLines(lines []line.Line) {
-       linechecks.CheckRcsid(lines[0], ``, "")
-       if 1 < len(lines) && lines[1].Text() != "" {
+func (ck *distinfoLinesChecker) checkLines(lines []Line) {
+       CheckLineRcsid(lines[0], ``, "")
+       if 1 < len(lines) && lines[1].Text != "" {
                lines[1].Notef("Empty line expected.")
        }
 
@@ -64,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
@@ -81,7 +79,7 @@
        ck.onFilenameChange(NewLineEOF(ck.distinfoFilename), "")
 }
 
-func (ck *distinfoLinesChecker) onFilenameChange(line line.Line, nextFname string) {
+func (ck *distinfoLinesChecker) onFilenameChange(line Line, nextFname string) {
        currentFname := ck.currentFilename
        if currentFname != "" {
                algorithms := strings.Join(ck.algorithms, ", ")
@@ -108,7 +106,7 @@
        ck.algorithms = nil
 }
 
-func (ck *distinfoLinesChecker) checkPatchSha1(line 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)
@@ -148,7 +146,7 @@
 }
 
 // Inter-package check for differing distfile checksums.
-func (ck *distinfoLinesChecker) checkGlobalMismatch(line line.Line, fname, alg, hash string) {
+func (ck *distinfoLinesChecker) checkGlobalMismatch(line Line, fname, alg, hash string) {
        if G.Hash != nil && !hasPrefix(fname, "patch-") { // Intentionally checking the filename instead of ck.isPatch
                key := alg + ":" + fname
                otherHash := G.Hash[key]
@@ -163,7 +161,7 @@
        }
 }
 
-func (ck *distinfoLinesChecker) checkUncommittedPatch(line line.Line, patchName, sha1Hash string) {
+func (ck *distinfoLinesChecker) checkUncommittedPatch(line Line, patchName, sha1Hash string) {
        if ck.isPatch {
                patchFname := ck.patchdir + "/" + patchName
                if ck.distinfoIsCommitted && !isCommitted(G.CurrentDir+"/"+patchFname) {
diff -r 193acb3a283b -r bc6496ed5f0c pkgtools/pkglint/files/expecter.go
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkglint/files/expecter.go        Mon Jan 01 18:04:15 2018 +0000
@@ -0,0 +1,111 @@
+package main
+
+import (
+       "netbsd.org/pkglint/regex"
+       "netbsd.org/pkglint/trace"
+       "strings"
+)
+
+// Expecter records the state when checking a list of lines from top to bottom.
+type Expecter struct {
+       lines []Line
+       index int
+       m     []string
+}
+
+func NewExpecter(lines []Line) *Expecter {
+       return &Expecter{lines, 0, nil}
+}
+
+func (exp *Expecter) CurrentLine() Line {
+       if exp.index < len(exp.lines) {
+               return exp.lines[exp.index]
+       }
+
+       return NewLineEOF(exp.lines[0].Filename)
+}
+
+func (exp *Expecter) PreviousLine() Line {
+       return exp.lines[exp.index-1]
+}
+
+func (exp *Expecter) Index() int {
+       return exp.index
+}
+
+func (exp *Expecter) EOF() bool {
+       return !(exp.index < len(exp.lines))
+}
+
+func (exp *Expecter) Group(index int) string {
+       return exp.m[index]
+}
+
+func (exp *Expecter) Advance() bool {
+       exp.index++
+       exp.m = nil
+       return true
+}
+
+func (exp *Expecter) StepBack() {
+       exp.index--
+}
+
+func (exp *Expecter) AdvanceIfMatches(re regex.Pattern) bool {
+       if trace.Tracing {
+               defer trace.Call(exp.CurrentLine().Text, re)()
+       }
+
+       if !exp.EOF() {
+               if m := regex.Match(exp.lines[exp.index].Text, re); m != nil {
+                       exp.index++
+                       exp.m = m
+                       return true
+               }



Home | Main Index | Thread Index | Old Index