Skip to content

Commit

Permalink
refactor: use gci linter to sort imports (cosmos#2608)
Browse files Browse the repository at this point in the history
* use the gci linter to sort imports

* enable custom ordering in gci
  • Loading branch information
faddat committed Jul 18, 2023
1 parent a759409 commit 69d1dd0
Show file tree
Hide file tree
Showing 49 changed files with 230 additions and 171 deletions.
15 changes: 14 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ linters:
- dogsled
- errcheck
- exportloopref
- gci
- goconst
- gocritic
- gofumpt
Expand Down Expand Up @@ -57,6 +58,18 @@ issues:
max-same-issues: 10000

linters-settings:
gci:
custom-order: true
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- blank # blank imports
- dot # dot imports
- prefix(github.com/cometbft/cometbft) # comet
- prefix(github.com/cosmos) # cosmos org
- prefix(cosmossdk.io) # new modules
- prefix(github.com/cosmos/cosmos-sdk) # cosmos sdk
- prefix(github.com/cosmos/gaia) # Gaia
dogsled:
max-blank-identifiers: 3
maligned:
Expand Down Expand Up @@ -94,4 +107,4 @@ linters-settings:
- name: empty-block
- name: superfluous-else
- name: unreachable-code
- name: redefines-builtin-id
- name: redefines-builtin-id
8 changes: 5 additions & 3 deletions ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package ante

import (
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"

errorsmod "cosmossdk.io/errors"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
gaiaerrors "github.com/cosmos/gaia/v11/types/errors"
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"

gaiaerrors "github.com/cosmos/gaia/v11/types/errors"
gaiafeeante "github.com/cosmos/gaia/v11/x/globalfee/ante"
)

Expand Down
5 changes: 3 additions & 2 deletions ante/gov_ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package ante

import (
errorsmod "cosmossdk.io/errors"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
gaiaerrors "github.com/cosmos/gaia/v11/types/errors"

"github.com/cosmos/cosmos-sdk/x/authz"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

gaiaerrors "github.com/cosmos/gaia/v11/types/errors"
)

// initial deposit must be greater than or equal to 10% of the minimum deposit
Expand Down
11 changes: 5 additions & 6 deletions ante/gov_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import (
"fmt"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/stretchr/testify/suite"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

"github.com/cosmos/gaia/v11/ante"
gaiahelpers "github.com/cosmos/gaia/v11/app/helpers"

gaiaapp "github.com/cosmos/gaia/v11/app"
gaiahelpers "github.com/cosmos/gaia/v11/app/helpers"
)

var (
Expand Down
28 changes: 15 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ import (
"os"
"path/filepath"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"

ibctesting "github.com/cosmos/interchain-security/v2/legacy_ibc_testing/testing"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
Expand All @@ -29,26 +44,13 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibctesting "github.com/cosmos/interchain-security/v2/legacy_ibc_testing/testing"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

gaiaante "github.com/cosmos/gaia/v11/ante"
"github.com/cosmos/gaia/v11/app/keepers"
gaiaappparams "github.com/cosmos/gaia/v11/app/params"
"github.com/cosmos/gaia/v11/app/upgrades"
v11 "github.com/cosmos/gaia/v11/app/upgrades/v11"
"github.com/cosmos/gaia/v11/x/globalfee"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion app/app_helpers.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package gaia

import (
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
ibcstakinginterface "github.com/cosmos/interchain-security/v2/legacy_ibc_testing/core"
icstest "github.com/cosmos/interchain-security/v2/testutil/integration"
ibcproviderkeeper "github.com/cosmos/interchain-security/v2/x/ccv/provider/keeper"

capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
)

// ProviderApp interface implementations for icstest tests
Expand Down
5 changes: 3 additions & 2 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package gaia_test
import (
"testing"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
db "github.com/tendermint/tm-db"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

gaia "github.com/cosmos/gaia/v11/app"
gaiahelpers "github.com/cosmos/gaia/v11/app/helpers"
)
Expand Down
3 changes: 2 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package gaia
import (
"encoding/json"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)

// ExportAppStateAndValidators exports the state of the application for a genesis
Expand Down
12 changes: 6 additions & 6 deletions app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
Expand All @@ -15,12 +21,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

gaiaapp "github.com/cosmos/gaia/v11/app"
)
Expand Down
52 changes: 26 additions & 26 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
package keepers

import (
liquiditykeeper "github.com/gravity-devs/liquidity/x/liquidity/keeper"
liquiditytypes "github.com/gravity-devs/liquidity/x/liquidity/types"
"github.com/strangelove-ventures/packet-forward-middleware/v4/router"
routerkeeper "github.com/strangelove-ventures/packet-forward-middleware/v4/router/keeper"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"
tmos "github.com/tendermint/tendermint/libs/os"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"

ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
"github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
ibcprovider "github.com/cosmos/interchain-security/v2/x/ccv/provider"
ibcproviderkeeper "github.com/cosmos/interchain-security/v2/x/ccv/provider/keeper"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand All @@ -22,12 +48,8 @@ import (
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
tmos "github.com/tendermint/tendermint/libs/os"

govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
Expand All @@ -41,30 +63,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
"github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
ibcprovider "github.com/cosmos/interchain-security/v2/x/ccv/provider"
ibcproviderkeeper "github.com/cosmos/interchain-security/v2/x/ccv/provider/keeper"
liquiditykeeper "github.com/gravity-devs/liquidity/x/liquidity/keeper"
liquiditytypes "github.com/gravity-devs/liquidity/x/liquidity/types"
"github.com/strangelove-ventures/packet-forward-middleware/v4/router"
routerkeeper "github.com/strangelove-ventures/packet-forward-middleware/v4/router/keeper"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"

"github.com/cosmos/gaia/v11/x/globalfee"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)

type AppKeepers struct {
Expand Down
14 changes: 8 additions & 6 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package keepers

import (
liquiditytypes "github.com/gravity-devs/liquidity/x/liquidity/types"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"

icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -16,12 +24,6 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
liquiditytypes "github.com/gravity-devs/liquidity/x/liquidity/types"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"
)

func (appKeepers *AppKeepers) GenerateKeys() {
Expand Down
30 changes: 16 additions & 14 deletions app/modules.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
package gaia

import (
"github.com/gravity-devs/liquidity/x/liquidity"
liquiditytypes "github.com/gravity-devs/liquidity/x/liquidity/types"
"github.com/strangelove-ventures/packet-forward-middleware/v4/router"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"

ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v4/modules/core"
ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibcprovider "github.com/cosmos/interchain-security/v2/x/ccv/provider"
ibcproviderclient "github.com/cosmos/interchain-security/v2/x/ccv/provider/client"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"

"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
Expand Down Expand Up @@ -38,20 +54,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v4/modules/core"
ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibcprovider "github.com/cosmos/interchain-security/v2/x/ccv/provider"
ibcproviderclient "github.com/cosmos/interchain-security/v2/x/ccv/provider/client"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
"github.com/gravity-devs/liquidity/x/liquidity"
liquiditytypes "github.com/gravity-devs/liquidity/x/liquidity/types"
"github.com/strangelove-ventures/packet-forward-middleware/v4/router"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"

gaiaappparams "github.com/cosmos/gaia/v11/app/params"
"github.com/cosmos/gaia/v11/x/globalfee"
Expand Down
4 changes: 2 additions & 2 deletions app/sim/sim_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"

gaia "github.com/cosmos/gaia/v11/app"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
Expand All @@ -22,6 +20,8 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

gaia "github.com/cosmos/gaia/v11/app"
)

// AppStateFn returns the initial application state using a genesis or the simulation parameters.
Expand Down
Loading

0 comments on commit 69d1dd0

Please sign in to comment.