Skip to content

Commit 5e716cf

Browse files
sync: coreth PR #1197: style: enable staticcheck linter (#1769)
Signed-off-by: Jonathan Oppenheimer <jonathan.oppenheimer@avalabs.org>
1 parent eab5ad0 commit 5e716cf

File tree

20 files changed

+59
-89
lines changed

20 files changed

+59
-89
lines changed

.avalanche-golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ linters:
7575
- predeclared
7676
- revive
7777
- spancheck
78-
# - staticcheck
78+
- staticcheck
7979
- tagalign
8080
# - testifylint
8181
- unconvert

accounts/abi/abi_extra_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515

1616
// Note: This file contains tests in addition to those found in go-ethereum.
1717

18-
const TEST_ABI = `[{"type":"function","name":"receive","inputs":[{"name":"sender","type":"address"},{"name":"amount","type":"uint256"},{"name":"memo","type":"bytes"}],"outputs":[{"internalType":"bool","name":"isAllowed","type":"bool"}]}]`
18+
const TestABI = `[{"type":"function","name":"receive","inputs":[{"name":"sender","type":"address"},{"name":"amount","type":"uint256"},{"name":"memo","type":"bytes"}],"outputs":[{"internalType":"bool","name":"isAllowed","type":"bool"}]}]`
1919

