From 22bfecfe38f2485a57724533a680bf5b2c346f4f Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Thu, 6 Apr 2023 17:58:52 -0400 Subject: [PATCH] style: fix linting issues in store module (#15724) ## Description - Return an exported type rather than an unexported type, from an exported function - Assign error values to _ - Add reason to nolint directive - Remove ineffectual assignment - Remove checked cast to same type as value --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] ~~provided a link to the relevant issue or specification~~ - [ ] ~~reviewed "Files changed" and left comments if necessary~~ - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed all author checklist items have been addressed - [ ] confirmed that this PR does not change production code --- store/cachekv/internal/mergeiterator.go | 2 +- store/iavl/tree_test.go | 4 ++-- store/internal/conv/string_test.go | 2 +- store/mem/store.go | 2 +- store/rootmulti/store.go | 1 - store/types/store_test.go | 2 -- 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/store/cachekv/internal/mergeiterator.go b/store/cachekv/internal/mergeiterator.go index e4d80ab491..58e9497b30 100644 --- a/store/cachekv/internal/mergeiterator.go +++ b/store/cachekv/internal/mergeiterator.go @@ -24,7 +24,7 @@ type cacheMergeIterator struct { var _ types.Iterator = (*cacheMergeIterator)(nil) -func NewCacheMergeIterator(parent, cache types.Iterator, ascending bool) *cacheMergeIterator { //nolint:revive +func NewCacheMergeIterator(parent, cache types.Iterator, ascending bool) types.Iterator { iter := &cacheMergeIterator{ parent: parent, cache: cache, diff --git a/store/iavl/tree_test.go b/store/iavl/tree_test.go index fa04129616..c03e9518c7 100644 --- a/store/iavl/tree_test.go +++ b/store/iavl/tree_test.go @@ -14,8 +14,8 @@ func TestImmutableTreePanics(t *testing.T) { it := &immutableTree{immTree} require.Panics(t, func() { it.Set([]byte{}, []byte{}) }) require.Panics(t, func() { it.Remove([]byte{}) }) - require.Panics(t, func() { it.SaveVersion() }) //nolint:errcheck - require.Panics(t, func() { it.DeleteVersion(int64(1)) }) //nolint:errcheck + require.Panics(t, func() { _, _, _ = it.SaveVersion() }) + require.Panics(t, func() { _ = it.DeleteVersion(int64(1)) }) imm, err := it.GetImmutable(1) require.Error(t, err) diff --git a/store/internal/conv/string_test.go b/store/internal/conv/string_test.go index 7029e3190a..3a14517531 100644 --- a/store/internal/conv/string_test.go +++ b/store/internal/conv/string_test.go @@ -26,7 +26,7 @@ func (s *StringSuite) TestUnsafeStrToBytes() { b := unsafeConvertStr() runtime.GC() <-time.NewTimer(2 * time.Millisecond).C - b2 := append(b, 'd') + b2 := append(b, 'd') s.Equal("abc", string(b)) s.Equal("abcd", string(b2)) } diff --git a/store/mem/store.go b/store/mem/store.go index ce83089f70..ca832d7b77 100644 --- a/store/mem/store.go +++ b/store/mem/store.go @@ -27,7 +27,7 @@ func NewStore() *Store { return NewStoreWithDB(dbm.NewMemDB()) } -func NewStoreWithDB(db *dbm.MemDB) *Store { //nolint: interfacer +func NewStoreWithDB(db *dbm.MemDB) *Store { //nolint: interfacer // Concrete return type is fine here. return &Store{Store: dbadapter.Store{DB: db}} } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index a47a9beaee..55ee77e394 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -827,7 +827,6 @@ func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error { node, err := exporter.Next() if err == iavltree.ErrorExportDone { rs.logger.Debug("snapshot Done", "store", store.name, "nodeCount", nodeCount) - nodeCount = 0 break } else if err != nil { return err diff --git a/store/types/store_test.go b/store/types/store_test.go index 0a46f84fc9..b6304d131b 100644 --- a/store/types/store_test.go +++ b/store/types/store_test.go @@ -233,8 +233,6 @@ func TestNewTransientStoreKeys(t *testing.T) { func TestNewInfiniteGasMeter(t *testing.T) { gm := NewInfiniteGasMeter() require.NotNil(t, gm) - _, ok := gm.(GasMeter) //nolint:gosimple - require.True(t, ok) } func TestStoreTypes(t *testing.T) {