diff --git a/.golangci.yml b/.golangci.yml index 19d70d9e4c6..27fdada5b66 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,6 @@ run: tests: false -# # timeout for analysis, e.g. 30s, 5m, default is 1m -# timeout: 5m + timeout: 5m linters: disable-all: true @@ -10,88 +9,40 @@ linters: enable: - asciicheck - bidichk - # - bodyclose <- needs go 1.18 support - # - contextcheck <- needs go 1.18 support - # - cyclop - depguard - # - dogsled <- disabled because we would like to participate in the iditerod - # - dupl <- really just catches cli stub text - durationcheck - errcheck - errname -# - errorlint <- later -# - exhaustive <- too picky - # - exhaustivestruct <- disabled because we don't want to use every element of every struct - exportloopref - # - forbidigo <- forbids fmt.Print* by default - forcetypeassert - # - funlen <- some of our functions are longer than this by necessity - # - gci <- questionable utility - # - gochecknoglobals <- disabled because we want some globals - # - gochecknoinits <- disabled because we want to use init() - # - gocognit <- disabled for same reason as gocyclo - goconst - # - gocritic <- re enable later to catch capitalized local variables - # - gocyclo <- disabled because it won't work with how we cosmos - # - godot - # - godox <- detects TODO/BUG/FIXME and we may wantnthis later but isn't appropriate now - # - goerr113 <- disabled due to lack of comprehension - gofmt - # - gofumpt <- disabled https://github.com/osmosis-labs/osmosis/issues/1309 - - goheader - goimports - # - gomoddirectives <- disables replaces + # - gofumpt + - goheader - gomodguard - goprintffuncname -# - gosec <- triggers too much for this round and should be re-enabled later - - gosimple # specializes in simplifying code, subset of staticcheck binary. + - gosimple - govet - # - ifshort <- questionable value, unclear if globally helping readability. - importas - ineffassign - # - ireturn <- disabled because we want to return interfaces - # - lll <- disabled as it is a bit much. Maybe we have a desired limit? - makezero - misspell - nakedret -# - nestif <- ? - # - nilerr <- needs go 1.18 support - nilnil - # - nlreturn <- disabled as it doesn't auto-fix something simple and doesn't add anything useful - # - noctx <- needs go 1.18 support - # - nolintlint <- disabled because we use nolint in some places - paralleltest - # - prealloc <- disabled because it makes simple code complicated -# - predeclared <- later - promlinter -# - revive <- temporarily disabled while jacob figures out how to make poolId not trigger it. - # - rowserrcheck <- needs go 1.18 support - # - sqlclosecheck <- needs go 1.18 support - - staticcheck # set of rules from staticcheck, subset of staticcheck binary. - - stylecheck # replacement of golint, subset of staticcheck binary. - # - tagliatelle <- disabled for defying cosmos idiom + - staticcheck + - stylecheck - tenv - testpackage -# - thelper <- later - # - tparallel <- needs go 1.18 support - typecheck - unconvert -# - unparam <- looks for unused parameters (enable later) - - unused # looks for unused variables, subset of staticcheck binary. - # - varnamelen <- disabled because defies idiom - # - wastedassign + - unused - whitespace -# - wrapcheck -# - wsl issues: exclude-rules: - - path: bench_test\.go - linters: - - errcheck - - path: client/docs - linters: - - all - path: x/gamm/pool-models/stableswap linters: # Stableswap is in development. @@ -100,16 +51,16 @@ issues: - unused - deadcode - linters: - - staticcheck + - staticcheck text: "SA1024: cutset contains duplicate characters" # proved to not provide much value, only false positives. - linters: - - staticcheck + - staticcheck text: "SA9004: only the first constant in this group has an explicit type" # explicitly recommended in go syntax - linters: - - stylecheck + - stylecheck text: "ST1003:" # requires identifiers with "id" to be "ID". - linters: - - stylecheck + - stylecheck text: "ST1005:" # punctuation in error messages max-issues-per-linter: 10000 max-same-issues: 10000 diff --git a/app/app.go b/app/app.go index f2121ab2cb0..aee676eb41c 100644 --- a/app/app.go +++ b/app/app.go @@ -179,10 +179,8 @@ func NewOsmosisApp( wasmDir := filepath.Join(homePath, "wasm") wasmConfig, err := wasm.ReadWasmConfig(appOpts) - // Uncomment this for debugging contracts. In the future this could be made into a param passed by the tests - //wasmConfig.ContractDebugMode = true - + // wasmConfig.ContractDebugMode = true if err != nil { panic(fmt.Sprintf("error while reading wasm config: %s", err)) } diff --git a/app/apptesting/gamm.go b/app/apptesting/gamm.go index fca72869975..0bbc3b23bb4 100644 --- a/app/apptesting/gamm.go +++ b/app/apptesting/gamm.go @@ -158,7 +158,7 @@ func (s *KeeperTestHelper) PrepareBalancerPoolWithPoolAsset(assets []balancer.Po // Modify spotprice of a pool to target spotprice func (s *KeeperTestHelper) ModifySpotPrice(poolID uint64, targetSpotPrice sdk.Dec, baseDenom string) { var quoteDenom string - var int64Max = int64(^uint64(0) >> 1) + int64Max := int64(^uint64(0) >> 1) s.Require().Positive(targetSpotPrice) s.Require().Greater(gammtypes.MaxSpotPrice, targetSpotPrice) diff --git a/app/encoding.go b/app/encoding.go index ed87c13e296..e5775d95444 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -6,9 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/std" ) -var ( - encodingConfig params.EncodingConfig = MakeEncodingConfig() -) +var encodingConfig params.EncodingConfig = MakeEncodingConfig() func GetEncodingConfig() params.EncodingConfig { return encodingConfig diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index bf77b332d95..2d2d0ad0ede 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -440,8 +440,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( func (appKeepers *AppKeepers) WireICS20PreWasmKeeper( appCodec codec.Codec, bApp *baseapp.BaseApp, - hooksKeeper *ibchookskeeper.Keeper, -) { + hooksKeeper *ibchookskeeper.Keeper) { // Setup the ICS4Wrapper used by the hooks middleware wasmHooks := ibchooks.NewWasmHooks(hooksKeeper, nil) // The contract keeper needs to be set later appKeepers.Ics20WasmHooks = &wasmHooks diff --git a/cmd/osmosisd/cmd/balances_from_state_export.go b/cmd/osmosisd/cmd/balances_from_state_export.go index f5f0e36996e..f9410181c11 100644 --- a/cmd/osmosisd/cmd/balances_from_state_export.go +++ b/cmd/osmosisd/cmd/balances_from_state_export.go @@ -24,8 +24,10 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) -const FlagSelectPoolIds = "breakdown-by-pool-ids" -const FlagMinimumStakeAmount = "minimum-stake-amount" +const ( + FlagSelectPoolIds = "breakdown-by-pool-ids" + FlagMinimumStakeAmount = "minimum-stake-amount" +) type DeriveSnapshot struct { NumberAccounts uint64 `json:"num_accounts"` diff --git a/cmd/osmosisd/cmd/forceprune.go b/cmd/osmosisd/cmd/forceprune.go index eb032e915a3..f585f2bbb26 100644 --- a/cmd/osmosisd/cmd/forceprune.go +++ b/cmd/osmosisd/cmd/forceprune.go @@ -107,7 +107,6 @@ func pruneBlockStoreAndGetHeights(dbPath string, fullHeight int64) ( return 0, 0, err } - // nolint: staticcheck defer db_bs.Close() bs := tmstore.NewBlockStore(db_bs) diff --git a/cmd/osmosisd/cmd/genesis.go b/cmd/osmosisd/cmd/genesis.go index 3ba3d0ad640..f31ffbd76b1 100644 --- a/cmd/osmosisd/cmd/genesis.go +++ b/cmd/osmosisd/cmd/genesis.go @@ -35,7 +35,7 @@ import ( // PrepareGenesisCmd returns prepare-genesis cobra Command. // -//nolint:ineffassign + func PrepareGenesisCmd(defaultNodeHome string, mbm module.BasicManager) *cobra.Command { cmd := &cobra.Command{ Use: "prepare-genesis", diff --git a/osmoutils/module_account.go b/osmoutils/module_account.go index 20c57704cb5..c583502afa6 100644 --- a/osmoutils/module_account.go +++ b/osmoutils/module_account.go @@ -41,7 +41,7 @@ func CanCreateModuleAccountAtAddr(ctx sdk.Context, ak AccountKeeper, addr sdk.Ac return fmt.Errorf("cannot create module account %s, "+ "due to an account at that address already existing & having sent txs", addr) } - var overrideAccountTypes = map[reflect.Type]struct{}{ + overrideAccountTypes := map[reflect.Type]struct{}{ reflect.TypeOf(&authtypes.BaseAccount{}): {}, reflect.TypeOf(&vestingtypes.DelayedVestingAccount{}): {}, reflect.TypeOf(&vestingtypes.ContinuousVestingAccount{}): {}, diff --git a/osmoutils/osmocli/query_cmd_wrap.go b/osmoutils/osmocli/query_cmd_wrap.go index 790fd2ad5c1..af727553408 100644 --- a/osmoutils/osmocli/query_cmd_wrap.go +++ b/osmoutils/osmocli/query_cmd_wrap.go @@ -112,7 +112,8 @@ func BuildQueryCli[reqP proto.Message, querier any](desc *QueryDescriptor, newQu // with just the "Query" and "Request" args chopped off. // It expects all proto fields to appear as arguments, in order. func SimpleQueryCmd[reqP proto.Message, querier any](use string, short string, long string, - moduleName string, newQueryClientFn func(grpc1.ClientConn) querier) *cobra.Command { + moduleName string, newQueryClientFn func(grpc1.ClientConn) querier, +) *cobra.Command { desc := QueryDescriptor{ Use: use, Short: short, @@ -122,7 +123,8 @@ func SimpleQueryCmd[reqP proto.Message, querier any](use string, short string, l } func GetParams[reqP proto.Message, querier any](moduleName string, - newQueryClientFn func(grpc1.ClientConn) querier) *cobra.Command { + newQueryClientFn func(grpc1.ClientConn) querier, +) *cobra.Command { return BuildQueryCli[reqP](&QueryDescriptor{ Use: "params [flags]", Short: fmt.Sprintf("Get the params for the x/%s module", moduleName), @@ -156,7 +158,8 @@ func callQueryClientFn(ctx context.Context, fnName string, req proto.Message, q } func queryLogic[querier any](desc *QueryDescriptor, - newQueryClientFn func(grpc1.ClientConn) querier) func(cmd *cobra.Command, args []string) error { + newQueryClientFn func(grpc1.ClientConn) querier, +) func(cmd *cobra.Command, args []string) error { return func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { diff --git a/simulation/simtypes/txbuilder.go b/simulation/simtypes/txbuilder.go index 8ff083b1953..36f33c5c54d 100644 --- a/simulation/simtypes/txbuilder.go +++ b/simulation/simtypes/txbuilder.go @@ -112,7 +112,7 @@ func genTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch if err != nil { panic(err) } - //nolint:forcetypeassert + sigs[i] = sig err = txBuilder.SetSignatures(sigs...) if err != nil { diff --git a/tests/e2e/initialization/config.go b/tests/e2e/initialization/config.go index 290928fe68f..a6e865474a1 100644 --- a/tests/e2e/initialization/config.go +++ b/tests/e2e/initialization/config.go @@ -159,7 +159,6 @@ func addAccount(path, moniker, amountStr string, accAddr sdk.AccAddress, forkHei return genutil.ExportGenesisFile(genDoc, genFile) } -//nolint:typecheck func updateModuleGenesis[V proto.Message](appGenState map[string]json.RawMessage, moduleName string, protoVal V, updateGenesis func(V)) error { if err := util.Cdc.UnmarshalJSON(appGenState[moduleName], protoVal); err != nil { return err diff --git a/x/gamm/keeper/grpc_query.go b/x/gamm/keeper/grpc_query.go index 31473c5f0f6..a4091ceb731 100644 --- a/x/gamm/keeper/grpc_query.go +++ b/x/gamm/keeper/grpc_query.go @@ -168,7 +168,7 @@ func (q Querier) PoolsWithFilter(ctx context.Context, req *types.QueryPoolsWithF store := sdkCtx.KVStore(q.Keeper.storeKey) poolStore := prefix.NewStore(store, types.KeyPrefixPools) - var response = []*codectypes.Any{} + response := []*codectypes.Any{} pageRes, err := query.FilteredPaginate(poolStore, req.Pagination, func(_, value []byte, accumulate bool) (bool, error) { pool, err := q.Keeper.UnmarshalPool(value) if err != nil { @@ -214,7 +214,6 @@ func (q Querier) PoolsWithFilter(ctx context.Context, req *types.QueryPoolsWithF return true, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/ibc-rate-limit/module.go b/x/ibc-rate-limit/module.go index 1776ff8cc6c..74588000633 100644 --- a/x/ibc-rate-limit/module.go +++ b/x/ibc-rate-limit/module.go @@ -18,9 +18,7 @@ import ( "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" ) -var ( - _ module.AppModuleBasic = AppModuleBasic{} -) +var _ module.AppModuleBasic = AppModuleBasic{} type AppModuleBasic struct{} diff --git a/x/lockup/client/rest/rest.go b/x/lockup/client/rest/rest.go index 60a4faee74d..06ad9521665 100644 --- a/x/lockup/client/rest/rest.go +++ b/x/lockup/client/rest/rest.go @@ -10,7 +10,7 @@ import ( ) // REST Variable names -// nolint + const ( LockID = "lock-id" RestOwnerAddress = "owner" diff --git a/x/protorev/keeper/epoch_hook.go b/x/protorev/keeper/epoch_hook.go index 5c431c84eba..173a10396bc 100644 --- a/x/protorev/keeper/epoch_hook.go +++ b/x/protorev/keeper/epoch_hook.go @@ -17,9 +17,7 @@ type LiquidityPoolStruct struct { PoolId uint64 } -var ( - _ epochstypes.EpochHooks = EpochHooks{} -) +var _ epochstypes.EpochHooks = EpochHooks{} func (k Keeper) EpochHooks() epochstypes.EpochHooks { return EpochHooks{k} diff --git a/x/protorev/keeper/keeper.go b/x/protorev/keeper/keeper.go index 65585f1bf6f..f22c33c5a52 100644 --- a/x/protorev/keeper/keeper.go +++ b/x/protorev/keeper/keeper.go @@ -34,7 +34,6 @@ func NewKeeper( bankKeeper types.BankKeeper, gammKeeper types.GAMMKeeper, epochKeeper types.EpochKeeper, - ) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() {