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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8d766bc0cda9
branches:  trunk
changeset: 435985:8d766bc0cda9
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Jul 22 19:26:29 2020 +0000

description:
pkgtools/pkglint: update to 20.2.2

Changes since 20.2.1:

Emit notes about redundant != assignments, as well as those that
overwrite each other.

For packages that set DISTINFO_FILE to their own distinfo file, don't
check that file twice.

diffstat:

 pkgtools/pkglint/Makefile                     |   5 +-
 pkgtools/pkglint/files/distinfo_test.go       |  25 +++++++++++++++
 pkgtools/pkglint/files/package.go             |   8 +++-
 pkgtools/pkglint/files/redundantscope.go      |  17 ++++++++++
 pkgtools/pkglint/files/redundantscope_test.go |  43 +++++++++++---------------
 5 files changed, 69 insertions(+), 29 deletions(-)

diffs (195 lines):

diff -r a6984d225373 -r 8d766bc0cda9 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Wed Jul 22 15:36:55 2020 +0000
+++ b/pkgtools/pkglint/Makefile Wed Jul 22 19:26:29 2020 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.662 2020/07/17 18:04:27 bsiegert Exp $
+# $NetBSD: Makefile,v 1.663 2020/07/22 19:26:29 rillig Exp $
 
-PKGNAME=       pkglint-20.2.1
-PKGREVISION=   1
+PKGNAME=       pkglint-20.2.2
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r a6984d225373 -r 8d766bc0cda9 pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go   Wed Jul 22 15:36:55 2020 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go   Wed Jul 22 19:26:29 2020 +0000
@@ -36,6 +36,31 @@
                "WARN: distinfo:9: Patch file \"patch-nonexistent\" does not exist in directory \"patches\".")
 }
 
+func (s *Suite) Test_CheckLinesDistinfo__DISTINFO_FILE(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpPackage("category/package",
+               "DISTINFO_FILE=\t${.CURDIR}/../../category/package/distinfo",
+               "PATCHDIR=\t${.CURDIR}/../../category/package/patches")
+       t.Chdir("category/package")
+       t.CreateFileDummyPatch("patches/patch-dummy_txt")
+       t.CreateFileLines("patches/CVS/Entries",
+               "/other/1.1/modified//")
+       t.CreateFileLines("distinfo",
+               CvsID,
+               "",
+               "SHA1 (patch-dummy_txt) = 2388e84518db54eaa827c68f191d9a87e90f7f00")
+       t.CreateFileLines("CVS/Entries",
+               "/distinfo/1.1/modified//")
+       t.FinishSetUp()
+
+       G.Check(".")
+
+       t.CheckOutputLines(
+               "WARN: distinfo:3: ../../category/package/patches/patch-dummy_txt " +
+                       "is registered in distinfo but not added to CVS.")
+}
+
 func (s *Suite) Test_distinfoLinesChecker_parse__trailing_empty_line(c *check.C) {
        t := s.Init(c)
 
diff -r a6984d225373 -r 8d766bc0cda9 pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Wed Jul 22 15:36:55 2020 +0000
+++ b/pkgtools/pkglint/files/package.go Wed Jul 22 19:26:29 2020 +0000
@@ -155,8 +155,12 @@
                files = append(files, pkg.File(pkg.Pkgdir).ReadPaths()...)
        }
        files = append(files, pkg.File(pkg.Patchdir).ReadPaths()...)
-       if pkg.DistinfoFile != NewPackagePathString(pkg.vars.create("DISTINFO_FILE").fallback) {
-               files = append(files, pkg.File(pkg.DistinfoFile))
+       defaultDistinfoFile := NewPackagePathString(pkg.vars.create("DISTINFO_FILE").fallback)
+       if pkg.DistinfoFile != defaultDistinfoFile {
+               resolved := func(p PackagePath) PkgsrcPath { return G.Pkgsrc.Rel(pkg.File(p)) }
+               if resolved(pkg.DistinfoFile) != resolved(defaultDistinfoFile) {
+                       files = append(files, pkg.File(pkg.DistinfoFile))
+               }
        }
 
        isRelevantMk := func(filename CurrPath, basename RelPath) bool {
diff -r a6984d225373 -r 8d766bc0cda9 pkgtools/pkglint/files/redundantscope.go
--- a/pkgtools/pkglint/files/redundantscope.go  Wed Jul 22 15:36:55 2020 +0000
+++ b/pkgtools/pkglint/files/redundantscope.go  Wed Jul 22 19:26:29 2020 +0000
@@ -155,6 +155,23 @@
 
        case opAssignAppend:
                s.checkAppendUnique(mkline, info)
+
+       case opAssignShell:
+               if s.includePath.includedByOrEqualsAll(info.includePaths) {
+
+                       // The situation is:
+                       //
+                       //   including.mk: VAR=  value
+                       //   included.mk:  VAR!= value   <-- you are here
+                       //
+                       // A variable has been defined in an including file and
+                       // has never been read.
+                       // The current line has a shell command assignment,
+                       // overwriting the previously assigned value.
+                       if info.vari.IsConstant() {
+                               s.onRedundant(prevWrites[len(prevWrites)-1], mkline)
+                       }
+               }
        }
 }
 
