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.6.6
details: https://anonhg.NetBSD.org/pkgsrc/rev/6650cd989fdd
branches: trunk
changeset: 325034:6650cd989fdd
user: rillig <rillig%pkgsrc.org@localhost>
date: Wed Nov 07 20:58:22 2018 +0000
description:
pkgtools/pkglint: update to 5.6.6
Changes since 5.6.5:
- Removed plist-clash since it had crashed unconditionally whenever it
was called. This means that in the last 3 years, nobody can have
used it in the originally intended way.
- Fixed interactions between the --source, --explain, --show-autofix,
--autofix and --only options.
- Fixed "defined but not used" and "used but not defined" for variables
from the pkgsrc infrastructure.
- Lots of small fixes and improvements found by the large pkglint code
review (12% done).
diffstat:
pkgtools/pkglint/Makefile | 16 +-
pkgtools/pkglint/PLIST | 3 +-
pkgtools/pkglint/files/alternatives.go | 29 +-
pkgtools/pkglint/files/alternatives_test.go | 2 +-
pkgtools/pkglint/files/autofix.go | 463 ++++++++++------
pkgtools/pkglint/files/autofix_test.go | 579 +++++++++++++++-----
pkgtools/pkglint/files/buildlink3.go | 343 ++++++-----
pkgtools/pkglint/files/buildlink3_test.go | 256 ++++++---
pkgtools/pkglint/files/category.go | 172 +++---
pkgtools/pkglint/files/category_test.go | 129 ++++-
pkgtools/pkglint/files/check_test.go | 343 +++++++----
pkgtools/pkglint/files/distinfo.go | 177 +++--
pkgtools/pkglint/files/distinfo_test.go | 174 ++++-
pkgtools/pkglint/files/expecter.go | 78 +-
pkgtools/pkglint/files/expecter_test.go | 36 +
pkgtools/pkglint/files/files.go | 74 +-
pkgtools/pkglint/files/files_test.go | 130 ++--
pkgtools/pkglint/files/fuzzer_test.go | 28 +-
pkgtools/pkglint/files/getopt/getopt.go | 128 ++--
pkgtools/pkglint/files/getopt/getopt_test.go | 87 +-
pkgtools/pkglint/files/histogram/histogram.go | 14 +-
pkgtools/pkglint/files/histogram/histogram_test.go | 28 +
pkgtools/pkglint/files/intqa/see.go | 6 +
pkgtools/pkglint/files/intqa/testnames.go | 330 +++++++++++
pkgtools/pkglint/files/licenses.go | 30 +-
pkgtools/pkglint/files/licenses/licenses.go | 80 +-
pkgtools/pkglint/files/licenses/licenses_test.go | 40 +-
pkgtools/pkglint/files/licenses_test.go | 2 +-
pkgtools/pkglint/files/line.go | 77 +-
pkgtools/pkglint/files/line_test.go | 52 +-
pkgtools/pkglint/files/linechecker.go | 3 +-
pkgtools/pkglint/files/linechecker_test.go | 10 +-
pkgtools/pkglint/files/lines.go | 33 +
pkgtools/pkglint/files/logging.go | 64 +-
pkgtools/pkglint/files/logging_test.go | 129 +--
pkgtools/pkglint/files/mkline.go | 91 ++-
pkgtools/pkglint/files/mkline_test.go | 335 +----------
pkgtools/pkglint/files/mklinechecker.go | 134 ++--
pkgtools/pkglint/files/mklinechecker_test.go | 158 +++-
pkgtools/pkglint/files/mklines.go | 143 +++-
pkgtools/pkglint/files/mklines_test.go | 311 +++++++++--
pkgtools/pkglint/files/mklines_varalign_test.go | 24 +-
pkgtools/pkglint/files/mkparser.go | 44 +-
pkgtools/pkglint/files/mkparser_test.go | 19 +-
pkgtools/pkglint/files/mkshparser.go | 1 -
pkgtools/pkglint/files/mkshtypes.go | 2 +-
pkgtools/pkglint/files/mktypes.go | 104 +++-
pkgtools/pkglint/files/mktypes_test.go | 32 +-
pkgtools/pkglint/files/options.go | 18 +-
pkgtools/pkglint/files/package.go | 288 +++-------
pkgtools/pkglint/files/package_test.go | 122 +----
pkgtools/pkglint/files/parser.go | 10 +-
pkgtools/pkglint/files/patches.go | 47 +-
pkgtools/pkglint/files/patches_test.go | 33 +-
pkgtools/pkglint/files/pkglint.go | 361 ++++++++-----
pkgtools/pkglint/files/pkglint_test.go | 185 +++++-
pkgtools/pkglint/files/pkgsrc.go | 197 ++++--
pkgtools/pkglint/files/pkgsrc_test.go | 218 ++++++-
pkgtools/pkglint/files/plist.go | 45 +-
pkgtools/pkglint/files/plist_test.go | 55 +-
pkgtools/pkglint/files/regex/regex.go | 10 +-
pkgtools/pkglint/files/shell.go | 53 +-
pkgtools/pkglint/files/shell_test.go | 212 ++++---
pkgtools/pkglint/files/shtokenizer.go | 28 +-
pkgtools/pkglint/files/shtokenizer_test.go | 6 +-
pkgtools/pkglint/files/substcontext.go | 41 +-
pkgtools/pkglint/files/substcontext_test.go | 52 +-
pkgtools/pkglint/files/testnames_test.go | 134 +----
pkgtools/pkglint/files/textproc/lexer.go | 205 +++++++
pkgtools/pkglint/files/textproc/lexer_test.go | 295 ++++++++++
pkgtools/pkglint/files/textproc/prefixreplacer.go | 47 +-
pkgtools/pkglint/files/tools.go | 13 +-
pkgtools/pkglint/files/tools_test.go | 95 +-
pkgtools/pkglint/files/toplevel.go | 12 +-
pkgtools/pkglint/files/toplevel_test.go | 6 +-
pkgtools/pkglint/files/trace/tracing.go | 57 +-
pkgtools/pkglint/files/trace/tracing_test.go | 93 ++-
pkgtools/pkglint/files/util.go | 103 ++-
pkgtools/pkglint/files/util_test.go | 50 +-
pkgtools/pkglint/files/vardefs.go | 81 +-
pkgtools/pkglint/files/vardefs_test.go | 49 +-
pkgtools/pkglint/files/vartype.go | 10 +-
pkgtools/pkglint/files/vartype_test.go | 2 +-
pkgtools/pkglint/files/vartypecheck.go | 489 +++++++++--------
pkgtools/pkglint/files/vartypecheck_test.go | 387 +++++++------
85 files changed, 5929 insertions(+), 3723 deletions(-)
diffs (truncated from 18005 to 300 lines):
diff -r 5c88a9d60c1e -r 6650cd989fdd pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Wed Nov 07 16:50:27 2018 +0000
+++ b/pkgtools/pkglint/Makefile Wed Nov 07 20:58:22 2018 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.553 2018/11/04 18:38:05 bsiegert Exp $
+# $NetBSD: Makefile,v 1.554 2018/11/07 20:58:22 rillig Exp $
-PKGNAME= pkglint-5.6.5
-PKGREVISION= 1
+PKGNAME= pkglint-5.6.6
DISTFILES= # none
CATEGORIES= pkgtools
@@ -17,7 +16,6 @@
GO_SRCPATH= netbsd.org/pkglint
CHECK_RELRO_SKIP+= bin/pkglint
-CHECK_RELRO_SKIP+= bin/plist-clash
SUBST_CLASSES+= pkglint
SUBST_STAGE.pkglint= post-configure
@@ -25,11 +23,21 @@
SUBST_SED.pkglint+= -e s\|@VERSION@\|${PKGNAME:S/pkglint-//}\|g
SUBST_SED.pkglint+= -e s\|@BMAKE@\|${MAKE:T:Q}\|g
+TOOLS_CREATE+= goyacc
+TOOLS_PATH.goyacc= ${WRKDIR}/bin/goyacc
+USE_TOOLS+= goyacc
+
do-extract:
${RUN} ${MKDIR} ${WRKDIR}/pkglint
${RUN} cd ${FILESDIR} && ${PAX} -rw . ${WRKDIR}/pkglint
+ ${RUN} ${PKGSRC_SETENV} ${MAKE_ENV} ${GO} get golang.org/x/tools/cmd/goyacc
+ ${RUN} ${PKGSRC_SETENV} ${MAKE_ENV} ${GO} install golang.org/x/tools/cmd/goyacc
+
+pre-build:
+ ${RUN} ${PKGSRC_SETENV} ${MAKE_ENV} ${GO} generate ${GO_BUILD_PATTERN}
pre-install:
+ ${RUN} rm -f ${WRKDIR}/bin/goyacc
${RUN} rm -rf ${WRKDIR}/pkg
post-install: do-install-man
diff -r 5c88a9d60c1e -r 6650cd989fdd pkgtools/pkglint/PLIST
--- a/pkgtools/pkglint/PLIST Wed Nov 07 16:50:27 2018 +0000
+++ b/pkgtools/pkglint/PLIST Wed Nov 07 20:58:22 2018 +0000
@@ -1,5 +1,4 @@
-@comment $NetBSD: PLIST,v 1.6 2015/11/25 13:29:07 rillig Exp $
+@comment $NetBSD: PLIST,v 1.7 2018/11/07 20:58:22 rillig Exp $
bin/pkglint
-bin/plist-clash
man/cat1/pkglint.0
man/man1/pkglint.1
diff -r 5c88a9d60c1e -r 6650cd989fdd pkgtools/pkglint/files/alternatives.go
--- a/pkgtools/pkglint/files/alternatives.go Wed Nov 07 16:50:27 2018 +0000
+++ b/pkgtools/pkglint/files/alternatives.go Wed Nov 07 20:58:22 2018 +0000
@@ -2,26 +2,31 @@
import "strings"
-func CheckfileAlternatives(filename string, plistFiles map[string]bool) {
- lines := Load(filename, NotEmpty|LogErrors)
+func CheckfileAlternatives(fileName string) {
+ lines := Load(fileName, NotEmpty|LogErrors)
if lines == nil {
return
}
- for _, line := range lines {
- if m, wrapper, space, implementation := match3(line.Text, `^(\S+)([ \t]+)(\S+)`); m {
- if plistFiles != nil {
- if plistFiles[wrapper] {
+ var plist PlistContent
+ if G.Pkg != nil {
+ plist = G.Pkg.Plist
+ }
+
+ for _, line := range lines.Lines {
+ if m, wrapper, space, alternative := match3(line.Text, `^([^\t ]+)([ \t]+)([^\t ]+)`); m {
+ if plist.Files != nil {
+ if plist.Files[wrapper] {
line.Errorf("Alternative wrapper %q must not appear in the PLIST.", wrapper)
}
- relImplementation := strings.Replace(implementation, "@PREFIX@/", "", 1)
+ relImplementation := strings.Replace(alternative, "@PREFIX@/", "", 1)
plistName := replaceAll(relImplementation, `@(\w+)@`, "${$1}")
- if !plistFiles[plistName] && !G.Pkg.vars.Defined("ALTERNATIVES_SRC") {
- if plistName != implementation {
- line.Errorf("Alternative implementation %q must appear in the PLIST as %q.", implementation, plistName)
+ if !plist.Files[plistName] && !G.Pkg.vars.Defined("ALTERNATIVES_SRC") {
+ if plistName != alternative {
+ line.Errorf("Alternative implementation %q must appear in the PLIST as %q.", alternative, plistName)
} else {
- line.Errorf("Alternative implementation %q must appear in the PLIST.", implementation)
+ line.Errorf("Alternative implementation %q must appear in the PLIST.", alternative)
}
}
}
@@ -36,7 +41,7 @@
} else {
line.Errorf("Invalid ALTERNATIVES line %q.", line.Text)
Explain(
- "Run \"" + confMake + " help topic=alternatives\" for more information.")
+ sprintf("Run %q for more information.", makeHelp("alternatives")))
}
}
}
diff -r 5c88a9d60c1e -r 6650cd989fdd pkgtools/pkglint/files/alternatives_test.go
--- a/pkgtools/pkglint/files/alternatives_test.go Wed Nov 07 16:50:27 2018 +0000
+++ b/pkgtools/pkglint/files/alternatives_test.go Wed Nov 07 20:58:22 2018 +0000
@@ -38,7 +38,7 @@
G.Pkg = NewPackage(".")
- CheckfileAlternatives("ALTERNATIVES", G.Pkg.PlistFiles)
+ CheckfileAlternatives("ALTERNATIVES")
t.CheckOutputLines(
"ERROR: ALTERNATIVES: Must not be empty.")
diff -r 5c88a9d60c1e -r 6650cd989fdd pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Wed Nov 07 16:50:27 2018 +0000
+++ b/pkgtools/pkglint/files/autofix.go Wed Nov 07 20:58:22 2018 +0000
@@ -4,7 +4,6 @@
"fmt"
"io/ioutil"
"netbsd.org/pkglint/regex"
- "netbsd.org/pkglint/trace"
"os"
"strconv"
"strings"
@@ -16,13 +15,20 @@
// until they are written to disk by SaveAutofixChanges.
type Autofix struct {
line Line
- linesBefore []string // Newly inserted lines, including \n
- lines []*RawLine // Original lines, available for diff
- linesAfter []string // Newly inserted lines, including \n
- modified bool // Modified in memory, but not necessarily written back to disk
+ 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,
+ // whether a fix is applicable)
+ modified bool
+
+ autofixShortTerm
+}
+
+// autofixShortTerm is the part of the Autofix that is reset after each call to Apply.
+type autofixShortTerm struct {
actions []autofixAction // Human-readable description of the actual autofix actions
level *LogLevel //
- diagFormat string // Is printed only if it couldn't be fixed automatically
+ diagFormat string // Is logged only if it couldn't be fixed automatically
diagArgs []interface{} //
explanation []string // Is printed together with the diagnostic
}
@@ -32,50 +38,72 @@
lineno int
}
+// SilentAutofixFormat is used in exceptional situations when an
+// autofix action is not directly related to a diagnostic.
+//
+// To prevent confusion, the code using this magic value must ensure
+// to log a diagnostic by other means.
+const SilentAutofixFormat = "SilentAutofixFormat"
+
+// AutofixFormat is a special value that is used for logging
+// diagnostics like "Replacing \"old\" with \"new\".".
+//
+// Since these are not really diagnostics, duplicates are not suppressed.
+const AutofixFormat = "AutofixFormat"
+
func NewAutofix(line Line) *Autofix {
- return &Autofix{
- line: line,
- lines: append([]*RawLine{}, line.raw...)}
+ return &Autofix{line: line}
+}
+
+// Errorf remembers the error for logging it later when Apply is called.
+func (fix *Autofix) Errorf(format string, args ...interface{}) {
+ fix.setDiag(Error, format, args)
+}
+
+// Warnf remembers the warning for logging it later when Apply is called.
+func (fix *Autofix) Warnf(format string, args ...interface{}) {
+ fix.setDiag(Warn, format, args)
}
-// Custom runs a custom fix action, unless the fix is skipped anyway
-// because of the --only option.
-//
-// The fixer function must always call Describef.
-//
-// If printAutofix or autofix is true, the fix should be done in
-// memory as far as possible (e.g. changes to the text of the line).
-//
-// If autofix is true, the fix should be done persistently
-// (e.g. direct changes to the file system). Except if the fix only
-// affects the current line, then SaveAutofixChanges will do that.
-func (fix *Autofix) Custom(fixer func(printAutofix, autofix bool)) {
+// Notef remembers the note for logging it later when Apply is called.
+func (fix *Autofix) Notef(format string, args ...interface{}) {
+ fix.setDiag(Note, format, args)
+}
+
+// Explain remembers the explanation for logging it later when Apply is called.
+func (fix *Autofix) Explain(explanation ...string) {
+ // 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.
+ G.Assertf(
+ fix.diagFormat != SilentAutofixFormat,
+ "Autofix: Silent fixes cannot have an explanation.")
+
+ fix.explanation = explanation
+}
+
+// ReplaceAfter replaces "from" with "to", a single time.
+func (fix *Autofix) Replace(from string, to string) {
+ fix.ReplaceAfter("", from, to)
+}
+
+// ReplaceAfter replaces the text "prefix+from" with "prefix+to", a single time.
+// In the diagnostic, only the replacement of "from" with "to" is mentioned.
+func (fix *Autofix) ReplaceAfter(prefix, from string, to string) {
+ fix.assertRealLine()
if fix.skip() {
return
}
- fixer(G.opts.PrintAutofix, G.opts.Autofix)
-}
-
-func (fix *Autofix) Replace(from string, to string) {
- fix.ReplaceAfter("", from, to)
-}
-
-// ReplaceAfter replaces the text "prefix+from" with "prefix+to",
-// but in the diagnostic, only the replacement of "from" with "to"
-// is mentioned.
-func (fix *Autofix) ReplaceAfter(prefix, from string, to string) {
- if fix.skip() {
- return
- }
-
- for _, rawLine := range fix.lines {
+ for _, rawLine := range fix.line.raw {
if rawLine.Lineno != 0 {
- if replaced := strings.Replace(rawLine.textnl, prefix+from, prefix+to, 1); replaced != rawLine.textnl {
- if G.opts.PrintAutofix || G.opts.Autofix {
+ replaced := strings.Replace(rawLine.textnl, prefix+from, prefix+to, 1)
+ if replaced != rawLine.textnl {
+ if G.Opts.ShowAutofix || G.Opts.Autofix {
rawLine.textnl = replaced
}
fix.Describef(rawLine.Lineno, "Replacing %q with %q.", from, to)
+ return
}
}
}
@@ -87,12 +115,13 @@
// Placeholders like `$1` are _not_ expanded in the `toText`.
// (If you know how to do the expansion correctly, feel free to implement it.)
func (fix *Autofix) ReplaceRegex(from regex.Pattern, toText string, howOften int) {
+ fix.assertRealLine()
if fix.skip() {
return
}
done := 0
- for _, rawLine := range fix.lines {
+ for _, rawLine := range fix.line.raw {
if rawLine.Lineno != 0 {
var froms []string // The strings that have actually changed
@@ -105,8 +134,9 @@
return toText
}
- if replaced := replaceAllFunc(rawLine.textnl, from, replace); replaced != rawLine.textnl {
- if G.opts.PrintAutofix || G.opts.Autofix {
+ replaced := replaceAllFunc(rawLine.textnl, from, replace)
+ if replaced != rawLine.textnl {
+ if G.Opts.ShowAutofix || G.Opts.Autofix {
rawLine.textnl = replaced
}
for _, fromText := range froms {
@@ -117,8 +147,166 @@
}
}
+// Custom runs a custom fix action, unless the fix is skipped anyway
+// because of the --only option.
+//
+// The fixer function must check whether it can actually fix something,
+// and if so, call Describef to describe the actual fix.
+//
Home |
Main Index |
Thread Index |
Old Index