Skip to content

Commit

Permalink
updates for goreport (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
yys authored and dokwon committed Oct 18, 2019
1 parent 06daa32 commit 2f75b51
Show file tree
Hide file tree
Showing 51 changed files with 388 additions and 325 deletions.
18 changes: 9 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ import (
const appName = "TerraApp"

var (
// default home directories for terracli
// DefaultCLIHome defines default home directories for terracli
DefaultCLIHome = os.ExpandEnv("$HOME/.terracli")

// default home directories for terrad
// DefaultNodeHome defines default home directories for terrad
DefaultNodeHome = os.ExpandEnv("$HOME/.terrad")

// The ModuleBasicManager is in charge of setting up basic,
// ModuleBasics = The ModuleBasicManager is in charge of setting up basic,
// non-dependant module elements, such as codec registration
// and genesis verification.
ModuleBasics = module.NewBasicManager(
Expand Down Expand Up @@ -78,7 +78,7 @@ var (
}
)

// custom tx codec
// MakeCodec builds application codec
func MakeCodec() *codec.Codec {
var cdc = codec.New()
ModuleBasics.RegisterCodec(cdc)
Expand All @@ -88,7 +88,7 @@ func MakeCodec() *codec.Codec {
return cdc
}

// Extended ABCI application
// TerraApp is Extended ABCI application
type TerraApp struct {
*bam.BaseApp
cdc *codec.Codec
Expand Down Expand Up @@ -244,24 +244,24 @@ func NewTerraApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
return app
}

// application updates every begin block
// BeginBlocker defines application updates at every begin block
func (app *TerraApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
return app.mm.BeginBlock(ctx, req)
}

// application updates every end block
// EndBlocker defines application updates at every end block
func (app *TerraApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
return app.mm.EndBlock(ctx, req)
}

// application update at chain initialization
// InitChainer defines application update at chain initialization
func (app *TerraApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
var genesisState simapp.GenesisState
app.cdc.MustUnmarshalJSON(req.AppStateBytes, &genesisState)
return app.mm.InitGenesis(ctx, genesisState)
}

// load a particular height
// LoadHeight loads a particular height
func (app *TerraApp) LoadHeight(height int64) error {
return app.LoadVersion(height, app.keys[bam.MainStoreKey])
}
Expand Down
1 change: 0 additions & 1 deletion app/utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//nolint
package app

import (
Expand Down
4 changes: 3 additions & 1 deletion cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ func TestTerraCLIQueryRewards(t *testing.T) {
genDoc, err := tmtypes.GenesisDocFromFile(genFile)
require.NoError(t, err)
genDoc.AppState, err = cdc.MarshalJSON(genesisState)
require.NoError(t, err)
require.NoError(t, genDoc.SaveAs(genFile))

// start terrad server
Expand Down Expand Up @@ -772,6 +773,7 @@ func TestTerraCLISubmitCommunityPoolSpendProposal(t *testing.T) {
genDoc, err := tmtypes.GenesisDocFromFile(genFile)
require.NoError(t, err)
genDoc.AppState, err = cdc.MarshalJSON(genesisState)
require.NoError(t, err)
require.NoError(t, genDoc.SaveAs(genFile))

proc := f.TDStart()
Expand Down Expand Up @@ -1016,7 +1018,7 @@ func TestTerraCLISendGenerateSignAndBroadcast(t *testing.T) {
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))

// Test broadcast
success, stdOut, _ = f.TxBroadcast(signedTxFile.Name())
success, _, _ = f.TxBroadcast(signedTxFile.Name())
require.True(t, success)
tests.WaitForNextNBlocksTM(1, f.Port)

Expand Down
6 changes: 3 additions & 3 deletions cli_test/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (f Fixtures) GenesisFile() string {
return filepath.Join(f.TerradHome, "config", "genesis.json")
}

// GenesisFile returns the application's genesis state
// GenesisState returns the application's genesis state
func (f Fixtures) GenesisState() simapp.GenesisState {
cdc := codec.New()
genDoc, err := tmtypes.GenesisDocFromFile(f.GenesisFile())
Expand Down Expand Up @@ -352,7 +352,7 @@ func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string,
return executeWriteRetStdStreams(f.T, cmd)
}

// TxEstimateFee
// TxEstimateFee is terracli tx estimate-fee
func (f *Fixtures) TxEstimateFee(fileName string, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx estimate-fee %v %v", f.TerracliBinary, f.Flags(), fileName)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags))
Expand Down Expand Up @@ -757,7 +757,7 @@ func queryTags(tags []string) (out string) {
return strings.TrimSuffix(out, "&")
}

// Write the given string to a new temporary file
// WriteToNewTempFile writes the given string to a new temporary file
func WriteToNewTempFile(t *testing.T, s string) *os.File {
fp, err := ioutil.TempFile(os.TempDir(), "cosmos_cli_test_")
require.Nil(t, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/terrad/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Example:

const nodeDirPerm = 0755

// Initialize the testnet
// InitTestnet initializes the testnet
func InitTestnet(cmd *cobra.Command, config *tmconfig.Config, cdc *codec.Codec,
mbm module.BasicManager, genAccIterator genutiltypes.GenesisAccountsIterator,
outputDir, chainID, minGasPrices, nodeDirPrefix, nodeDaemonHome,
Expand Down
2 changes: 1 addition & 1 deletion x/auth/client/rest/multisigntx.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type MultiSignReq struct {
Pubkey MultiSignPubKey `json:"pubkey"` // (optional) In case the multisig account never reveals its pubkey, it is required.
}

// MultiSignPubkey defines the properties of a multisig account's public key
// MultiSignPubKey defines the properties of a multisig account's public key
type MultiSignPubKey struct {
Threshold int `json:"threshold"`
PubKeys []string `json:"pubkeys"`
Expand Down
8 changes: 4 additions & 4 deletions x/auth/client/utils/feeutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import (
)

type (
// EstimateReq defines a tx encoding request.
// EstimateFeeReq defines a tx encoding request.
EstimateFeeReq struct {
Tx auth.StdTx `json:"tx"`
GasAdjustment string `json:"gas_adjustment"`
GasPrices sdk.DecCoins `json:"gas_prices"`
}

// EstimateResp defines a tx encoding response.
// EstimateFeeResp defines a tx encoding response.
EstimateFeeResp struct {
Fees sdk.Coins `json:"fees"`
Gas uint64 `json:"gas"`
Expand Down Expand Up @@ -104,7 +104,7 @@ type ComputeReqParams struct {
Msgs []sdk.Msg
}

// ComputeFee returns fee amount with given transfer, gas, gas prices, and fees amount.
// ComputeFees returns fee amount with given transfer, gas, gas prices, and fees amount.
func ComputeFees(
cliCtx context.CLIContext,
req ComputeReqParams) (fees sdk.Coins, gas uint64, err error) {
Expand Down Expand Up @@ -265,7 +265,7 @@ func queryTaxCap(cliCtx context.CLIContext, denom string) (sdk.Int, error) {
return taxCap, nil
}

// parse string to float64
// ParseFloat64 parses string to float64
func ParseFloat64(s string, defaultIfEmpty float64) (n float64, err error) {
if len(s) == 0 {
return defaultIfEmpty, nil
Expand Down
2 changes: 1 addition & 1 deletion x/auth/internal/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(&BaseLazyGradedVestingAccount{}, "core/LazyGradedVestingAccount", nil)
}

// module wide codec
// ModuleCdc defines module wide codec
var ModuleCdc *codec.Codec

func init() {
Expand Down
5 changes: 3 additions & 2 deletions x/auth/internal/types/lazy_vesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
//-----------------------------------------------------------------------------
// Schedule

// Schedule no-lint
// LazySchedule defines a vesting schedule which is used for LazyGradedVestingAccount
type LazySchedule struct {
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
Ratio sdk.Dec `json:"ratio"`
}

// NewLazySchedule returns new LazySchedule instance
func NewLazySchedule(startTime, endTime int64, ratio sdk.Dec) LazySchedule {
return LazySchedule{
StartTime: startTime,
Expand Down Expand Up @@ -152,7 +153,7 @@ type BaseLazyGradedVestingAccount struct {
VestingSchedules []VestingSchedule `json:"vesting_schedules"`
}

// NewBaseLazyGradedVestingAccount creates a new BaseLazyGradedVestingAccount object from BaseVestingAccount
// NewBaseLazyGradedVestingAccountRaw creates a new BaseLazyGradedVestingAccount object from BaseVestingAccount
func NewBaseLazyGradedVestingAccountRaw(baseVestingAcc *auth.BaseVestingAccount, lazyVestingSchedules []VestingSchedule) *BaseLazyGradedVestingAccount {
return &BaseLazyGradedVestingAccount{baseVestingAcc, lazyVestingSchedules}
}
Expand Down
41 changes: 22 additions & 19 deletions x/auth/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,49 @@ var (
_ module.AppModuleBasic = AppModuleBasic{}
)

// app module basics object
// AppModuleBasic defines the basic application module used by the auth module.
type AppModuleBasic struct{}

// module name
// Name returns the auth module's name
func (AppModuleBasic) Name() string {
return CosmosAppModuleBasic{}.Name()
}

// register module codec
// RegisterCodec registers the auth module's types for the given codec.
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
RegisterCodec(cdc)
*CosmosModuleCdc = *ModuleCdc // nolint (DO NOT TOUCH)
}

// default genesis state
// DefaultGenesis returns default genesis state as raw bytes for the auth
// module.
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
return CosmosAppModuleBasic{}.DefaultGenesis()
}

// module validate genesis
// ValidateGenesis performs genesis state validation for the auth module.
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
return CosmosAppModuleBasic{}.ValidateGenesis(bz)
}

// register rest routes
// RegisterRESTRoutes registers the REST routes for the auth module.
func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) {
CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route)
}

// get the root tx command of this module
// GetTxCmd returns the root tx command for the auth module.
func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command {
return CosmosAppModuleBasic{}.GetTxCmd(cdc)
}

// get the root query command of this module
// GetQueryCmd returns the root query command for the auth module.
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
return CosmosAppModuleBasic{}.GetQueryCmd(cdc)
}

//___________________________
// app module object

// AppModule implements an application module for the auth module.
type AppModule struct {
AppModuleBasic
cosmosAppModule CosmosAppModule
Expand All @@ -72,48 +74,49 @@ func NewAppModule(accountKeeper AccountKeeper) AppModule {
}
}

// module name
// Name returns the auth module's name.
func (am AppModule) Name() string {
return am.cosmosAppModule.Name()
}

// register invariants
// RegisterInvariants registers the auth module invariants.
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
am.cosmosAppModule.RegisterInvariants(ir)
}

// module querier route name
// Route returns the message routing key for the auth module.
func (am AppModule) Route() string {
return am.cosmosAppModule.Route()
}

// module handler
// NewHandler returns an sdk.Handler for the auth module.
func (am AppModule) NewHandler() sdk.Handler {
return am.cosmosAppModule.NewHandler()
}

// module querier route name
// QuerierRoute returns the auth module's querier route name.
func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() }

// module querier
// NewQuerierHandler returns the auth module sdk.Querier.
func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() }

// module init-genesis
// InitGenesis performs genesis initialization for the auth module.
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
return am.cosmosAppModule.InitGenesis(ctx, data)
}

// module export genesis
// ExportGenesis returns the exported genesis state as raw bytes for the auth
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
return am.cosmosAppModule.ExportGenesis(ctx)
}

// module begin-block
// BeginBlock returns the begin blocker for the auth module.
func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) {
am.cosmosAppModule.BeginBlock(ctx, rbb)
}

// module end-block
// EndBlock returns the end blocker for the auth module.
func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate {
return am.cosmosAppModule.EndBlock(ctx, rbb)
}
2 changes: 1 addition & 1 deletion x/auth/simulation/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/simulation"
)

// This simulation is forked because of the absence of the Mint Module
// SimulateDeductFee generates simulation cases that accounts send token to FeeCollector module account
// This simulation is forked to cover the absence of the Mint Module
func SimulateDeductFee(ak auth.AccountKeeper, supplyKeeper types.SupplyKeeper) simulation.Operation {
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simulation.Account) (
Expand Down
4 changes: 2 additions & 2 deletions x/bank/internal/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank"
)

// Register concrete types on codec codec
// RegisterCodec registers concrete types on codec codec
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(bank.MsgSend{}, "bank/MsgSend", nil)
cdc.RegisterConcrete(bank.MsgMultiSend{}, "bank/MsgMultiSend", nil)
}

// module codec
// ModuleCdc defines module codec
var ModuleCdc *codec.Codec

func init() {
Expand Down
Loading

0 comments on commit 2f75b51

Please sign in to comment.