Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ineffassign for openSUSE:Factory checked in at 2026-05-05 15:15:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ineffassign (Old) and /work/SRC/openSUSE:Factory/.ineffassign.new.30200 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ineffassign" Tue May 5 15:15:46 2026 rev:4 rq:1350854 version:0.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ineffassign/ineffassign.changes 2023-08-13 19:18:16.500228414 +0200 +++ /work/SRC/openSUSE:Factory/.ineffassign.new.30200/ineffassign.changes 2026-05-05 15:17:00.031197087 +0200 @@ -1,0 +2,27 @@ +Mon May 4 19:06:42 UTC 2026 - Jeff Kowalczyk <[email protected]> + +- Packaging improvements: + * Re-enable binary stripping and debuginfo boo#1210938 + * Use BuildRequires: golang(API) >= 1.23 matching go.mod + * Use autosetup -a 1 to unpack source and vendored dependencies + * Build PIE with pattern that may become recommended procedure: + %%ifnarch ppc64 GOFLAGS="-buildmode=pie" %%endif go build + A go toolchain buildmode default config would be preferable + but none exist at this time. + * Add basic %check to execute binary --help + +------------------------------------------------------------------- +Mon May 04 16:42:44 UTC 2026 - Dirk Müller <[email protected]> + +- Update to version 0.2.0: + * add flag to optionally check for escaping errors (#100) + * Remove unused import + * Use the IsGenerated function from the go/ast package (#98) + * Update ineffassign.go + * Process method receiver in function declaration + * Upgrade golang.org/x/tools and Go versions + * docs: update install instructions + * Update analyzer doc to match with golangci-lint + * add flag for printing the version + +------------------------------------------------------------------- Old: ---- ineffassign-0.0.0+git20230610.0e73809.tar.gz New: ---- ineffassign-0.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ineffassign.spec ++++++ --- /var/tmp/diff_new_pack.Xsy4ki/_old 2026-05-05 15:17:00.619221484 +0200 +++ /var/tmp/diff_new_pack.Xsy4ki/_new 2026-05-05 15:17:00.623221650 +0200 @@ -1,7 +1,7 @@ # # spec file for package ineffassign # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,10 +16,8 @@ # -%define __arch_install_post export NO_BRP_STRIP_DEBUG=true - Name: ineffassign -Version: 0.0.0+git20230610.0e73809 +Version: 0.2.0 Release: 0 Summary: Tool to detect ineffectual assignments in Go code License: MIT @@ -27,7 +25,7 @@ Source: %{name}-%{version}.tar.gz Source1: vendor.tar.gz Source99: %{name}-rpmlintrc -BuildRequires: golang(API) >= 1.14 +BuildRequires: golang(API) >= 1.23 %description This tool misses some cases because does not consider any type information in @@ -35,24 +33,24 @@ ineffectual.) It should, however, never give any false positives. %prep -%setup -q -%setup -q -T -D -a 1 +%autosetup -a 1 %build -go build \ - -buildmode=pie ; +%ifnarch ppc64 +export GOFLAGS="-buildmode=pie" +%endif +go build %install # Install the binary. install -D -m 0755 %{name} "%{buildroot}/%{_bindir}/%{name}" +%check +# execute the binary as a basic check +./%{name} --help + %files -%defattr(-,root,root) -%doc README.md -%if 0%{?suse_version} < 1500 -%doc LICENSE -%else %license LICENSE -%endif +%doc README.md %{_bindir}/%{name} ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Xsy4ki/_old 2026-05-05 15:17:00.659223144 +0200 +++ /var/tmp/diff_new_pack.Xsy4ki/_new 2026-05-05 15:17:00.663223310 +0200 @@ -3,8 +3,8 @@ <param name="url">https://github.com/gordonklaus/ineffassign</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="versionformat">0.0.0+git%cd.%h</param> - <param name="revision">master</param> + <param name="versionformat">0.2.0</param> + <param name="revision">v0.2.0</param> <param name="changesgenerate">enable</param> </service> <service name="recompress" mode="manual"> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Xsy4ki/_old 2026-05-05 15:17:00.683224140 +0200 +++ /var/tmp/diff_new_pack.Xsy4ki/_new 2026-05-05 15:17:00.691224472 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/gordonklaus/ineffassign</param> - <param name="changesrevision">0e73809eb6015f1b6d49fbea72ab76e8d8ebfbc2</param></service></servicedata> + <param name="changesrevision">44548fda05c113cf0ecbac2921a332c7a13fda51</param></service></servicedata> (No newline at EOF) ++++++ ineffassign-0.0.0+git20230610.0e73809.tar.gz -> ineffassign-0.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ineffassign-0.0.0+git20230610.0e73809/.github/ISSUE_TEMPLATE/false-positive.md new/ineffassign-0.2.0/.github/ISSUE_TEMPLATE/false-positive.md --- old/ineffassign-0.0.0+git20230610.0e73809/.github/ISSUE_TEMPLATE/false-positive.md 2023-06-10 10:36:14.000000000 +0200 +++ new/ineffassign-0.2.0/.github/ISSUE_TEMPLATE/false-positive.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,12 +0,0 @@ ---- -name: False positive -about: Report a false positive reported by the tool -title: '' -labels: '' -assignees: '' - ---- - -The tool has flagged an assignment as ineffectual, but you think it is wrong. The burden is on you to show where the assignment is used. (Hint: the tool is time-tested and unlikely to report false positives. More likely, you've misunderstood your code.) - -Please provide enough code to reproduce the issue and a clear indication of which variable is assigned and on which line. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ineffassign-0.0.0+git20230610.0e73809/.gitignore new/ineffassign-0.2.0/.gitignore --- old/ineffassign-0.0.0+git20230610.0e73809/.gitignore 2023-06-10 10:36:14.000000000 +0200 +++ new/ineffassign-0.2.0/.gitignore 1970-01-01 01:00:00.000000000 +0100 @@ -1,30 +0,0 @@ -/ineffassign - -# Created by https://www.gitignore.io/api/go - -### Go ### -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ineffassign-0.0.0+git20230610.0e73809/README.md new/ineffassign-0.2.0/README.md --- old/ineffassign-0.0.0+git20230610.0e73809/README.md 2023-06-10 10:36:14.000000000 +0200 +++ new/ineffassign-0.2.0/README.md 2025-08-24 09:36:11.000000000 +0200 @@ -6,7 +6,7 @@ ## Install - go get -u github.com/gordonklaus/ineffassign + go install github.com/gordonklaus/ineffassign@latest ## Usage diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ineffassign-0.0.0+git20230610.0e73809/go.mod new/ineffassign-0.2.0/go.mod --- old/ineffassign-0.0.0+git20230610.0e73809/go.mod 2023-06-10 10:36:14.000000000 +0200 +++ new/ineffassign-0.2.0/go.mod 2025-08-24 09:36:11.000000000 +0200 @@ -1,5 +1,12 @@ module github.com/gordonklaus/ineffassign -go 1.14 +go 1.23.0 -require golang.org/x/tools v0.1.5 +toolchain go1.24.2 + +require golang.org/x/tools v0.33.0 + +require ( + golang.org/x/mod v0.24.0 // indirect + golang.org/x/sync v0.14.0 // indirect +) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ineffassign-0.0.0+git20230610.0e73809/go.sum new/ineffassign-0.2.0/go.sum --- old/ineffassign-0.0.0+git20230610.0e73809/go.sum 2023-06-10 10:36:14.000000000 +0200 +++ new/ineffassign-0.2.0/go.sum 2025-08-24 09:36:11.000000000 +0200 @@ -1,27 +1,8 @@ -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= +golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ineffassign-0.0.0+git20230610.0e73809/ineffassign.go new/ineffassign-0.2.0/ineffassign.go --- old/ineffassign-0.0.0+git20230610.0e73809/ineffassign.go 2023-06-10 10:36:14.000000000 +0200 +++ new/ineffassign-0.2.0/ineffassign.go 2025-08-24 09:36:11.000000000 +0200 @@ -9,6 +9,7 @@ "go/token" "log" "os" + "runtime/debug" "strings" "sync" @@ -21,6 +22,10 @@ log.SetFlags(0) log.SetPrefix(ineffassign.Analyzer.Name + ": ") + var ( + printVersion = flag.Bool("version", false, "print ineffassign version") + _ = flag.Bool("n", false, "no effect (deprecated)") + ) flag.Usage = func() { paras := strings.Split(ineffassign.Analyzer.Doc, "\n\n") fmt.Fprintf(os.Stderr, "%s: %s\n\n", ineffassign.Analyzer.Name, paras[0]) @@ -31,8 +36,17 @@ fmt.Fprintln(os.Stderr, "\nFlags:") flag.PrintDefaults() } + ineffassign.Analyzer.Flags.VisitAll(func(f *flag.Flag) { + flag.Var(f.Value, f.Name, f.Usage) + }) flag.Parse() + if *printVersion { + bi, _ := debug.ReadBuildInfo() + log.Print("version ", bi.Main.Version) + return + } + patterns := flag.Args() if len(patterns) == 0 { flag.Usage() @@ -114,7 +128,3 @@ return pkgs, nil } - -func init() { - flag.Bool("n", false, "no effect (deprecated)") -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ineffassign-0.0.0+git20230610.0e73809/pkg/ineffassign/ineffassign.go new/ineffassign-0.2.0/pkg/ineffassign/ineffassign.go --- old/ineffassign-0.0.0+git20230610.0e73809/pkg/ineffassign/ineffassign.go 2023-06-10 10:36:14.000000000 +0200 +++ new/ineffassign-0.2.0/pkg/ineffassign/ineffassign.go 2025-08-24 09:36:11.000000000 +0200 @@ -5,21 +5,26 @@ "go/ast" "go/token" "sort" - "strings" "golang.org/x/tools/go/analysis" ) +var checkEscapingErrors bool + // Analyzer is the ineffassign analysis.Analyzer instance. var Analyzer = &analysis.Analyzer{ Name: "ineffassign", - Doc: "detect ineffectual assignments in Go code", + Doc: "detects when assignments to existing variables are not used", Run: checkPath, } +func init() { + Analyzer.Flags.BoolVar(&checkEscapingErrors, "check-escaping-errors", false, "check escaping variables of type error, may cause false positives") +} + func checkPath(pass *analysis.Pass) (interface{}, error) { for _, file := range pass.Files { - if isGenerated(file) { + if ast.IsGenerated(file) { continue } @@ -35,6 +40,7 @@ for _, id := range chk.ineff { pass.Report(analysis.Diagnostic{ Pos: id.Pos(), + End: id.End(), Message: fmt.Sprintf("ineffectual assignment to %s", id.Name), }) } @@ -43,18 +49,6 @@ return nil, nil } -func isGenerated(file *ast.File) bool { - for _, cg := range file.Comments { - for _, c := range cg.List { - if strings.HasPrefix(c.Text, "// Code generated ") && strings.HasSuffix(c.Text, " DO NOT EDIT.") { - return true - } - } - } - - return false -} - type builder struct { roots []*block block *block @@ -96,10 +90,10 @@ switch n := n.(type) { case *ast.FuncDecl: if n.Body != nil { - bld.fun(n.Type, n.Body) + bld.fun(n.Recv, n.Type, n.Body) } case *ast.FuncLit: - bld.fun(n.Type, n.Body) + bld.fun(nil, n.Type, n.Body) case *ast.IfStmt: bld.walk(n.Init) bld.walk(n.Cond) @@ -290,9 +284,7 @@ id, ok = ident(ix.X) } if ok && n.Op == token.AND { - if v, ok := bld.vars[id.Obj]; ok { - v.escapes = true - } + bld.escape(id) } return bld case *ast.SelectorExpr: @@ -301,18 +293,14 @@ // the address of its receiver, causing it to escape. // We can't do any better here without knowing the variable's type. if id, ok := ident(n.X); ok { - if v, ok := bld.vars[id.Obj]; ok { - v.escapes = true - } + bld.escape(id) } return bld case *ast.SliceExpr: bld.maybePanic() // We don't care about slicing into slices, but without type information we can do no better. if id, ok := ident(n.X); ok { - if v, ok := bld.vars[id.Obj]; ok { - v.escapes = true - } + bld.escape(id) } return bld case *ast.StarExpr: @@ -328,6 +316,21 @@ return nil } +func (bld *builder) escape(id *ast.Ident) { + if checkEscapingErrors && id.Obj != nil { + if d, ok := id.Obj.Decl.(*ast.ValueSpec); ok { + if t, ok := d.Type.(*ast.Ident); ok { + if t.Name == "error" { + return + } + } + } + } + if v, ok := bld.vars[id.Obj]; ok { + v.escapes = true + } +} + func isZeroInitializer(x ast.Expr) bool { // Assume that a call expression of a single argument is a conversion expression. We can't do better without type information. if c, ok := x.(*ast.CallExpr); ok { @@ -362,7 +365,7 @@ return false } -func (bld *builder) fun(typ *ast.FuncType, body *ast.BlockStmt) { +func (bld *builder) fun(recv *ast.FieldList, typ *ast.FuncType, body *ast.BlockStmt) { for _, v := range bld.vars { v.fundept++ } @@ -372,6 +375,9 @@ b := bld.block bld.newBlock() bld.roots = append(bld.roots, bld.block) + if recv != nil { + bld.walk(recv) + } bld.walk(typ) bld.walk(body) bld.block = b diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ineffassign-0.0.0+git20230610.0e73809/pkg/ineffassign/testdata/testdata.go new/ineffassign-0.2.0/pkg/ineffassign/testdata/testdata.go --- old/ineffassign-0.0.0+git20230610.0e73809/pkg/ineffassign/testdata/testdata.go 2023-06-10 10:36:14.000000000 +0200 +++ new/ineffassign-0.2.0/pkg/ineffassign/testdata/testdata.go 2025-08-24 09:36:11.000000000 +0200 @@ -758,3 +758,12 @@ } func g() (int, error) { return 0, nil } + +type T struct{} + +func (t T) _() { + func() { + t = T{} + }() + _ = t +} ++++++ vendor.tar.gz ++++++ ++++ 55903 lines of diff (skipped)
