Skip to content

Commit

Permalink
refactor: add unparam linter (#4333)
Browse files Browse the repository at this point in the history
* add unparam linter

* remove unused-param from revive, add comments.

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
  • Loading branch information
3 people authored Aug 21, 2023
1 parent 8c45153 commit 1d514f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ linters:
- typecheck
- tenv
- unconvert
# Prefer unparam over revive's unused param. It is more thorough in its checking.
- unparam
- unused
- misspell

Expand Down Expand Up @@ -100,6 +102,9 @@ linters-settings:
disabled: true
- name: defer
disabled: true
# Disabled in favour of unparam.
- name: unused-parameter
disabled: true
- name: unhandled-error
disabled: false
arguments:
Expand Down
8 changes: 4 additions & 4 deletions modules/core/02-client/migrations/v7/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Binar
return err
}

if err := handleTendermintMigration(ctx, store, cdc, clientKeeper); err != nil {
if err := handleTendermintMigration(ctx, store, clientKeeper); err != nil {
return err
}

return handleLocalhostMigration(ctx, store, cdc, clientKeeper)
return handleLocalhostMigration(ctx, store, clientKeeper)
}

// handleSolomachineMigration iterates over the solo machine clients and migrates client state from
Expand Down Expand Up @@ -82,7 +82,7 @@ func handleSolomachineMigration(ctx sdk.Context, store storetypes.KVStore, cdc c

// handlerTendermintMigration asserts that the tendermint client in state can be decoded properly.
// This ensures the upgrading chain properly registered the tendermint client types on the chain codec.
func handleTendermintMigration(ctx sdk.Context, store storetypes.KVStore, cdc codec.BinaryCodec, clientKeeper ClientKeeper) error {
func handleTendermintMigration(ctx sdk.Context, store storetypes.KVStore, clientKeeper ClientKeeper) error {
clients, err := collectClients(ctx, store, exported.Tendermint)
if err != nil {
return err
Expand Down Expand Up @@ -114,7 +114,7 @@ func handleTendermintMigration(ctx sdk.Context, store storetypes.KVStore, cdc co
}

// handleLocalhostMigration removes all client and consensus states associated with the localhost client type.
func handleLocalhostMigration(ctx sdk.Context, store storetypes.KVStore, cdc codec.BinaryCodec, clientKeeper ClientKeeper) error {
func handleLocalhostMigration(ctx sdk.Context, store storetypes.KVStore, clientKeeper ClientKeeper) error {
clients, err := collectClients(ctx, store, Localhost)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (ClientState) CheckForMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ st
return false
}

func (cs ClientState) verifyMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, misbehaviour *Misbehaviour) error {
func (cs ClientState) verifyMisbehaviour(cdc codec.BinaryCodec, misbehaviour *Misbehaviour) error {
// NOTE: a check that the misbehaviour message data are not equal is done by
// misbehaviour.ValidateBasic which is called by the 02-client keeper.
// verify first signature
Expand Down
6 changes: 3 additions & 3 deletions modules/light-clients/06-solomachine/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import (
func (cs ClientState) VerifyClientMessage(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) error {
switch msg := clientMsg.(type) {
case *Header:
return cs.verifyHeader(ctx, cdc, clientStore, msg)
return cs.verifyHeader(cdc, msg)
case *Misbehaviour:
return cs.verifyMisbehaviour(ctx, cdc, clientStore, msg)
return cs.verifyMisbehaviour(cdc, msg)
default:
return errorsmod.Wrapf(clienttypes.ErrInvalidClientType, "expected type of %T or %T, got type %T", Header{}, Misbehaviour{}, msg)
}
}

func (cs ClientState) verifyHeader(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, header *Header) error {
func (cs ClientState) verifyHeader(cdc codec.BinaryCodec, header *Header) error {
// assert update timestamp is not less than current consensus state timestamp
if header.Timestamp < cs.ConsensusState.Timestamp {
return errorsmod.Wrapf(
Expand Down

0 comments on commit 1d514f8

Please sign in to comment.