From cb416cc93218751e10eee42da550b3213aa00308 Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Wed, 18 Dec 2024 13:52:34 +0700 Subject: [PATCH] Linter: Disable shadow linting for ctx and err It's been a year, and I'm still getting caught out by govet demanding I don't shadow a var I was deliberately shadowing. Made worse by an increase in clashes with stylecheck when they both want opposite things on the same line. --- .golangci.yml | 3 +++ exchanges/btse/btse_wrapper.go | 2 +- exchanges/subscription/template.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index b59ae9635b3..721dfbf15c0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -150,6 +150,9 @@ issues: - text: "Expect WriteFile permissions to be 0600 or less" linters: - gosec + - text: 'shadow: declaration of "(err|ctx)" shadows declaration at' + linters: [ govet ] + exclude-dirs: - vendor diff --git a/exchanges/btse/btse_wrapper.go b/exchanges/btse/btse_wrapper.go index 72d25f42925..54fa94d2a79 100644 --- a/exchanges/btse/btse_wrapper.go +++ b/exchanges/btse/btse_wrapper.go @@ -1281,7 +1281,7 @@ func (b *BTSE) UpdateOrderExecutionLimits(ctx context.Context, a asset.Item) err var errs error limits := make([]order.MinMaxLevel, 0, len(summary)) for _, marketInfo := range summary { - p, err := marketInfo.Pair() //nolint:govet // Deliberately shadow err + p, err := marketInfo.Pair() if err != nil { errs = common.AppendError(err, fmt.Errorf("%s: %w", p, err)) continue diff --git a/exchanges/subscription/template.go b/exchanges/subscription/template.go index ad48f3b462e..f112c5a390a 100644 --- a/exchanges/subscription/template.go +++ b/exchanges/subscription/template.go @@ -129,7 +129,7 @@ func expandTemplate(e iExchange, s *Subscription, ap assetPairs, assets asset.It } buf := &bytes.Buffer{} - if err := t.Execute(buf, subCtx); err != nil { //nolint:govet // Shadow, or gocritic will complain sloppyReassign + if err := t.Execute(buf, subCtx); err != nil { return nil, err }