Skip to content

Commit a6fe076

Browse files
JonathanOppenheimeralarso16StephenButtolph
authored
style: enable staticcheck linter (#1197)
Signed-off-by: Jonathan Oppenheimer <147infiniti@gmail.com> Signed-off-by: Jonathan Oppenheimer <jonathan.oppenheimer@avalabs.org> Co-authored-by: Austin Larson <78000745+alarso16@users.noreply.github.com> Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
1 parent c7031a9 commit a6fe076

File tree

28 files changed

+81
-103
lines changed

28 files changed

+81
-103
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,33 +13,33 @@ 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.
32-
func (*firewoodAccessorDb) OpenStorageTrie(_ common.Hash, _ common.Address, accountRoot common.Hash, self state.Trie) (state.Trie, error) {
32+
func (*firewoodAccessorDB) OpenStorageTrie(_ common.Hash, _ common.Address, accountRoot common.Hash, self state.Trie) (state.Trie, error) {
3333
accountTrie, ok := self.(*firewood.AccountTrie)
3434
if !ok {
35-
return nil, fmt.Errorf("Invalid account trie type: %T", self)
35+
return nil, fmt.Errorf("invalid account trie type: %T", self)
3636
}
3737
return firewood.NewStorageTrie(accountTrie, accountRoot)
3838
}
3939

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

interfaces/interfaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
ethereum "github.com/ava-labs/libevm"
1515
)
1616

17-
// NotFound is returned by API methods if the requested item does not exist.
18-
var NotFound = errors.New("not found")
17+
// ErrNotFound is returned by API methods if the requested item does not exist.
18+
var ErrNotFound = errors.New("not found")
1919

2020
// Subscription represents an event subscription where events are
2121
// delivered on a data channel.

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

plugin/evm/atomic/state/atomic_trie_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,6 @@ func TestIndexingNilShouldNotImpactTrie(t *testing.T) {
377377
if err := indexAtomicTxs(a1, i, ops[i]); err != nil {
378378
t.Fatal(err)
379379
}
380-
} else {
381-
// do nothing
382380
}
383381
}
384382

plugin/evm/atomic/sync/syncer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ type syncerLeafTask struct {
218218
}
219219

220220
func (a *syncerLeafTask) Start() []byte { return addZeroes(a.syncer.lastHeight + 1) }
221-
func (_ *syncerLeafTask) End() []byte { return nil }
222-
func (_ *syncerLeafTask) NodeType() message.NodeType { return TrieNode }
221+
func (*syncerLeafTask) End() []byte { return nil }
222+
func (*syncerLeafTask) NodeType() message.NodeType { return TrieNode }
223223
func (a *syncerLeafTask) OnFinish(context.Context) error { return a.syncer.onFinish() }
224-
func (_ *syncerLeafTask) OnStart() (bool, error) { return false, nil }
224+
func (*syncerLeafTask) OnStart() (bool, error) { return false, nil }
225225
func (a *syncerLeafTask) Root() common.Hash { return a.syncer.targetRoot }
226-
func (_ *syncerLeafTask) Account() common.Hash { return common.Hash{} }
226+
func (*syncerLeafTask) Account() common.Hash { return common.Hash{} }
227227
func (a *syncerLeafTask) OnLeafs(keys, vals [][]byte) error {
228228
return a.syncer.onLeafs(keys, vals)
229229
}

plugin/evm/atomic/tx.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ type EVMOutput struct {
6767
AssetID ids.ID `serialize:"true" json:"assetID"`
6868
}
6969

70-
func (o EVMOutput) Compare(other EVMOutput) int {
71-
addrComp := bytes.Compare(o.Address.Bytes(), other.Address.Bytes())
70+
func (out EVMOutput) Compare(other EVMOutput) int {
71+
addrComp := bytes.Compare(out.Address.Bytes(), other.Address.Bytes())
7272
if addrComp != 0 {
7373
return addrComp
7474
}
75-
return bytes.Compare(o.AssetID[:], other.AssetID[:])
75+
return bytes.Compare(out.AssetID[:], other.AssetID[:])
7676
}
7777

7878
// EVMInput defines an input created from the EVM state to fund export transactions
@@ -83,12 +83,12 @@ type EVMInput struct {
8383
Nonce uint64 `serialize:"true" json:"nonce"`
8484
}
8585

86-
func (i EVMInput) Compare(other EVMInput) int {
87-
addrComp := bytes.Compare(i.Address.Bytes(), other.Address.Bytes())
86+
func (in EVMInput) Compare(other EVMInput) int {
87+
addrComp := bytes.Compare(in.Address.Bytes(), other.Address.Bytes())
8888
if addrComp != 0 {
8989
return addrComp
9090
}
91-
return bytes.Compare(i.AssetID[:], other.AssetID[:])
91+
return bytes.Compare(in.AssetID[:], other.AssetID[:])
9292
}
9393

9494
// Verify ...

0 commit comments

Comments
 (0)