pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/pkgtools/pkglint
Module Name: pkgsrc
Committed By: rillig
Date: Tue Oct 9 23:17:17 UTC 2018
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: mklinechecker.go mklinechecker_test.go
util_test.go vardefs.go vartype.go vartypecheck.go
vartypecheck_test.go
Log Message:
pkgtools/pkglint: update to 5.6.5
Changes since 5.6.4:
* GCC_REQD should only contain the major version. For GCC versions up to
4.x, this consists of the first two numbers, such as 4.8, while starting
with the 5.x series, the major version is only the first number, such as
7.
To generate a diff of this commit:
cvs rdiff -u -r1.550 -r1.551 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.20 -r1.21 pkgsrc/pkgtools/pkglint/files/mklinechecker.go
cvs rdiff -u -r1.16 -r1.17 \
pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go
cvs rdiff -u -r1.15 -r1.16 pkgsrc/pkgtools/pkglint/files/util_test.go
cvs rdiff -u -r1.47 -r1.48 pkgsrc/pkgtools/pkglint/files/vardefs.go
cvs rdiff -u -r1.18 -r1.19 pkgsrc/pkgtools/pkglint/files/vartype.go
cvs rdiff -u -r1.41 -r1.42 pkgsrc/pkgtools/pkglint/files/vartypecheck.go
cvs rdiff -u -r1.33 -r1.34 pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.550 pkgsrc/pkgtools/pkglint/Makefile:1.551
--- pkgsrc/pkgtools/pkglint/Makefile:1.550 Tue Oct 9 19:12:13 2018
+++ pkgsrc/pkgtools/pkglint/Makefile Tue Oct 9 23:17:17 2018
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.550 2018/10/09 19:12:13 rillig Exp $
+# $NetBSD: Makefile,v 1.551 2018/10/09 23:17:17 rillig Exp $
-PKGNAME= pkglint-5.6.4
+PKGNAME= pkglint-5.6.5
DISTFILES= # none
CATEGORIES= pkgtools
Index: pkgsrc/pkgtools/pkglint/files/mklinechecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.20 pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.21
--- pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.20 Tue Oct 9 19:12:13 2018
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker.go Tue Oct 9 23:17:17 2018
@@ -362,17 +362,7 @@ func (ck MkLineChecker) CheckVaruse(varu
mkline.Warnf("%s is used but not defined.", varname)
}
- if hasPrefix(varuse.Mod(), ":=") && vartype != nil && !vartype.IsConsideredList() {
- mkline.Warnf("The :from=to modifier should only be used with lists, not with %s.", varuse.varname)
- Explain(
- "Instead of:",
- "\tMASTER_SITES=\t${HOMEPAGE:=repository/}",
- "",
- "Write:",
- "\tMASTER_SITES=\t${HOMEPAGE}repository/",
- "",
- "This is a much clearer expression of the same thought.")
- }
+ ck.checkVaruseMod(varuse, vartype)
if varuse.varname == "@" {
ck.MkLine.Warnf("Please use %q instead of %q.", "${.TARGET}", "$@")
@@ -404,6 +394,42 @@ func (ck MkLineChecker) CheckVaruse(varu
}
}
+func (ck MkLineChecker) checkVaruseMod(varuse *MkVarUse, vartype *Vartype) {
+ mods := varuse.modifiers
+ if len(mods) == 0 {
+ return
+ }
+
+ if hasPrefix(mods[0], "=") && vartype != nil && !vartype.IsConsideredList() {
+ ck.MkLine.Warnf("The :from=to modifier should only be used with lists, not with %s.", varuse.varname)
+ Explain(
+ "Instead of:",
+ "\tMASTER_SITES=\t${HOMEPAGE:=repository/}",
+ "",
+ "Write:",
+ "\tMASTER_SITES=\t${HOMEPAGE}repository/",
+ "",
+ "This is a much clearer expression of the same thought.")
+ }
+
+ if len(mods) == 3 {
+ if m, magic := match1(mods[0], `^[CS]/\^/(\w+)/1$`); m {
+ if mods[1] == "M"+magic+"*" {
+ if matches(mods[2], regex.Pattern(`^[CS]/\^`+magic+`//$`)) {
+ fix := ck.MkLine.Autofix()
+ fix.Notef("The modifier %q can be written as %q.", varuse.Mod(), ":[1]")
+ fix.Explain(
+ "The range modifier is much easier to understand than the",
+ "complicated regular expressions, which were needed before",
+ "the year 2006.")
+ fix.Replace(varuse.Mod(), ":[1]")
+ fix.Apply()
+ }
+ }
+ }
+ }
+}
+
// checkVarusePermissions checks the permissions for the right-hand side
// of a variable assignment line.
//
Index: pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.16 pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.17
--- pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.16 Tue Oct 9 19:12:13 2018
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go Tue Oct 9 23:17:17 2018
@@ -689,6 +689,24 @@ func (s *Suite) Test_MkLineChecker_Check
"WARN: ~/options.mk:2: The user-defined variable VARBASE is used but not added to BUILD_DEFS.")
}
+func (s *Suite) Test_MkLineChecker_CheckVaruse__complicated_range(c *check.C) {
+ t := s.Init(c)
+
+ t.SetupCommandLine("--show-autofix", "--source")
+ t.SetupVartypes()
+ mkline := t.NewMkLine("mk/compiler/gcc.mk", 150,
+ "CC:=\t${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}")
+
+ MkLineChecker{mkline}.Check()
+
+ // FIXME: The check is called two times, even though it only produces a single NOTE.
+ t.CheckOutputLines(
+ "NOTE: mk/compiler/gcc.mk:150: The modifier \":C/^/_asdf_/1:M_asdf_*:S/^_asdf_//\" can be written as \":[1]\".",
+ "AUTOFIX: mk/compiler/gcc.mk:150: Replacing \":C/^/_asdf_/1:M_asdf_*:S/^_asdf_//\" with \":[1]\".",
+ "-\tCC:=\t${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}",
+ "+\tCC:=\t${CC:[1]}")
+}
+
func (s *Suite) Test_MkLineChecker_checkVarassignSpecific(c *check.C) {
t := s.Init(c)
Index: pkgsrc/pkgtools/pkglint/files/util_test.go
diff -u pkgsrc/pkgtools/pkglint/files/util_test.go:1.15 pkgsrc/pkgtools/pkglint/files/util_test.go:1.16
--- pkgsrc/pkgtools/pkglint/files/util_test.go:1.15 Tue Oct 9 19:12:13 2018
+++ pkgsrc/pkgtools/pkglint/files/util_test.go Tue Oct 9 23:17:17 2018
@@ -84,7 +84,7 @@ func (s *Suite) Test_cleanpath(c *check.
c.Check(cleanpath("dir/"), equals, "dir")
}
-func (s *Suite) Test_relpath(c *check.C) {
+func (s *Suite) Test_relpath__failure(c *check.C) {
t := s.Init(c)
if runtime.GOOS == "windows" {
Index: pkgsrc/pkgtools/pkglint/files/vardefs.go
diff -u pkgsrc/pkgtools/pkglint/files/vardefs.go:1.47 pkgsrc/pkgtools/pkglint/files/vardefs.go:1.48
--- pkgsrc/pkgtools/pkglint/files/vardefs.go:1.47 Tue Oct 9 19:12:13 2018
+++ pkgsrc/pkgtools/pkglint/files/vardefs.go Tue Oct 9 23:17:17 2018
@@ -719,7 +719,7 @@ func (src *Pkgsrc) InitVartypes() {
sys("GAMEDIR_PERMS", lkShell, BtPerms)
sys("GAMEMODE", lkNone, BtFileMode)
sys("GAMES_USER", lkNone, BtUserGroupName)
- pkglist("GCC_REQD", lkShell, BtVersion)
+ pkglist("GCC_REQD", lkShell, BtGccReqd)
pkglist("GENERATE_PLIST", lkNone, BtShellCommands)
pkg("GITHUB_PROJECT", lkNone, BtIdentifier)
pkg("GITHUB_TAG", lkNone, BtIdentifier)
Index: pkgsrc/pkgtools/pkglint/files/vartype.go
diff -u pkgsrc/pkgtools/pkglint/files/vartype.go:1.18 pkgsrc/pkgtools/pkglint/files/vartype.go:1.19
--- pkgsrc/pkgtools/pkglint/files/vartype.go:1.18 Tue Oct 9 19:12:13 2018
+++ pkgsrc/pkgtools/pkglint/files/vartype.go Tue Oct 9 23:17:17 2018
@@ -216,6 +216,7 @@ var (
BtFilename = &BasicType{"Filename", (*VartypeCheck).Filename}
BtFilemask = &BasicType{"Filemask", (*VartypeCheck).Filemask}
BtFileMode = &BasicType{"FileMode", (*VartypeCheck).FileMode}
+ BtGccReqd = &BasicType{"GccReqd", (*VartypeCheck).GccReqd}
BtHomepage = &BasicType{"Homepage", (*VartypeCheck).Homepage}
BtIdentifier = &BasicType{"Identifier", (*VartypeCheck).Identifier}
BtInteger = &BasicType{"Integer", (*VartypeCheck).Integer}
Index: pkgsrc/pkgtools/pkglint/files/vartypecheck.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.41 pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.42
--- pkgsrc/pkgtools/pkglint/files/vartypecheck.go:1.41 Tue Oct 9 19:12:13 2018
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck.go Tue Oct 9 23:17:17 2018
@@ -456,6 +456,24 @@ func (cv *VartypeCheck) FileMode() {
}
}
+func (cv *VartypeCheck) GccReqd() {
+ cv.Version()
+
+ if m, major := match1(cv.Value, `^([5-9])\.\d+$`); m {
+ fix := cv.Line.Autofix()
+
+ fix.Warnf("GCC version numbers should only contain the major version (%s).", major)
+ fix.Explain(
+ "For GCC up to 4.x, the major version consists of the first and",
+ "second number, such as 4.8.",
+ "",
+ "Starting with GCC >= 5, the major version is only the first number",
+ "such as 5 or 7.")
+ fix.Replace(cv.Value, major)
+ fix.Apply()
+ }
+}
+
func (cv *VartypeCheck) Homepage() {
MkLineChecker{cv.MkLine}.CheckVartypePrimitive(cv.Varname, BtURL, cv.Op, cv.Value, cv.MkComment, cv.Guessed)
Index: pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.33 pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.34
--- pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.33 Tue Oct 9 19:12:13 2018
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go Tue Oct 9 23:17:17 2018
@@ -413,6 +413,24 @@ func (s *Suite) Test_VartypeCheck_FileMo
"WARN: fname:11: Invalid file mode \"u+rwx\".")
}
+func (s *Suite) Test_VartypeCheck_GccReqd(c *check.C) {
+ vt := NewVartypeCheckTester(s.Init(c), (*VartypeCheck).GccReqd)
+
+ vt.Varname("GCC_REQD")
+ vt.Op(opAssignAppend)
+ vt.Values(
+ "2.95",
+ "3.1.5",
+ "4.7",
+ "4.8",
+ "5.1",
+ "6",
+ "7.3")
+ vt.Output(
+ "WARN: fname:5: GCC version numbers should only contain the major version (5).",
+ "WARN: fname:7: GCC version numbers should only contain the major version (7).")
+}
+
func (s *Suite) Test_VartypeCheck_Homepage(c *check.C) {
t := s.Init(c)
vt := NewVartypeCheckTester(t, (*VartypeCheck).Homepage)
Home |
Main Index |
Thread Index |
Old Index