diff -r a6984d225373 -r 8d766bc0cda9 pkgtools/pkglint/files/redundantscope_test.go
--- a/pkgtools/pkglint/files/redundantscope_test.go     Wed Jul 22 15:36:55 2020 +0000
+++ b/pkgtools/pkglint/files/redundantscope_test.go     Wed Jul 22 19:26:29 2020 +0000
@@ -25,8 +25,8 @@
        t.CheckOutputLines(
                "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
                "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",
-               "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.")
-       // TODO: "VAR.shl: is overwritten later"
+               "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.",
+               "NOTE: file.mk:5: Default assignment of VAR.shl has no effect because of line 11.")
 }
 
 // In a single file, five variables get assigned are value and are later overridden
@@ -52,8 +52,8 @@
        t.CheckOutputLines(
                "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
                "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",
-               "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.")
-       // TODO: "VAR.shl: is overwritten later"
+               "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.",
+               "NOTE: file.mk:5: Definition of VAR.shl is redundant because of line 11.")
 }
 
 // In a single file, five variables get appended a value and are later overridden
@@ -79,8 +79,8 @@
        t.CheckOutputLines(
                "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
                "WARN: file.mk:2: Variable VAR.asg is overwritten in line 8.",
-               "WARN: file.mk:4: Variable VAR.evl is overwritten in line 10.")
-       // TODO: "VAR.shl: is overwritten later"
+               "WARN: file.mk:4: Variable VAR.evl is overwritten in line 10.",
+               "NOTE: file.mk:5: Definition of VAR.shl is redundant because of line 11.")
 }
 
 // In a single file, five variables get assigned a value using the := operator,
@@ -107,8 +107,8 @@
        t.CheckOutputLines(
                "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
                "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",
-               "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.")
-       // TODO: "VAR.shl: is overwritten later"
+               "NOTE: file.mk:10: Definition of VAR.evl is redundant because of line 4.",
+               "NOTE: file.mk:5: Definition of VAR.shl is redundant because of line 11.")
 }
 
 // In a single file, five variables get assigned a value using the != operator,
@@ -162,9 +162,9 @@
 
        t.CheckOutputLines(
                "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
-               "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.")
-       // TODO: "VAR.evl: is overwritten later",
-       // TODO: "VAR.shl: is overwritten later"
+               "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",
+               "NOTE: file.mk:5: Default assignment of VAR.shl has no effect because of line 11.")
+       // TODO: "VAR.evl: is overwritten later"
 }
 
 // In a single file, five variables get assigned are value and are later overridden
@@ -189,9 +189,9 @@
 
        t.CheckOutputLines(
                "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
-               "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.")
-       // TODO: "VAR.evl: is overwritten later",
-       // TODO: "VAR.shl: is overwritten later"
+               "NOTE: file.mk:8: Definition of VAR.asg is redundant because of line 2.",
+               "NOTE: file.mk:5: Definition of VAR.shl is redundant because of line 11.")
+       // TODO: "VAR.evl: is overwritten later"
 }
 
 // In a single file, five variables get appended a value and are later overridden
@@ -216,9 +216,9 @@
 
        t.CheckOutputLines(
                "NOTE: file.mk:7: Default assignment of VAR.def has no effect because of line 1.",
-               "WARN: file.mk:2: Variable VAR.asg is overwritten in line 8.")
-       // TODO: "VAR.evl: is overwritten later",
-       // TODO: "VAR.shl: is overwritten later"
+               "WARN: file.mk:2: Variable VAR.asg is overwritten in line 8.",
+               "NOTE: file.mk:5: Definition of VAR.shl is redundant because of line 11.")
+       // TODO: "VAR.evl: is overwritten later"
 }
 
 // In a single file, five variables get assigned a value using the := operator,
@@ -1229,13 +1229,8 @@
 
        NewRedundantScope().Check(mklines)
 
-       // Even when := is used with a literal value (which is usually
-       // only done for procedure calls), the shell evaluation can have
-       // so many different side effects that pkglint cannot reliably
-       // help in this situation.
-       //
-       // TODO: Why not? The evaluation in line 1 is trivial to analyze.
-       t.CheckOutputEmpty()
+       t.CheckOutputLines(
+               "NOTE: module.mk:1: Definition of VAR is redundant because of line 2.")
 }
 
 func (s *Suite) Test_RedundantScope__included_OPSYS_variable(c *check.C) {



Home | Main Index | Thread Index | Old Index