Skip to content

Commit

Permalink
Enable gofumpt (#1179)
Browse files Browse the repository at this point in the history
* Update Makefile

Draft PR aimed at enabling fumpt linter and using golangci-lint run --fix to make developer environments match ci

* update to go1.18

* Update Makefile

* fumpt & update makefile to exclude dirs

* Update Makefile

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update Makefile

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update Makefile

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
  • Loading branch information
faddat and alexanderbez authored Apr 14, 2022
1 parent efae5d9 commit 3c97121
Show file tree
Hide file tree
Showing 221 changed files with 704 additions and 495 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ linters:
# - godox <- detects TODO/BUG/FIXME and we may wantnthis later but isn't appropriate now
# - goerr113 <- disabled due to lack of comprehension
- gofmt
# - gofumpt
- gofumpt
- goheader
- goimports
# - gomoddirectives <- disables replaces
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,10 @@ lint:
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout=10m

format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/cosmos/cosmos-sdk
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name "*.pb.gw.go" -not -name "*.pb.go" | xargs gofumpt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name "*.pb.gw.go" -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 -name "*.pb.gw.go" -not -name "*.pb.go" | xargs goimports -w -local github.com/cosmos/cosmos-sdk
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --fix

###############################################################################
### Localnet ###
Expand Down
5 changes: 3 additions & 2 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package app
import (
wasm "github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
channelkeeper "github.com/cosmos/ibc-go/v2/modules/core/04-channel/keeper"
ibcante "github.com/cosmos/ibc-go/v2/modules/core/ante"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
channelkeeper "github.com/cosmos/ibc-go/v2/modules/core/04-channel/keeper"
ibcante "github.com/cosmos/ibc-go/v2/modules/core/ante"

txfeeskeeper "github.com/osmosis-labs/osmosis/v7/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types"
Expand Down
21 changes: 11 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ import (
"strings"

"github.com/CosmWasm/wasmd/x/wasm"
transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer"
"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"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
Expand All @@ -30,16 +41,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/crisis"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer"
"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"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

appparams "github.com/osmosis-labs/osmosis/v7/app/params"
v4 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v4"
Expand Down
5 changes: 3 additions & 2 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"fmt"
"time"

"github.com/osmosis-labs/osmosis/v7/app/params"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/osmosis-labs/osmosis/v7/app/params"
dbm "github.com/tendermint/tm-db"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand Down
3 changes: 2 additions & 1 deletion app/encoding.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package app

import (
"github.com/cosmos/cosmos-sdk/std"
"github.com/osmosis-labs/osmosis/v7/app/params"

"github.com/cosmos/cosmos-sdk/std"
)

// MakeEncodingConfig creates an EncodingConfig for testing.
Expand Down
17 changes: 9 additions & 8 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ package app
import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"
transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v2/modules/core"
ibcclientclient "github.com/cosmos/ibc-go/v2/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host"
"github.com/osmosis-labs/bech32-ibc/x/bech32ibc"
bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types"
"github.com/osmosis-labs/bech32-ibc/x/bech32ics20"

"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 @@ -36,14 +45,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"
transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v2/modules/core"
ibcclientclient "github.com/cosmos/ibc-go/v2/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host"
"github.com/osmosis-labs/bech32-ibc/x/bech32ibc"
bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types"
"github.com/osmosis-labs/bech32-ibc/x/bech32ics20"

appparams "github.com/osmosis-labs/osmosis/v7/app/params"
_ "github.com/osmosis-labs/osmosis/v7/client/docs/statik"
Expand Down
3 changes: 2 additions & 1 deletion app/params/config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package params

import (
"github.com/osmosis-labs/osmosis/v7/v043_temp/address"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/osmosis-labs/osmosis/v7/v043_temp/address"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"encoding/json"
"os"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// Setup initializes a new OsmosisApp.
Expand Down
13 changes: 6 additions & 7 deletions app/upgrades/v4/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"testing"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/osmosis-labs/osmosis/v7/app"
v4 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v4"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

sdk "github.com/cosmos/cosmos-sdk/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

type UpgradeTestSuite struct {
Expand Down Expand Up @@ -47,7 +48,7 @@ func (suite *UpgradeTestSuite) TestUpgradePayments() {
func() {
// mint coins to distribution module / feepool.communitypool

var bal = int64(1000000000000)
bal := int64(1000000000000)
coin := sdk.NewInt64Coin("uosmo", bal)
coins := sdk.NewCoins(coin)
err := suite.app.BankKeeper.MintCoins(suite.ctx, "mint", coins)
Expand All @@ -57,7 +58,6 @@ func (suite *UpgradeTestSuite) TestUpgradePayments() {
feePool := suite.app.DistrKeeper.GetFeePool(suite.ctx)
feePool.CommunityPool = feePool.CommunityPool.Add(sdk.NewDecCoinFromCoin(coin))
suite.app.DistrKeeper.SetFeePool(suite.ctx, feePool)

},
func() {
// run upgrade
Expand All @@ -75,7 +75,7 @@ func (suite *UpgradeTestSuite) TestUpgradePayments() {
})
},
func() {
var total = int64(0)
total := int64(0)

// check that each account got the payment expected
payments := v4.GetProp12Payments()
Expand All @@ -92,7 +92,7 @@ func (suite *UpgradeTestSuite) TestUpgradePayments() {
total += amount
}

//check that the total paid out was as expected
// check that the total paid out was as expected
suite.Require().Equal(total, int64(367926557424))

expectedBal := 1000000000000 - total
Expand Down Expand Up @@ -122,7 +122,6 @@ func (suite *UpgradeTestSuite) TestUpgradePayments() {
tc.pre_update()
tc.update()
tc.post_update()

})
}
}
7 changes: 4 additions & 3 deletions app/upgrades/v5/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package v5

import (
connectionkeeper "github.com/cosmos/ibc-go/v2/modules/core/03-connection/keeper"
ibcconnectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types"
bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/authz"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
connectionkeeper "github.com/cosmos/ibc-go/v2/modules/core/03-connection/keeper"
ibcconnectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types"
bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types"

gammkeeper "github.com/osmosis-labs/osmosis/v7/x/gamm/keeper"
"github.com/osmosis-labs/osmosis/v7/x/txfees"
Expand Down
1 change: 1 addition & 0 deletions app/upgrades/v7/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v7
import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
Expand Down
3 changes: 2 additions & 1 deletion app/wasm/bindings/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package wasmbindings

import (
"encoding/json"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion app/wasm/test/custom_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func TestSwapMsg(t *testing.T) {
func prepareSwapState(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp) BaseState {
actor := RandomAccountAddress()

var swapperFunds = sdk.NewCoins(
swapperFunds := sdk.NewCoins(
sdk.NewInt64Coin("uatom", 333000000),
sdk.NewInt64Coin("uosmo", 555000000+3*poolFee),
sdk.NewInt64Coin("uregen", 777000000),
Expand Down
5 changes: 3 additions & 2 deletions app/wasm/test/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v7/app"
)

Expand Down
7 changes: 3 additions & 4 deletions app/wasm/test/messages_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package wasm

import (
"math"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/v7/app/wasm"
wasmbindings "github.com/osmosis-labs/osmosis/v7/app/wasm/bindings"
"github.com/stretchr/testify/assert"
"math"
"testing"

"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -334,7 +335,6 @@ func TestSwap(t *testing.T) {
assert.InEpsilonf(t, (*spec.expCost.Out).ToDec().MustFloat64(), (*gotAmount.Out).ToDec().MustFloat64(), epsilon, "exp %s but got %s", spec.expCost.Out.String(), gotAmount.Out.String())
})
}

}

func TestSwapMultiHop(t *testing.T) {
Expand Down Expand Up @@ -517,5 +517,4 @@ func TestSwapMultiHop(t *testing.T) {
assert.InEpsilonf(t, (*spec.expCost.Out).ToDec().MustFloat64(), (*gotAmount.Out).ToDec().MustFloat64(), epsilon, "exp %s but got %s", spec.expCost.Out.String(), gotAmount.Out.String())
})
}

}
1 change: 0 additions & 1 deletion app/wasm/test/queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,5 +486,4 @@ func TestEstimateSwap(t *testing.T) {
assert.InEpsilonf(t, (*spec.expCost.Out).ToDec().MustFloat64(), (*gotCost.Out).ToDec().MustFloat64(), epsilon, "exp %s but got %s", spec.expCost.Out.String(), gotCost.Out.String())
})
}

}
2 changes: 1 addition & 1 deletion app/wasm/test/store_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/types"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v7/app"
Expand Down Expand Up @@ -50,7 +51,6 @@ func storeCodeViaProposal(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp
handler := govKeeper.Router().GetRoute(storedProposal.ProposalRoute())
err = handler(ctx, storedProposal.GetContent())
require.NoError(t, err)

}

func TestStoreCodeProposal(t *testing.T) {
Expand Down
13 changes: 7 additions & 6 deletions cmd/osmosisd/cmd/balances_from_state_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import (
"io/ioutil"
"os"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
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"
appparams "github.com/osmosis-labs/osmosis/v7/app/params"
"github.com/osmosis-labs/osmosis/v7/osmoutils"
claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types"
Expand All @@ -20,6 +14,13 @@ import (
"github.com/spf13/cobra"
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
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"
)

const FlagSelectPoolIds = "breakdown-by-pool-ids"
Expand Down
3 changes: 2 additions & 1 deletion cmd/osmosisd/cmd/genwasm.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package cmd

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"

wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli"
)

Expand Down
Loading

0 comments on commit 3c97121

Please sign in to comment.