From 621b393bc79519c098168989e9a373a0eb46c197 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 26 Jun 2022 14:43:31 +0200 Subject: [PATCH] review: breaking changes in a BUGFIX version are BAD --- pkg/golinters/nonamedreturns.go | 2 +- test/testdata/nonamedreturns_custom.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/golinters/nonamedreturns.go b/pkg/golinters/nonamedreturns.go index ebf0590490a0..65402bbb21e9 100644 --- a/pkg/golinters/nonamedreturns.go +++ b/pkg/golinters/nonamedreturns.go @@ -15,7 +15,7 @@ func NewNoNamedReturns(settings *config.NoNamedReturnsSettings) *goanalysis.Lint if settings != nil { cfg = map[string]map[string]interface{}{ a.Name: { - analyzer.FlagReportErrorInDefer: settings.ReportErrorInDefer || !settings.AllowErrorInDefer, + analyzer.FlagReportErrorInDefer: settings.ReportErrorInDefer && !settings.AllowErrorInDefer, }, } } diff --git a/test/testdata/nonamedreturns_custom.go b/test/testdata/nonamedreturns_custom.go index 13871c764268..53a8ba71f828 100644 --- a/test/testdata/nonamedreturns_custom.go +++ b/test/testdata/nonamedreturns_custom.go @@ -29,7 +29,7 @@ var e2 = func() (_ error) { return } -func deferWithError() (err error) { // ERROR `named return "err" with type "error" found` +func deferWithError() (err error) { defer func() { err = nil // use flag to allow this }() @@ -62,7 +62,7 @@ func funcDefintionImpl(arg1, arg2 interface{}) (int, error) { return 0, nil } -func funcDefintionImpl2(arg1, arg2 interface{}) (num int, err error) { // ERROR `named return "num" with type "int" found` `named return "err" with type "error" found` +func funcDefintionImpl2(arg1, arg2 interface{}) (num int, err error) { // ERROR `named return "num" with type "int" found` return 0, nil } @@ -103,12 +103,12 @@ func good(i string) string { return i } -func bad(i string, a, b int) (ret1 string, ret2 interface{}, ret3, ret4 int, ret5 asdf) { // ERROR `named return "ret1" with type "string" found` `named return "ret2" with type "interface{}" found` `named return "ret3" with type "int" found` `named return "ret4" with type "int" found` `named return "ret5" with type "asdf" found` +func bad(i string, a, b int) (ret1 string, ret2 interface{}, ret3, ret4 int, ret5 asdf) { // ERROR `named return "ret1" with type "string" found` x := "dummy" return fmt.Sprintf("%s", x), nil, 1, 2, asdf{} } -func bad2() (msg string, err error) { // ERROR `named return "msg" with type "string" found` `named return "err" with type "error" found` +func bad2() (msg string, err error) { // ERROR `named return "msg" with type "string" found` msg = "" err = nil return