Skip to content

Commit 0d2b34f

Browse files
authored
Merge pull request #6888 from onflow/jord/test-lint-upgrade
Upgrade golangci linter to 1.63
2 parents b740fc0 + c396112 commit 0d2b34f

File tree

16 files changed

+28
-50
lines changed

16 files changed

+28
-50
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
uses: golangci/golangci-lint-action@v3
5050
with:
5151
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
52-
version: v1.54
52+
version: v1.63
5353
args: -v
5454
working-directory: ${{ matrix.dir }}
5555
# https://github.com/golangci/golangci-lint-action/issues/244

cmd/util/cmd/common/node_info.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ func ReadFullPartnerNodeInfos(log zerolog.Logger, partnerWeightsPath, partnerNod
4141
}
4242
err = ValidateNetworkPubKey(partner.NetworkPubKey)
4343
if err != nil {
44-
return nil, fmt.Errorf(fmt.Sprintf("invalid network public key: %s", partner.NetworkPubKey))
44+
return nil, fmt.Errorf("invalid network public key: %s", partner.NetworkPubKey)
4545
}
4646
err = ValidateStakingPubKey(partner.StakingPubKey)
4747
if err != nil {
48-
return nil, fmt.Errorf(fmt.Sprintf("invalid staking public key: %s", partner.StakingPubKey))
48+
return nil, fmt.Errorf("invalid staking public key: %s", partner.StakingPubKey)
4949
}
5050

5151
weight := weights[partner.NodeID]
5252
if valid := ValidateWeight(weight); !valid {
53-
return nil, fmt.Errorf(fmt.Sprintf("invalid partner weight %v: %d", partner.NodeID, weight))
53+
return nil, fmt.Errorf("invalid partner weight %v: %d", partner.NodeID, weight)
5454
}
5555

