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
This commit is contained in:
Mark Rushakoff 2023-04-06 17:58:52 -04:00 committed by GitHub
parent 06892b9bc4
commit 22bfecfe38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 8 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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))
}

View File

@ -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}}
}

View File

@ -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

View File

@ -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) {