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:           Wed Jul 22 19:26:30 UTC 2020

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: distinfo_test.go package.go
            redundantscope.go redundantscope_test.go

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.662 -r1.663 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.42 -r1.43 pkgsrc/pkgtools/pkglint/files/distinfo_test.go
cvs rdiff -u -r1.95 -r1.96 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.13 -r1.14 pkgsrc/pkgtools/pkglint/files/redundantscope.go
cvs rdiff -u -r1.17 -r1.18 \
    pkgsrc/pkgtools/pkglint/files/redundantscope_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.662 pkgsrc/pkgtools/pkglint/Makefile:1.663
--- pkgsrc/pkgtools/pkglint/Makefile:1.662      Fri Jul 17 18:04:27 2020
+++ pkgsrc/pkgtools/pkglint/Makefile    Wed Jul 22 19:26:29 2020
@@ -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/}

Index: pkgsrc/pkgtools/pkglint/files/distinfo_test.go
diff -u pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.42 pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.43
--- pkgsrc/pkgtools/pkglint/files/distinfo_test.go:1.42 Sat Jun  6 20:42:56 2020
+++ pkgsrc/pkgtools/pkglint/files/distinfo_test.go      Wed Jul 22 19:26:29 2020
@@ -36,6 +36,31 @@ func (s *Suite) Test_CheckLinesDistinfo_
                "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)
 

Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.95 pkgsrc/pkgtools/pkglint/files/package.go:1.96
--- pkgsrc/pkgtools/pkglint/files/package.go:1.95       Wed Jul  1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/package.go    Wed Jul 22 19:26:30 2020
@@ -155,8 +155,12 @@ func (pkg *Package) load() ([]CurrPath, 
                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 {

Index: pkgsrc/pkgtools/pkglint/files/redundantscope.go
diff -u pkgsrc/pkgtools/pkglint/files/redundantscope.go:1.13 pkgsrc/pkgtools/pkglint/files/redundantscope.go:1.14
--- pkgsrc/pkgtools/pkglint/files/redundantscope.go:1.13        Mon Apr 13 19:46:44 2020
+++ pkgsrc/pkgtools/pkglint/files/redundantscope.go     Wed Jul 22 19:26:30 2020
@@ -155,6 +155,23 @@ func (s *RedundantScope) handleVarassign
 
        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)
+                       }
+               }
        }
 }
 

Index: pkgsrc/pkgtools/pkglint/files/redundantscope_test.go
diff -u pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.17 pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.18
--- pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.17   Fri Jun 12 19:14:45 2020
+++ pkgsrc/pkgtools/pkglint/files/redundantscope_test.go        Wed Jul 22 19:26:30 2020
@@ -25,8 +25,8 @@ func (s *Suite) Test_RedundantScope__sin
        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 @@ func (s *Suite) Test_RedundantScope__sin
        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 @@ func (s *Suite) Test_RedundantScope__sin
        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 @@ func (s *Suite) Test_RedundantScope__sin
        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 @@ func (s *Suite) Test_RedundantScope__sin
 
        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 @@ func (s *Suite) Test_RedundantScope__sin
 
        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 @@ func (s *Suite) Test_RedundantScope__sin
 
        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 @@ func (s *Suite) Test_RedundantScope__she
 
        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