From 74be21f34f0dd2c6e2d761a5c878f43d8889c802 Mon Sep 17 00:00:00 2001 From: Noulodado Date: Mon, 23 Dec 2024 11:53:52 +0000 Subject: [PATCH] fix: linter fixes. --- modules/core/04-channel/keeper/keeper.go | 10 +++++----- modules/core/24-host/validate.go | 6 +++--- modules/light-clients/07-tendermint/client_state.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index c14f6aa49c8..527cd10007d 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -369,7 +369,7 @@ func (k *Keeper) GetAllPacketAckSeqs(ctx context.Context) (seqs []types.PacketSe func (k *Keeper) IteratePacketCommitment(ctx context.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketCommitmentPrefix)) - k.iterateHashes(ctx, iterator, cb) + k.iterateHashes(iterator, cb) } // GetAllPacketCommitments returns all stored PacketCommitments objects. @@ -388,7 +388,7 @@ func (k *Keeper) GetAllPacketCommitments(ctx context.Context) (commitments []typ func (k *Keeper) IteratePacketCommitmentAtChannel(ctx context.Context, portID, channelID string, cb func(_, _ string, sequence uint64, hash []byte) bool) { store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, host.PacketCommitmentPrefixKey(portID, channelID)) - k.iterateHashes(ctx, iterator, cb) + k.iterateHashes(iterator, cb) } // GetAllPacketCommitmentsAtChannel returns all stored PacketCommitments objects for a specified @@ -408,7 +408,7 @@ func (k *Keeper) GetAllPacketCommitmentsAtChannel(ctx context.Context, portID, c func (k *Keeper) IteratePacketReceipt(ctx context.Context, cb func(portID, channelID string, sequence uint64, receipt []byte) bool) { store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketReceiptPrefix)) - k.iterateHashes(ctx, iterator, cb) + k.iterateHashes(iterator, cb) } // GetAllPacketReceipts returns all stored PacketReceipt objects. @@ -427,7 +427,7 @@ func (k *Keeper) GetAllPacketReceipts(ctx context.Context) (receipts []types.Pac func (k *Keeper) IteratePacketAcknowledgement(ctx context.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketAckPrefix)) - k.iterateHashes(ctx, iterator, cb) + k.iterateHashes(iterator, cb) } // GetAllPacketAcks returns all stored PacketAcknowledgements objects. @@ -688,7 +688,7 @@ func (k *Keeper) GetParams(ctx context.Context) types.Params { } // common functionality for IteratePacketCommitment and IteratePacketAcknowledgement -func (k *Keeper) iterateHashes(ctx context.Context, iterator db.Iterator, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { +func (k *Keeper) iterateHashes(iterator db.Iterator, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { diff --git a/modules/core/24-host/validate.go b/modules/core/24-host/validate.go index 3ba0f88847c..6407a8a6326 100644 --- a/modules/core/24-host/validate.go +++ b/modules/core/24-host/validate.go @@ -36,7 +36,7 @@ var IsValidID = regexp.MustCompile(`^[a-zA-Z0-9\.\_\+\-\#\[\]\<\>]+$`).MatchStri // ValidateFn function type to validate path and identifier bytestrings type ValidateFn func(string) error -func defaultIdentifierValidator(id string, min, max int) error { +func defaultIdentifierValidator(id string, minimum, maximum int) error { if strings.TrimSpace(id) == "" { return errorsmod.Wrap(ErrInvalidID, "identifier cannot be blank") } @@ -45,8 +45,8 @@ func defaultIdentifierValidator(id string, min, max int) error { return errorsmod.Wrapf(ErrInvalidID, "identifier %s cannot contain separator '/'", id) } // valid id must fit the length requirements - if len(id) < min || len(id) > max { - return errorsmod.Wrapf(ErrInvalidID, "identifier %s has invalid length: %d, must be between %d-%d characters", id, len(id), min, max) + if len(id) < minimum || len(id) > maximum { + return errorsmod.Wrapf(ErrInvalidID, "identifier %s has invalid length: %d, must be between %d-%d characters", id, len(id), minimum, maximum) } // valid id must contain only alphanumeric characters and some allowed symbols. if !IsValidID(id) { diff --git a/modules/light-clients/07-tendermint/client_state.go b/modules/light-clients/07-tendermint/client_state.go index 89ab21128d7..f400f4cbf47 100644 --- a/modules/light-clients/07-tendermint/client_state.go +++ b/modules/light-clients/07-tendermint/client_state.go @@ -125,7 +125,7 @@ func (cs ClientState) Validate() error { } if err := light.ValidateTrustLevel(cs.TrustLevel.ToTendermint()); err != nil { - return errorsmod.Wrapf(ErrInvalidTrustLevel, err.Error()) + return errorsmod.Wrap(ErrInvalidTrustLevel, err.Error()) } if cs.TrustingPeriod <= 0 { return errorsmod.Wrap(ErrInvalidTrustingPeriod, "trusting period must be greater than zero") @@ -143,7 +143,7 @@ func (cs ClientState) Validate() error { "latest height revision number must match chain id revision number (%d != %d)", cs.LatestHeight.RevisionNumber, clienttypes.ParseChainID(cs.ChainId)) } if cs.LatestHeight.RevisionHeight == 0 { - return errorsmod.Wrapf(ErrInvalidHeaderHeight, "tendermint client's latest height revision height cannot be zero") + return errorsmod.Wrap(ErrInvalidHeaderHeight, "tendermint client's latest height revision height cannot be zero") } if cs.TrustingPeriod >= cs.UnbondingPeriod { return errorsmod.Wrapf(