2020
func TestUnpackInputIntoInterface(t *testing.T) {
21-
abi, err := JSON(strings.NewReader(TEST_ABI))
21+
abi, err := JSON(strings.NewReader(TestABI))
2222
require.NoError(t, err)
2323

2424
type inputType struct {
@@ -35,7 +35,7 @@ func TestUnpackInputIntoInterface(t *testing.T) {
3535
rawData, err := abi.Pack("receive", input.Sender, input.Amount, input.Memo)
3636
require.NoError(t, err)
3737

38-
abi, err = JSON(strings.NewReader(TEST_ABI))
38+
abi, err = JSON(strings.NewReader(TestABI))
3939
require.NoError(t, err)
4040

4141
for _, test := range []struct {
@@ -97,7 +97,7 @@ func TestUnpackInputIntoInterface(t *testing.T) {
9797
}
9898

9999
func TestPackOutput(t *testing.T) {
100-
abi, err := JSON(strings.NewReader(TEST_ABI))
100+
abi, err := JSON(strings.NewReader(TestABI))
101101
require.NoError(t, err)
102102

103103
bytes, err := abi.PackOutput("receive", true)

cmd/simulator/load/loader.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,8 @@ func ExecuteLoader(ctx context.Context, config config.Config) error {
196196
log.Info("Distributed funds successfully", "time", time.Since(fundStart))
197197

198198
pks := make([]*ecdsa.PrivateKey, 0, len(keys))
199-
senders := make([]common.Address, 0, len(keys))
200199
for _, key := range keys {
201200
pks = append(pks, key.PrivKey)
202-
senders = append(senders, key.Address)
203201
}
204202

205203
bigGwei := big.NewInt(params.GWei)

core/extstate/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func wrapIfFirewood(db state.Database) state.Database {
2626
if !ok {
2727
return db
2828
}
29-
return &firewoodAccessorDb{
29+
return &firewoodAccessorDB{
3030
Database: db,
3131
fw: fw,
3232
}

core/extstate/firewood_database.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,35 @@ import (
1313
)
1414

1515
var (
16-
_ state.Database = (*firewoodAccessorDb)(nil)
16+
_ state.Database = (*firewoodAccessorDB)(nil)
1717
_ state.Trie = (*firewood.AccountTrie)(nil)
1818
_ state.Trie = (*firewood.StorageTrie)(nil)
1919
)
2020

21-
type firewoodAccessorDb struct {
21+
type firewoodAccessorDB struct {
2222
state.Database
2323
fw *firewood.Database
2424
}
2525

2626
// OpenTrie opens the main account trie.
27-
func (db *firewoodAccessorDb) OpenTrie(root common.Hash) (state.Trie, error) {
27+
func (db *firewoodAccessorDB) OpenTrie(root common.Hash) (state.Trie, error) {
2828
return firewood.NewAccountTrie(root, db.fw)
2929
}
3030

3131
// OpenStorageTrie opens a wrapped version of the account trie.
3232
//
3333
//nolint:revive // removing names loses context.
34-
func (*firewoodAccessorDb) OpenStorageTrie(stateRoot common.Hash, addr common.Address, accountRoot common.Hash, self state.Trie) (state.Trie, error) {
34+
func (*firewoodAccessorDB) OpenStorageTrie(stateRoot common.Hash, addr common.Address, accountRoot common.Hash, self state.Trie) (state.Trie, error) {
3535
accountTrie, ok := self.(*firewood.AccountTrie)
3636
if !ok {
37-
return nil, fmt.Errorf("Invalid account trie type: %T", self)
37+
return nil, fmt.Errorf("invalid account trie type: %T", self)
3838
}
3939
return firewood.NewStorageTrie(accountTrie)
4040
}
4141

4242
// CopyTrie returns a deep copy of the given trie.
4343
// It can be altered by the caller.
44-
func (*firewoodAccessorDb) CopyTrie(t state.Trie) state.Trie {
44+
func (*firewoodAccessorDB) CopyTrie(t state.Trie) state.Trie {
4545
switch t := t.(type) {
4646
case *firewood.AccountTrie:
4747
return t.Copy()

network/waiting_handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ func (w *waitingResponseHandler) OnFailure() error {
4949
return nil
5050
}
5151

52-
func (waitingHandler *waitingResponseHandler) WaitForResult(ctx context.Context) ([]byte, error) {
52+
func (w *waitingResponseHandler) WaitForResult(ctx context.Context) ([]byte, error) {
5353
select {
5454
case <-ctx.Done():
5555
return nil, ctx.Err()
56-
case response := <-waitingHandler.responseChan:
57-
if waitingHandler.failed {
56+
case response := <-w.responseChan:
57+
if w.failed {
5858
return nil, errRequestFailed
5959
}
6060
return response, nil

params/extras/network_upgrades.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ func (n *NetworkUpgrades) SetDefaults(agoUpgrades upgrade.Config) {
105105
func (n *NetworkUpgrades) verifyNetworkUpgrades(agoUpgrades upgrade.Config) error {
106106
defaults := GetNetworkUpgrades(agoUpgrades)
107107
if err := verifyWithDefault(n.SubnetEVMTimestamp, defaults.SubnetEVMTimestamp); err != nil {
108-
return fmt.Errorf("SubnetEVM fork block timestamp is invalid: %w", err)
108+
return fmt.Errorf("subnetEVM fork block timestamp is invalid: %w", err)
109109
}
110110
if err := verifyWithDefault(n.DurangoTimestamp, defaults.DurangoTimestamp); err != nil {
111-
return fmt.Errorf("Durango fork block timestamp is invalid: %w", err)
111+
return fmt.Errorf("durango fork block timestamp is invalid: %w", err)
112112
}
113113
if err := verifyWithDefault(n.EtnaTimestamp, defaults.EtnaTimestamp); err != nil {
114-
return fmt.Errorf("Etna fork block timestamp is invalid: %w", err)
114+
return fmt.Errorf("etna fork block timestamp is invalid: %w", err)
115115
}
116116
if err := verifyWithDefault(n.FortunaTimestamp, defaults.FortunaTimestamp); err != nil {
117-
return fmt.Errorf("Fortuna fork block timestamp is invalid: %w", err)
117+
return fmt.Errorf("fortuna fork block timestamp is invalid: %w", err)
118118
}
119119
if err := verifyWithDefault(n.GraniteTimestamp, defaults.GraniteTimestamp); err != nil {
120-
return fmt.Errorf("Granite fork block timestamp is invalid: %w", err)
120+
return fmt.Errorf("granite fork block timestamp is invalid: %w", err)
121121
}
122122
return nil
123123
}

plugin/evm/blockgascost/cost.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ func BlockGasCost(
3030
}
3131

3232
var (
33-
minBlockGasCost uint64 = feeConfig.MinBlockGasCost.Uint64()
34-
maxBlockGasCost uint64 = feeConfig.MaxBlockGasCost.Uint64()
35-
op = safemath.Add[uint64]
36-
defaultCost uint64 = feeConfig.MaxBlockGasCost.Uint64()
33+
minBlockGasCost = feeConfig.MinBlockGasCost.Uint64()
34+
maxBlockGasCost = feeConfig.MaxBlockGasCost.Uint64()
35+
op = safemath.Add[uint64]
36+
defaultCost = feeConfig.MaxBlockGasCost.Uint64()
3737
)
3838
if timeElapsed > feeConfig.TargetBlockRate {
3939
op = safemath.Sub

plugin/evm/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ type client struct {
4949

5050
// NewClient returns a Client for interacting with EVM [chain]
5151
func NewClient(uri, chain string) Client {
52-
requestUri := fmt.Sprintf("%s/ext/bc/%s", uri, chain)
53-
return NewClientWithURL(requestUri)
52+
requestURI := fmt.Sprintf("%s/ext/bc/%s", uri, chain)
53+
return NewClientWithURL(requestURI)
5454
}
5555

5656
// NewClientWithURL returns a Client for interacting with EVM [chain]

plugin/evm/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ type Config struct {
173173
WarpOffChainMessages []hexutil.Bytes `json:"warp-off-chain-messages"`
174174

175175
// RPC settings
176-
HttpBodyLimit uint64 `json:"http-body-limit"`
176+
HTTPBodyLimit uint64 `json:"http-body-limit"`
177177
BatchRequestLimit uint64 `json:"batch-request-limit"`
178178
BatchResponseMaxSize uint64 `json:"batch-response-max-size"`
179179

0 commit comments

Comments
 (0)