diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 11e422b923..45e3b3c1d7 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -19,13 +19,13 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: "1.20" + go-version: '1.20' - uses: actions/checkout@v3 - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.52.2 + version: v1.53.3 # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/.golangci.yml b/.golangci.yml index 5a3b555a6d..5bf3cfb98f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,9 +3,8 @@ run: timeout: 10m sort-results: true allow-parallel-runners: true - skip-dirs: - - "legacy_ibc_testing" - - "testutil" + skip-dirs: + - 'testutil' linters: disable-all: true @@ -31,28 +30,24 @@ linters: - unconvert - unused - - - - issues: exclude-rules: - - text: "Use of weak random number generator" + - text: 'Use of weak random number generator' linters: - gosec - - text: "ST1003:" + - text: 'ST1003:' linters: - stylecheck # FIXME: Disabled until golangci-lint updates stylecheck with this fix: # https://github.com/dominikh/go-tools/issues/389 - - text: "ST1016:" + - text: 'ST1016:' linters: - stylecheck - - path: "migrations" - text: "SA1019:" + - path: 'migrations' + text: 'SA1019:' linters: - staticcheck - - text: "leading space" + - text: 'leading space' linters: - nolintlint diff --git a/legacy_ibc_testing/core/events.go b/legacy_ibc_testing/core/events.go index daabc92d54..a01c14c685 100644 --- a/legacy_ibc_testing/core/events.go +++ b/legacy_ibc_testing/core/events.go @@ -3,10 +3,10 @@ package core import ( "strconv" - abci "github.com/cometbft/cometbft/abci/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + + abci "github.com/cometbft/cometbft/abci/types" ) /* @@ -20,7 +20,7 @@ These files will be deprecated once ICS is able to upgrade to ibc-go v5. func ReconstructPacketFromEvent(event abci.Event) (packet types.Packet, err error) { attrMap := make(map[string][]byte) for _, attr := range event.Attributes { - attrMap[string(attr.Key)] = []byte(attr.Value) + attrMap[attr.Key] = []byte(attr.Value) } sequence, err := strconv.Atoi(string(attrMap[string(types.AttributeKeySequence)])) @@ -36,7 +36,7 @@ func ReconstructPacketFromEvent(event abci.Event) (packet types.Packet, err erro return packet, err } return types.NewPacket( - attrMap[string(types.AttributeKeyData)], // data + attrMap[string(types.AttributeKeyData)], //nolint:staticcheck // data uint64(sequence), string(attrMap[string(types.AttributeKeySrcPort)]), // sourcePort, string(attrMap[string(types.AttributeKeySrcChannel)]), // sourceChannel, diff --git a/legacy_ibc_testing/simapp/test_helpers.go b/legacy_ibc_testing/simapp/test_helpers.go index 249fffb903..efdc359499 100644 --- a/legacy_ibc_testing/simapp/test_helpers.go +++ b/legacy_ibc_testing/simapp/test_helpers.go @@ -8,15 +8,19 @@ import ( "testing" "time" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" + "github.com/stretchr/testify/require" + + errorsmod "cosmossdk.io/errors" + bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp/helpers" ) @@ -60,7 +64,7 @@ func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { return valAddrs } -func TestAddr(addr string, bech string) (sdk.AccAddress, error) { +func TestAddr(addr, bech string) (sdk.AccAddress, error) { res, err := sdk.AccAddressFromHexUnsafe(addr) if err != nil { return nil, err @@ -140,7 +144,7 @@ func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { panic(err) } if len(pkBytes) != ed25519.PubKeySize { - panic(errors.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) + panic(errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) } return &ed25519.PubKey{Key: pkBytes} } diff --git a/legacy_ibc_testing/testing/app.go b/legacy_ibc_testing/testing/app.go index 8a1fef452c..da861481a7 100644 --- a/legacy_ibc_testing/testing/app.go +++ b/legacy_ibc_testing/testing/app.go @@ -5,12 +5,11 @@ import ( "testing" "time" + "github.com/cosmos/ibc-go/v7/modules/core/keeper" + "github.com/stretchr/testify/require" + "cosmossdk.io/math" - "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - abci "github.com/cometbft/cometbft/abci/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -22,10 +21,12 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/stretchr/testify/require" - "github.com/cosmos/ibc-go/v7/modules/core/keeper" + abci "github.com/cometbft/cometbft/abci/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmtypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ) diff --git a/legacy_ibc_testing/testing/chain.go b/legacy_ibc_testing/testing/chain.go index 945c5b94d0..14177679b7 100644 --- a/legacy_ibc_testing/testing/chain.go +++ b/legacy_ibc_testing/testing/chain.go @@ -6,13 +6,18 @@ import ( "testing" "time" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + "github.com/cosmos/ibc-go/v7/modules/core/exported" + "github.com/cosmos/ibc-go/v7/modules/core/types" + ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "github.com/cosmos/ibc-go/v7/testing/mock" + "github.com/stretchr/testify/require" + errorsmod "cosmossdk.io/errors" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmprotoversion "github.com/cometbft/cometbft/proto/tendermint/version" - tmtypes "github.com/cometbft/cometbft/types" - tmversion "github.com/cometbft/cometbft/version" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -24,16 +29,13 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" teststaking "github.com/cosmos/cosmos-sdk/x/staking/testutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/stretchr/testify/require" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - "github.com/cosmos/ibc-go/v7/modules/core/exported" - "github.com/cosmos/ibc-go/v7/modules/core/types" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - "github.com/cosmos/ibc-go/v7/testing/mock" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cometbft/cometbft/crypto/tmhash" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmprotoversion "github.com/cometbft/cometbft/proto/tendermint/version" + tmtypes "github.com/cometbft/cometbft/types" + tmversion "github.com/cometbft/cometbft/version" ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" diff --git a/legacy_ibc_testing/testing/coordinator.go b/legacy_ibc_testing/testing/coordinator.go index 4aee8f8923..13f5ac1bec 100644 --- a/legacy_ibc_testing/testing/coordinator.go +++ b/legacy_ibc_testing/testing/coordinator.go @@ -6,8 +6,9 @@ import ( "testing" "time" - abci "github.com/cometbft/cometbft/abci/types" "github.com/stretchr/testify/require" + + abci "github.com/cometbft/cometbft/abci/types" ) /* diff --git a/legacy_ibc_testing/testing/endpoint.go b/legacy_ibc_testing/testing/endpoint.go index c3f2ac9abb..ef9213d222 100644 --- a/legacy_ibc_testing/testing/endpoint.go +++ b/legacy_ibc_testing/testing/endpoint.go @@ -3,9 +3,6 @@ package testing import ( "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -13,6 +10,9 @@ import ( host "github.com/cosmos/ibc-go/v7/modules/core/24-host" "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" ) /* diff --git a/legacy_ibc_testing/testing/events.go b/legacy_ibc_testing/testing/events.go index 763199a695..4bab444cbb 100644 --- a/legacy_ibc_testing/testing/events.go +++ b/legacy_ibc_testing/testing/events.go @@ -3,11 +3,11 @@ package testing import ( "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + + sdk "github.com/cosmos/cosmos-sdk/types" ) /* @@ -23,8 +23,8 @@ func ParseClientIDFromEvents(events sdk.Events) (string, error) { for _, ev := range events { if ev.Type == clienttypes.EventTypeCreateClient { for _, attr := range ev.Attributes { - if string(attr.Key) == clienttypes.AttributeKeyClientID { - return string(attr.Value), nil + if attr.Key == clienttypes.AttributeKeyClientID { + return attr.Value, nil } } } @@ -39,8 +39,8 @@ func ParseConnectionIDFromEvents(events sdk.Events) (string, error) { if ev.Type == connectiontypes.EventTypeConnectionOpenInit || ev.Type == connectiontypes.EventTypeConnectionOpenTry { for _, attr := range ev.Attributes { - if string(attr.Key) == connectiontypes.AttributeKeyConnectionID { - return string(attr.Value), nil + if attr.Key == connectiontypes.AttributeKeyConnectionID { + return attr.Value, nil } } } @@ -54,8 +54,8 @@ func ParseChannelIDFromEvents(events sdk.Events) (string, error) { for _, ev := range events { if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { for _, attr := range ev.Attributes { - if string(attr.Key) == channeltypes.AttributeKeyChannelID { - return string(attr.Value), nil + if attr.Key == channeltypes.AttributeKeyChannelID { + return attr.Value, nil } } } @@ -69,7 +69,7 @@ func ParseAckFromEvents(events sdk.Events) ([]byte, error) { for _, ev := range events { if ev.Type == channeltypes.EventTypeWriteAck { for _, attr := range ev.Attributes { - if string(attr.Key) == channeltypes.AttributeKeyAck { + if attr.Key == channeltypes.AttributeKeyAck { //nolint:staticcheck // data return []byte(attr.Value), nil } } diff --git a/legacy_ibc_testing/testing/utils.go b/legacy_ibc_testing/testing/utils.go index 885958f25e..047793f455 100644 --- a/legacy_ibc_testing/testing/utils.go +++ b/legacy_ibc_testing/testing/utils.go @@ -3,9 +3,10 @@ package testing import ( "testing" + "github.com/stretchr/testify/require" + abci "github.com/cometbft/cometbft/abci/types" tmtypes "github.com/cometbft/cometbft/types" - "github.com/stretchr/testify/require" ) /*