5656
if weight != flow.DefaultInitialWeight {
@@ -143,12 +143,12 @@ func ReadFullInternalNodeInfos(log zerolog.Logger, internalNodePrivInfoDir, inte
143143
// validate every single internal node
144144
err := ValidateNodeID(internal.NodeID)
145145
if err != nil {
146-
return nil, fmt.Errorf(fmt.Sprintf("invalid internal node ID: %s", internal.NodeID))
146+
return nil, fmt.Errorf("invalid internal node ID: %s", internal.NodeID)
147147
}
148148
weight := weights[internal.Address]
149149

150150
if valid := ValidateWeight(weight); !valid {
151-
return nil, fmt.Errorf(fmt.Sprintf("invalid partner weight %v: %d", internal.NodeID, weight))
151+
return nil, fmt.Errorf("invalid partner weight %v: %d", internal.NodeID, weight)
152152
}
153153
if weight != flow.DefaultInitialWeight {
154154
log.Warn().Msgf("internal node (id=%x) has non-default weight (%d != %d)", internal.NodeID, weight, flow.DefaultInitialWeight)

engine/access/rpc/backend/backend_transactions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (b *backendTransactions) getTransactionResultsByBlockIDFromExecutionNode(
417417
)
418418
if err != nil {
419419
if IsInsufficientExecutionReceipts(err) {
420-
return nil, status.Errorf(codes.NotFound, err.Error())
420+
return nil, status.Error(codes.NotFound, err.Error())
421421
}
422422
return nil, rpc.ConvertError(err, "failed to retrieve result from any execution node", codes.Internal)
423423
}
@@ -574,7 +574,7 @@ func (b *backendTransactions) getTransactionResultByIndexFromExecutionNode(
574574
)
575575
if err != nil {
576576
if IsInsufficientExecutionReceipts(err) {
577-
return nil, status.Errorf(codes.NotFound, err.Error())
577+
return nil, status.Error(codes.NotFound, err.Error())
578578
}
579579
return nil, rpc.ConvertError(err, "failed to retrieve result from any execution node", codes.Internal)
580580
}
@@ -762,7 +762,7 @@ func (b *backendTransactions) getTransactionResultFromExecutionNode(
762762
if err != nil {
763763
// if no execution receipt were found, return a NotFound GRPC error
764764
if IsInsufficientExecutionReceipts(err) {
765-
return nil, status.Errorf(codes.NotFound, err.Error())
765+
return nil, status.Error(codes.NotFound, err.Error())
766766
}
767767
return nil, err
768768
}
@@ -1002,7 +1002,7 @@ func (b *backendTransactions) LookupErrorMessageByTransactionID(
10021002
)
10031003
if err != nil {
10041004
if IsInsufficientExecutionReceipts(err) {
1005-
return "", status.Errorf(codes.NotFound, err.Error())
1005+
return "", status.Error(codes.NotFound, err.Error())
10061006
}
10071007
return "", rpc.ConvertError(err, "failed to select execution nodes", codes.Internal)
10081008
}
@@ -1057,7 +1057,7 @@ func (b *backendTransactions) LookupErrorMessageByIndex(
10571057
)
10581058
if err != nil {
10591059
if IsInsufficientExecutionReceipts(err) {
1060-
return "", status.Errorf(codes.NotFound, err.Error())
1060+
return "", status.Error(codes.NotFound, err.Error())
10611061
}
10621062
return "", rpc.ConvertError(err, "failed to select execution nodes", codes.Internal)
10631063
}
@@ -1117,7 +1117,7 @@ func (b *backendTransactions) LookupErrorMessagesByBlockID(
11171117
)
11181118
if err != nil {
11191119
if IsInsufficientExecutionReceipts(err) {
1120-
return nil, status.Errorf(codes.NotFound, err.Error())
1120+
return nil, status.Error(codes.NotFound, err.Error())
11211121
}
11221122
return nil, rpc.ConvertError(err, "failed to select execution nodes", codes.Internal)
11231123
}

engine/collection/compliance/core_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func (cs *CoreSuite) TestOnBlockProposal_FailsProtocolStateValidation() {
376376
// make sure we fail to extend the state
377377
*cs.state = clusterstate.MutableState{}
378378
cs.state.On("Final").Return(func() clusterint.Snapshot { return cs.snapshot })
379-
sentinelErr := state.NewInvalidExtensionError("")
379+
sentinelErr := state.NewInvalidExtensionErrorf("")
380380
cs.state.On("Extend", mock.Anything).Return(sentinelErr)
381381
cs.proposalViolationNotifier.On("OnInvalidBlockDetected", mock.Anything).Run(func(args mock.Arguments) {
382382
err := args.Get(0).(flow.Slashable[model.InvalidProposalError])
@@ -406,7 +406,7 @@ func (cs *CoreSuite) TestOnBlockProposal_FailsProtocolStateValidation() {
406406
// make sure we fail to extend the state
407407
*cs.state = clusterstate.MutableState{}
408408
cs.state.On("Final").Return(func() clusterint.Snapshot { return cs.snapshot })
409-
cs.state.On("Extend", mock.Anything).Return(state.NewOutdatedExtensionError(""))
409+
cs.state.On("Extend", mock.Anything).Return(state.NewOutdatedExtensionErrorf(""))
410410

411411
// the expected error should be handled within the Core
412412
err := cs.core.OnBlockProposal(flow.Slashable[*messages.ClusterBlockProposal]{

engine/common/grpc/forwarder/forwarder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (f *Forwarder) reconnectingClient(i int) error {
7575
// FaultTolerantClient implements an upstream connection that reconnects on errors
7676
// a reasonable amount of time.
7777
func (f *Forwarder) FaultTolerantClient() (access.AccessAPIClient, io.Closer, error) {
78-
if f.upstream == nil || len(f.upstream) == 0 {
78+
if len(f.upstream) == 0 {
7979
return nil, nil, status.Errorf(codes.Unimplemented, "method not implemented")
8080
}
8181

@@ -101,5 +101,5 @@ func (f *Forwarder) FaultTolerantClient() (access.AccessAPIClient, io.Closer, er
101101
return f.upstream[f.roundRobin].client, f.upstream[f.roundRobin].closer, nil
102102
}
103103

104-
return nil, nil, status.Errorf(codes.Unavailable, err.Error())
104+
return nil, nil, status.Error(codes.Unavailable, err.Error())
105105
}

engine/consensus/compliance/core_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ func (cs *CoreSuite) TestOnBlockProposal_FailsProtocolStateValidation() {
459459
// make sure we fail to extend the state
460460
*cs.state = protocol.ParticipantState{}
461461
cs.state.On("Final").Return(func() protint.Snapshot { return cs.snapshot })
462-
sentinelErr := state.NewInvalidExtensionError("")
462+
sentinelErr := state.NewInvalidExtensionErrorf("")
463463
cs.state.On("Extend", mock.Anything, mock.Anything).Return(sentinelErr)
464464
cs.proposalViolationNotifier.On("OnInvalidBlockDetected", mock.Anything).Run(func(args mock.Arguments) {
465465
err := args.Get(0).(flow.Slashable[model.InvalidProposalError])
@@ -489,7 +489,7 @@ func (cs *CoreSuite) TestOnBlockProposal_FailsProtocolStateValidation() {
489489
// make sure we fail to extend the state
490490
*cs.state = protocol.ParticipantState{}
491491
cs.state.On("Final").Return(func() protint.Snapshot { return cs.snapshot })
492-
cs.state.On("Extend", mock.Anything, mock.Anything).Return(state.NewOutdatedExtensionError(""))
492+
cs.state.On("Extend", mock.Anything, mock.Anything).Return(state.NewOutdatedExtensionErrorf(""))
493493

494494
// the expected error should be handled within the Core
495495
err := cs.core.OnBlockProposal(flow.Slashable[*messages.BlockProposal]{

engine/consensus/matching/core_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (ms *MatchingSuite) TestOnReceiptInvalid() {
166166
)
167167

168168
// check that _expected_ failure case of invalid receipt is handled without error
169-
ms.receiptValidator.On("Validate", receipt).Return(engine.NewInvalidInputError("")).Once()
169+
ms.receiptValidator.On("Validate", receipt).Return(engine.NewInvalidInputErrorf("")).Once()
170170
wasAdded, err := ms.core.processReceipt(receipt)
171171
ms.Require().NoError(err, "invalid receipt should be dropped but not error")
172172
ms.Require().False(wasAdded, "invalid receipt should not be added")

engine/errors.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ type InvalidInputError struct {
2222
err error
2323
}
2424

25-
func NewInvalidInputError(msg string) error {
26-
return NewInvalidInputErrorf(msg)
27-
}
28-
2925
func NewInvalidInputErrorf(msg string, args ...interface{}) error {
3026
return InvalidInputError{
3127
err: fmt.Errorf(msg, args...),
@@ -64,12 +60,6 @@ func NewNetworkTransmissionErrorf(msg string, args ...interface{}) error {
6460
}
6561
}
6662

67-
func NewNetworkTransmissionError(msg string) error {
68-
return NetworkTransmissionError{
69-
err: fmt.Errorf(msg),
70-
}
71-
}
72-
7363
func (e NetworkTransmissionError) Unwrap() error {
7464
return e.err
7565
}

integration/tests/access/cohort4/execution_data_pruning_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (s *ExecutionDataPruningSuite) SetupTest() {
8585
testnet.WithAdditionalFlagf("--event-query-mode=local-only"),
8686
testnet.WithAdditionalFlagf("--execution-data-height-range-target=%d", s.heightRangeTarget),
8787
testnet.WithAdditionalFlagf("--execution-data-height-range-threshold=%d", s.threshold),
88-
testnet.WithAdditionalFlagf(fmt.Sprintf("--execution-data-pruning-interval=%s", s.pruningInterval)),
88+
testnet.WithAdditionalFlagf("--execution-data-pruning-interval=%s", s.pruningInterval),
8989
)
9090

9191
consensusConfigs := []func(config *testnet.NodeConfig){

module/mempool/errors.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ type UnknownExecutionResultError struct {
1010
err error
1111
}
1212

13-
func NewUnknownExecutionResultError(msg string) error {
14-
return NewUnknownExecutionResultErrorf(msg)
15-
}
16-
1713
func NewUnknownExecutionResultErrorf(msg string, args ...interface{}) error {
1814
return UnknownExecutionResultError{
1915
err: fmt.Errorf(msg, args...),

0 commit comments

Comments
 (0)