diff --git a/.github/workflows/lint-go.yaml b/.github/workflows/lint-go.yaml index d14521319..be7b21b27 100644 --- a/.github/workflows/lint-go.yaml +++ b/.github/workflows/lint-go.yaml @@ -20,7 +20,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.59.1 + version: v1.60.3 # use the default if on main branch, otherwise use the pull request config args: --timeout=30m --config=.golangci.yml only-new-issues: true diff --git a/.golangci.yml b/.golangci.yml index b9c99c667..76baf3bf4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,7 +22,7 @@ linters: - staticcheck - bidichk - durationcheck - - exportloopref + - copyloopvar - whitespace - gosec @@ -38,6 +38,11 @@ linters: linters-settings: gofmt: simplify: true + gosec: + excludes: + - G115 + - G406 # ignore ripe160 deprecation + - G507 # ignore ripe160 deprecation issues: max-issues-per-linter: 1000 diff --git a/cmd/thor/sync_logdb.go b/cmd/thor/sync_logdb.go index c27364ba2..b5062779c 100644 --- a/cmd/thor/sync_logdb.go +++ b/cmd/thor/sync_logdb.go @@ -276,8 +276,8 @@ func verifyLogDBPerBlock( ) error { convertTopics := func(topics []thor.Bytes32) (r [5]*thor.Bytes32) { for i, t := range topics { - t := t - r[i] = &t + topic := t + r[i] = &topic } return } @@ -378,9 +378,9 @@ func pumpBlockAndReceipts(ctx context.Context, repo *chain.Repository, headID th h.ID() } for _, tx := range b.Transactions() { - tx := tx + tmpTx := tx queue <- func() { - tx.ID() + tmpTx.ID() } } } diff --git a/comm/communicator.go b/comm/communicator.go index 4bdd1e2b2..a0ad58c0c 100644 --- a/comm/communicator.go +++ b/comm/communicator.go @@ -238,21 +238,21 @@ func (c *Communicator) BroadcastBlock(blk *block.Block) { toAnnounce := peers[p:] for _, peer := range toPropagate { - peer := peer - peer.MarkBlock(blk.Header().ID()) + tmpPeer := peer + tmpPeer.MarkBlock(blk.Header().ID()) c.goes.Go(func() { - if err := proto.NotifyNewBlock(c.ctx, peer, blk); err != nil { - peer.logger.Debug("failed to broadcast new block", "err", err) + if err := proto.NotifyNewBlock(c.ctx, tmpPeer, blk); err != nil { + tmpPeer.logger.Debug("failed to broadcast new block", "err", err) } }) } for _, peer := range toAnnounce { - peer := peer - peer.MarkBlock(blk.Header().ID()) + tmpPeer := peer + tmpPeer.MarkBlock(blk.Header().ID()) c.goes.Go(func() { - if err := proto.NotifyNewBlockID(c.ctx, peer, blk.Header().ID()); err != nil { - peer.logger.Debug("failed to broadcast new block id", "err", err) + if err := proto.NotifyNewBlockID(c.ctx, tmpPeer, blk.Header().ID()); err != nil { + tmpPeer.logger.Debug("failed to broadcast new block id", "err", err) } }) } diff --git a/comm/sync.go b/comm/sync.go index 9fe69d3d8..e2897806c 100644 --- a/comm/sync.go +++ b/comm/sync.go @@ -87,12 +87,12 @@ func warmupBlocks(ctx context.Context, fetched <-chan []*block.Block, warmedUp c h.Beta() } for _, tx := range blk.Transactions() { - tx := tx + tmpTx := tx queue <- func() { - tx.ID() - tx.UnprovedWork() - _, _ = tx.IntrinsicGas() - _, _ = tx.Delegator() + tmpTx.ID() + tmpTx.UnprovedWork() + _, _ = tmpTx.IntrinsicGas() + _, _ = tmpTx.Delegator() } } } diff --git a/comm/txs_loop.go b/comm/txs_loop.go index 85d887b35..3040ce587 100644 --- a/comm/txs_loop.go +++ b/comm/txs_loop.go @@ -27,11 +27,11 @@ func (c *Communicator) txsLoop() { }) for _, peer := range peers { - peer := peer - peer.MarkTransaction(tx.Hash()) + tmpPeer := peer + tmpPeer.MarkTransaction(tx.Hash()) c.goes.Go(func() { - if err := proto.NotifyNewTx(c.ctx, peer, tx); err != nil { - peer.logger.Debug("failed to broadcast tx", "err", err) + if err := proto.NotifyNewTx(c.ctx, tmpPeer, tx); err != nil { + tmpPeer.logger.Debug("failed to broadcast tx", "err", err) } }) } diff --git a/tracers/logger/logger.go b/tracers/logger/logger.go index ff3735a6e..f128cac61 100644 --- a/tracers/logger/logger.go +++ b/tracers/logger/logger.go @@ -450,7 +450,7 @@ func formatLogs(logs []StructLog) []StructLogRes { } formatted[index].Stack = &stack } - if trace.ReturnData != nil && len(trace.ReturnData) > 0 { + if len(trace.ReturnData) > 0 { formatted[index].ReturnData = hexutil.Bytes(trace.ReturnData).String() } if trace.Memory != nil {