Skip to content

Commit

Permalink
fix: make format and golangci-lint errors (#1894)
Browse files Browse the repository at this point in the history
* removing gofmt from golangci.yml

* attempt to fix gofmt interacer lint errors

* updating makefile and running gofumpt

* adding exception to makefile for misspell, fixing chanOpenConfirm godoc

* removing unnecessary -s flag
  • Loading branch information
damiannolan authored Aug 5, 2022
1 parent 44541b8 commit e5ec801
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 39 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ linters:
- errcheck
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- gosec
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ lint-fix:
.PHONY: lint lint-fix

format: goimports
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs gofumpt -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs misspell -w
.PHONY: format

goimports:
Expand Down
1 change: 0 additions & 1 deletion e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io/ioutil"

"strings"
"time"

Expand Down
1 change: 1 addition & 0 deletions modules/apps/transfer/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
)

// NewMsgTransfer creates a new MsgTransfer instance
//
//nolint:interfacer
func NewMsgTransfer(
sourcePort, sourceChannel string,
Expand Down
8 changes: 4 additions & 4 deletions modules/apps/transfer/types/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ func (t Traces) Sort() Traces {
// ValidatePrefixedDenom checks that the denomination for an IBC fungible token packet denom is correctly prefixed.
// The function will return no error if the given string follows one of the two formats:
//
// - Prefixed denomination: '{portIDN}/{channelIDN}/.../{portID0}/{channelID0}/baseDenom'
// - Unprefixed denomination: 'baseDenom'
// - Prefixed denomination: '{portIDN}/{channelIDN}/.../{portID0}/{channelID0}/baseDenom'
// - Unprefixed denomination: 'baseDenom'
//
// 'baseDenom' may or may not contain '/'s
func ValidatePrefixedDenom(denom string) error {
Expand All @@ -205,8 +205,8 @@ func ValidatePrefixedDenom(denom string) error {

// ValidateIBCDenom validates that the given denomination is either:
//
// - A valid base denomination (eg: 'uatom' or 'gamm/pool/1' as in https://github.com/cosmos/ibc-go/issues/894)
// - A valid fungible token representation (i.e 'ibc/{hash}') per ADR 001 https://github.com/cosmos/ibc-go/blob/main/docs/architecture/adr-001-coin-source-tracing.md
// - A valid base denomination (eg: 'uatom' or 'gamm/pool/1' as in https://github.com/cosmos/ibc-go/issues/894)
// - A valid fungible token representation (i.e 'ibc/{hash}') per ADR 001 https://github.com/cosmos/ibc-go/blob/main/docs/architecture/adr-001-coin-source-tracing.md
func ValidateIBCDenom(denom string) error {
if err := sdk.ValidateDenom(denom); err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion modules/core/02-client/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
)

// NewMsgCreateClient creates a new MsgCreateClient instance
//
//nolint:interfacer
func NewMsgCreateClient(
clientState exported.ClientState, consensusState exported.ConsensusState, signer string,
Expand Down Expand Up @@ -102,6 +103,7 @@ func (msg MsgCreateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err
}

// NewMsgUpdateClient creates a new MsgUpdateClient instance
//
//nolint:interfacer
func NewMsgUpdateClient(id string, header exported.Header, signer string) (*MsgUpdateClient, error) {
anyHeader, err := PackHeader(header)
Expand Down Expand Up @@ -151,7 +153,8 @@ func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err
}

// NewMsgUpgradeClient creates a new MsgUpgradeClient instance
// nolint: interfacer
//
//nolint:interfacer
func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, consState exported.ConsensusState,
proofUpgradeClient, proofUpgradeConsState []byte, signer string,
) (*MsgUpgradeClient, error) {
Expand Down Expand Up @@ -228,6 +231,7 @@ func (msg MsgUpgradeClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) er
}

// NewMsgSubmitMisbehaviour creates a new MsgSubmitMisbehaviour instance.
//
//nolint:interfacer
func NewMsgSubmitMisbehaviour(clientID string, misbehaviour exported.Misbehaviour, signer string) (*MsgSubmitMisbehaviour, error) {
anyMisbehaviour, err := PackMisbehaviour(misbehaviour)
Expand Down
4 changes: 2 additions & 2 deletions modules/core/03-connection/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func (k Keeper) ConnOpenInit(
// code is executed on chain B).
//
// NOTE:
// - Here chain A acts as the counterparty
// - Identifiers are checked on msg validation
// - Here chain A acts as the counterparty
// - Identifiers are checked on msg validation
func (k Keeper) ConnOpenTry(
ctx sdk.Context,
counterparty types.Counterparty, // counterpartyConnectionIdentifier, counterpartyPrefix and counterpartyClientIdentifier
Expand Down
4 changes: 4 additions & 0 deletions modules/core/03-connection/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (

// NewMsgConnectionOpenInit creates a new MsgConnectionOpenInit instance. It sets the
// counterparty connection identifier to be empty.
//
//nolint:interfacer
func NewMsgConnectionOpenInit(
clientID, counterpartyClientID string,
Expand Down Expand Up @@ -72,6 +73,7 @@ func (msg MsgConnectionOpenInit) GetSigners() []sdk.AccAddress {
}

// NewMsgConnectionOpenTry creates a new MsgConnectionOpenTry instance
//
//nolint:interfacer
func NewMsgConnectionOpenTry(
clientID, counterpartyConnectionID, counterpartyClientID string,
Expand Down Expand Up @@ -165,6 +167,7 @@ func (msg MsgConnectionOpenTry) GetSigners() []sdk.AccAddress {
}

// NewMsgConnectionOpenAck creates a new MsgConnectionOpenAck instance
//
//nolint:interfacer
func NewMsgConnectionOpenAck(
connectionID, counterpartyConnectionID string, counterpartyClient exported.ClientState,
Expand Down Expand Up @@ -246,6 +249,7 @@ func (msg MsgConnectionOpenAck) GetSigners() []sdk.AccAddress {
}

// NewMsgConnectionOpenConfirm creates a new MsgConnectionOpenConfirm instance
//
//nolint:interfacer
func NewMsgConnectionOpenConfirm(
connectionID string, proofAck []byte, proofHeight clienttypes.Height,
Expand Down
2 changes: 1 addition & 1 deletion modules/core/04-channel/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (k Keeper) WriteOpenAckChannel(
}

// ChanOpenConfirm is called by the counterparty module to close their end of the
// channel, since the other end has been closed.
// channel, since the other end has been closed.
func (k Keeper) ChanOpenConfirm(
ctx sdk.Context,
portID,
Expand Down
30 changes: 20 additions & 10 deletions modules/core/04-channel/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var _ sdk.Msg = &MsgChannelOpenInit{}

// NewMsgChannelOpenInit creates a new MsgChannelOpenInit. It sets the counterparty channel
// identifier to be empty.
// nolint:interfacer
//
//nolint:interfacer
func NewMsgChannelOpenInit(
portID, version string, channelOrder Order, connectionHops []string,
counterpartyPortID string, signer string,
Expand Down Expand Up @@ -64,7 +65,8 @@ var _ sdk.Msg = &MsgChannelOpenTry{}
// NewMsgChannelOpenTry creates a new MsgChannelOpenTry instance
// The version string is deprecated and will be ignored by core IBC.
// It is left as an argument for go API backwards compatibility.
// nolint:interfacer
//
//nolint:interfacer
func NewMsgChannelOpenTry(
portID, version string, channelOrder Order, connectionHops []string,
counterpartyPortID, counterpartyChannelID, counterpartyVersion string,
Expand Down Expand Up @@ -126,7 +128,8 @@ func (msg MsgChannelOpenTry) GetSigners() []sdk.AccAddress {
var _ sdk.Msg = &MsgChannelOpenAck{}

// NewMsgChannelOpenAck creates a new MsgChannelOpenAck instance
// nolint:interfacer
//
//nolint:interfacer
func NewMsgChannelOpenAck(
portID, channelID, counterpartyChannelID string, cpv string, proofTry []byte, proofHeight clienttypes.Height,
signer string,
Expand Down Expand Up @@ -178,7 +181,8 @@ func (msg MsgChannelOpenAck) GetSigners() []sdk.AccAddress {
var _ sdk.Msg = &MsgChannelOpenConfirm{}

// NewMsgChannelOpenConfirm creates a new MsgChannelOpenConfirm instance
// nolint:interfacer
//
//nolint:interfacer
func NewMsgChannelOpenConfirm(
portID, channelID string, proofAck []byte, proofHeight clienttypes.Height,
signer string,
Expand Down Expand Up @@ -225,7 +229,8 @@ func (msg MsgChannelOpenConfirm) GetSigners() []sdk.AccAddress {
var _ sdk.Msg = &MsgChannelCloseInit{}

// NewMsgChannelCloseInit creates a new MsgChannelCloseInit instance
// nolint:interfacer
//
//nolint:interfacer
func NewMsgChannelCloseInit(
portID string, channelID string, signer string,
) *MsgChannelCloseInit {
Expand Down Expand Up @@ -263,7 +268,8 @@ func (msg MsgChannelCloseInit) GetSigners() []sdk.AccAddress {
var _ sdk.Msg = &MsgChannelCloseConfirm{}

// NewMsgChannelCloseConfirm creates a new MsgChannelCloseConfirm instance
// nolint:interfacer
//
//nolint:interfacer
func NewMsgChannelCloseConfirm(
portID, channelID string, proofInit []byte, proofHeight clienttypes.Height,
signer string,
Expand Down Expand Up @@ -310,7 +316,8 @@ func (msg MsgChannelCloseConfirm) GetSigners() []sdk.AccAddress {
var _ sdk.Msg = &MsgRecvPacket{}

// NewMsgRecvPacket constructs new MsgRecvPacket
// nolint:interfacer
//
//nolint:interfacer
func NewMsgRecvPacket(
packet Packet, proofCommitment []byte, proofHeight clienttypes.Height,
signer string,
Expand Down Expand Up @@ -357,7 +364,8 @@ func (msg MsgRecvPacket) GetSigners() []sdk.AccAddress {
var _ sdk.Msg = &MsgTimeout{}

// NewMsgTimeout constructs new MsgTimeout
// nolint:interfacer
//
//nolint:interfacer
func NewMsgTimeout(
packet Packet, nextSequenceRecv uint64, proofUnreceived []byte,
proofHeight clienttypes.Height, signer string,
Expand Down Expand Up @@ -399,7 +407,8 @@ func (msg MsgTimeout) GetSigners() []sdk.AccAddress {
}

// NewMsgTimeoutOnClose constructs new MsgTimeoutOnClose
// nolint:interfacer
//
//nolint:interfacer
func NewMsgTimeoutOnClose(
packet Packet, nextSequenceRecv uint64,
proofUnreceived, proofClose []byte,
Expand Down Expand Up @@ -448,7 +457,8 @@ func (msg MsgTimeoutOnClose) GetSigners() []sdk.AccAddress {
var _ sdk.Msg = &MsgAcknowledgement{}

// NewMsgAcknowledgement constructs a new MsgAcknowledgement
// nolint:interfacer
//
//nolint:interfacer
func NewMsgAcknowledgement(
packet Packet,
ack, proofAcked []byte,
Expand Down
1 change: 0 additions & 1 deletion modules/core/24-host/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
The storage path supported are defined in [ICS24](https://github.com/cosmos/ibc/blob/master/spec/core/ics-024-host-requirements#path-space).
Hostname validation is implemented as defined in [ICS 24](https://github.com/cosmos/ibc/tree/master/spec/core/ics-024-host-requirements).
*/
package host
2 changes: 1 addition & 1 deletion modules/core/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() {
// and unordered channels. It verifies that the deletion of a packet
// commitment occurs. It tests high level properties like ordering and basic
// sanity checks. More rigorous testing of 'TimeoutOnClose' and
//'TimeoutExecuted' can be found in the 04-channel/keeper/timeout_test.go.
// 'TimeoutExecuted' can be found in the 04-channel/keeper/timeout_test.go.
func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() {
var (
packet channeltypes.Packet
Expand Down
16 changes: 8 additions & 8 deletions modules/light-clients/06-solomachine/types/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func ClientStateSignBytes(
// SignBytes.
func ClientStateDataBytes(
cdc codec.BinaryCodec,
path commitmenttypes.MerklePath, // nolint: interfacer
path commitmenttypes.MerklePath, //nolint:interfacer
clientState exported.ClientState,
) ([]byte, error) {
any, err := clienttypes.PackClientState(clientState)
Expand Down Expand Up @@ -173,7 +173,7 @@ func ConsensusStateSignBytes(
// SignBytes.
func ConsensusStateDataBytes(
cdc codec.BinaryCodec,
path commitmenttypes.MerklePath, // nolint: interfacer
path commitmenttypes.MerklePath, //nolint:interfacer
consensusState exported.ConsensusState,
) ([]byte, error) {
any, err := clienttypes.PackConsensusState(consensusState)
Expand Down Expand Up @@ -223,7 +223,7 @@ func ConnectionStateSignBytes(
// SignBytes.
func ConnectionStateDataBytes(
cdc codec.BinaryCodec,
path commitmenttypes.MerklePath, // nolint: interfacer
path commitmenttypes.MerklePath, //nolint:interfacer
connectionEnd exported.ConnectionI,
) ([]byte, error) {
connection, ok := connectionEnd.(connectiontypes.ConnectionEnd)
Expand Down Expand Up @@ -276,7 +276,7 @@ func ChannelStateSignBytes(
// SignBytes.
func ChannelStateDataBytes(
cdc codec.BinaryCodec,
path commitmenttypes.MerklePath, // nolint: interfacer
path commitmenttypes.MerklePath, //nolint:interfacer
channelEnd exported.ChannelI,
) ([]byte, error) {
channel, ok := channelEnd.(channeltypes.Channel)
Expand Down Expand Up @@ -328,7 +328,7 @@ func PacketCommitmentSignBytes(
// SignBytes.
func PacketCommitmentDataBytes(
cdc codec.BinaryCodec,
path commitmenttypes.MerklePath, // nolint: interfacer
path commitmenttypes.MerklePath, //nolint:interfacer
commitmentBytes []byte,
) ([]byte, error) {
data := &PacketCommitmentData{
Expand Down Expand Up @@ -373,7 +373,7 @@ func PacketAcknowledgementSignBytes(
// SignBytes.
func PacketAcknowledgementDataBytes(
cdc codec.BinaryCodec,
path commitmenttypes.MerklePath, // nolint: interfacer
path commitmenttypes.MerklePath, //nolint:interfacer
acknowledgement []byte,
) ([]byte, error) {
data := &PacketAcknowledgementData{
Expand Down Expand Up @@ -417,7 +417,7 @@ func PacketReceiptAbsenceSignBytes(
// used in constructing SignBytes.
func PacketReceiptAbsenceDataBytes(
cdc codec.BinaryCodec,
path commitmenttypes.MerklePath, // nolint: interfacer
path commitmenttypes.MerklePath, //nolint:interfacer
) ([]byte, error) {
data := &PacketReceiptAbsenceData{
Path: []byte(path.String()),
Expand Down Expand Up @@ -460,7 +460,7 @@ func NextSequenceRecvSignBytes(
// SignBytes.
func NextSequenceRecvDataBytes(
cdc codec.BinaryCodec,
path commitmenttypes.MerklePath, // nolint: interfacer
path commitmenttypes.MerklePath, //nolint:interfacer
nextSequenceRecv uint64,
) ([]byte, error) {
data := &NextSequenceRecvData{
Expand Down
4 changes: 2 additions & 2 deletions modules/light-clients/07-tendermint/types/proposal_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
// Please see ADR 026 for more information.
//
// The following must always be true:
// - The substitute client is the same type as the subject client
// - The subject and substitute client states match in all parameters (expect frozen height, latest height, and chain-id)
// - The substitute client is the same type as the subject client
// - The subject and substitute client states match in all parameters (expect frozen height, latest height, and chain-id)
//
// In case 1) before updating the client, the client will be unfrozen by resetting
// the FrozenHeight to the zero Height.
Expand Down
8 changes: 4 additions & 4 deletions modules/light-clients/07-tendermint/types/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
// - the upgradedClient is not a Tendermint ClientState
// - the lastest height of the client state does not have the same revision number or has a greater
// height than the committed client.
// - the height of upgraded client is not greater than that of current client
// - the latest height of the new client does not match or is greater than the height in committed client
// - any Tendermint chain specified parameter in upgraded client such as ChainID, UnbondingPeriod,
// and ProofSpecs do not match parameters set by committed client
// - the height of upgraded client is not greater than that of current client
// - the latest height of the new client does not match or is greater than the height in committed client
// - any Tendermint chain specified parameter in upgraded client such as ChainID, UnbondingPeriod,
// and ProofSpecs do not match parameters set by committed client
func (cs ClientState) VerifyUpgradeAndUpdateState(
ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore,
upgradedClient exported.ClientState, upgradedConsState exported.ConsensusState,
Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (app *SimApp) ExportAppStateAndValidators(

// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
// in favour of export at a block height
func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

Expand Down

0 comments on commit e5ec801

Please sign in to comment.