Skip to content

Commit fe458d7

Browse files
committed
all: address staticcheck linter errors
1 parent f89114a commit fe458d7

File tree

33 files changed

+129
-133
lines changed

33 files changed

+129
-133
lines changed

.golangci-lint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ linters:
77
- ineffassign
88
- govet
99
- gosimple
10+
- staticcheck
1011

1112
issues:
1213
exclude-rules:

pkg/code/async/account/gift_card.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (p *service) giftCardAutoReturnWorker(serviceCtx context.Context, interval
4141
func() (err error) {
4242
time.Sleep(delay)
4343

44-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
44+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
4545
m := nr.StartTransaction("async__account_service__handle_gift_card_auto_return")
4646
defer m.End()
4747
tracedCtx := newrelic.NewContext(serviceCtx, m)

pkg/code/async/commitment/testutil.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package async_commitment
33
import (
44
"context"
55
"crypto/ed25519"
6+
"crypto/rand"
67
"encoding/hex"
78
"fmt"
89
"math"
9-
"math/rand"
10+
mrand "math/rand"
1011
"testing"
1112
"time"
1213

@@ -123,7 +124,7 @@ func (e testEnv) simulateCommitment(t *testing.T, recentRoot string, state commi
123124
Amount: kin.ToQuarks(1),
124125

125126
Intent: testutil.NewRandomAccount(t).PublicKey().ToBase58(),
126-
ActionId: rand.Uint32(),
127+
ActionId: mrand.Uint32(),
127128

128129
Owner: testutil.NewRandomAccount(t).PublicKey().ToBase58(),
129130

@@ -178,7 +179,7 @@ func (e testEnv) simulateCommitment(t *testing.T, recentRoot string, state commi
178179

179180
FulfillmentType: fulfillment.TemporaryPrivacyTransferWithAuthority,
180181
Data: []byte("data"),
181-
Signature: pointer.String(fmt.Sprintf("sig%d", rand.Uint64())),
182+
Signature: pointer.String(fmt.Sprintf("sig%d", mrand.Uint64())),
182183

183184
Nonce: pointer.String(testutil.NewRandomAccount(t).PublicKey().ToBase58()),
184185
Blockhash: pointer.String("bh"),
@@ -276,7 +277,7 @@ func (e testEnv) simulateCommitmentBeingUpgraded(t *testing.T, upgradeFrom, upgr
276277

277278
permanentPrivacyFulfillment := fulfillmentRecords[0].Clone()
278279
permanentPrivacyFulfillment.Id = 0
279-
permanentPrivacyFulfillment.Signature = pointer.String(fmt.Sprintf("txn%d", rand.Uint64()))
280+
permanentPrivacyFulfillment.Signature = pointer.String(fmt.Sprintf("txn%d", mrand.Uint64()))
280281
permanentPrivacyFulfillment.FulfillmentType = fulfillment.PermanentPrivacyTransferWithAuthority
281282
permanentPrivacyFulfillment.Destination = &upgradeTo.Vault
282283
require.NoError(t, e.data.PutAllFulfillments(e.ctx, &permanentPrivacyFulfillment))
@@ -492,7 +493,8 @@ func (e *testEnv) generateAvailableNonce(t *testing.T) *nonce.Record {
492493
nonceAccount := testutil.NewRandomAccount(t)
493494

494495
var bh solana.Blockhash
495-
rand.Read(bh[:])
496+
_, err := rand.Read(bh[:])
497+
require.NoError(t, err)
496498

497499
nonceKey := &vault.Record{
498500
PublicKey: nonceAccount.PublicKey().ToBase58(),

pkg/code/async/commitment/worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (p *service) worker(serviceCtx context.Context, state commitment.State, int
6060
func() (err error) {
6161
time.Sleep(delay)
6262

63-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
63+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
6464
m := nr.StartTransaction("async__commitment_service__handle_" + state.String())
6565
defer m.End()
6666
tracedCtx := newrelic.NewContext(serviceCtx, m)

pkg/code/async/currency/exchange_rate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (p *exchangeRateService) Start(serviceCtx context.Context, interval time.Du
3535
func() error {
3636
p.log.Trace("updating exchange rates")
3737

38-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
38+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
3939
m := nr.StartTransaction("async__currency_service")
4040
defer m.End()
4141
tracedCtx := newrelic.NewContext(serviceCtx, m)

pkg/code/async/geyser/backup.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (p *service) backupTimelockStateWorker(serviceCtx context.Context, interval
4141
start := time.Now()
4242

4343
func() {
44-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
44+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
4545
m := nr.StartTransaction("async__geyser_consumer_service__backup_timelock_state_worker")
4646
defer m.End()
4747
tracedCtx := newrelic.NewContext(serviceCtx, m)
@@ -113,7 +113,7 @@ func (p *service) backupExternalDepositWorker(serviceCtx context.Context, interv
113113
select {
114114
case <-time.After(interval):
115115
func() {
116-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
116+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
117117
m := nr.StartTransaction("async__geyser_consumer_service__backup_external_deposit_worker")
118118
defer m.End()
119119
tracedCtx := newrelic.NewContext(serviceCtx, m)
@@ -186,7 +186,7 @@ func (p *service) backupMessagingWorker(serviceCtx context.Context, interval tim
186186
start := time.Now()
187187

188188
func() {
189-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
189+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
190190
m := nr.StartTransaction("async__geyser_consumer_service__backup_messaging_worker")
191191
defer m.End()
192192
tracedCtx := newrelic.NewContext(serviceCtx, m)

pkg/code/async/geyser/consumer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/pkg/errors"
99
"github.com/sirupsen/logrus"
1010

11-
"github.com/code-payments/code-server/pkg/metrics"
1211
"github.com/code-payments/code-server/pkg/code/common"
12+
"github.com/code-payments/code-server/pkg/metrics"
1313
)
1414

1515
func (p *service) consumeGeyserProgramUpdateEvents(ctx context.Context) error {
@@ -76,7 +76,7 @@ func (p *service) programUpdateWorker(serviceCtx context.Context, id int) {
7676

7777
for update := range p.programUpdatesChan {
7878
func() {
79-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
79+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
8080
m := nr.StartTransaction("async__geyser_consumer_service__program_update_worker")
8181
defer m.End()
8282
tracedCtx := newrelic.NewContext(serviceCtx, m)

pkg/code/async/nonce/allocator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"context"
55
"time"
66

7+
"github.com/code-payments/code-server/pkg/code/data/nonce"
78
"github.com/code-payments/code-server/pkg/metrics"
89
"github.com/code-payments/code-server/pkg/retry"
9-
"github.com/code-payments/code-server/pkg/code/data/nonce"
1010
"github.com/newrelic/go-agent/v3/newrelic"
1111
)
1212

@@ -17,7 +17,7 @@ func (p *service) generateNonceAccounts(serviceCtx context.Context) error {
1717
func() (err error) {
1818
time.Sleep(time.Second)
1919

20-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
20+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
2121
m := nr.StartTransaction("async__nonce_service__nonce_accounts")
2222
defer m.End()
2323
tracedCtx := newrelic.NewContext(serviceCtx, m)

pkg/code/async/nonce/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (p *service) generateKeys(ctx context.Context) error {
3636
// Give the server some time to breath.
3737
time.Sleep(time.Second * 15)
3838

39-
nr := ctx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
39+
nr := ctx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
4040
m := nr.StartTransaction("async__nonce_service__vault_keys")
4141
defer func() {
4242
m.End()

pkg/code/async/nonce/pool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88
"github.com/mr-tron/base58/base58"
99
"github.com/newrelic/go-agent/v3/newrelic"
1010

11+
"github.com/code-payments/code-server/pkg/code/data/nonce"
12+
"github.com/code-payments/code-server/pkg/code/data/transaction"
1113
"github.com/code-payments/code-server/pkg/database/query"
1214
"github.com/code-payments/code-server/pkg/metrics"
1315
"github.com/code-payments/code-server/pkg/retry"
1416
"github.com/code-payments/code-server/pkg/solana"
1517
"github.com/code-payments/code-server/pkg/solana/system"
16-
"github.com/code-payments/code-server/pkg/code/data/nonce"
17-
"github.com/code-payments/code-server/pkg/code/data/transaction"
1818
)
1919

2020
func (p *service) worker(serviceCtx context.Context, state nonce.State, interval time.Duration) error {
@@ -25,7 +25,7 @@ func (p *service) worker(serviceCtx context.Context, state nonce.State, interval
2525
func() (err error) {
2626
time.Sleep(delay)
2727

28-
nr := serviceCtx.Value(metrics.NewRelicContextKey).(*newrelic.Application)
28+
nr := serviceCtx.Value(metrics.NewRelicContextKey{}).(*newrelic.Application)
2929
m := nr.StartTransaction("async__nonce_service__handle_" + state.String())
3030
defer m.End()
3131
tracedCtx := newrelic.NewContext(serviceCtx, m)

0 commit comments

Comments
 (0)