Skip to content

Commit

Permalink
various linter fixes (cosmos#8666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Treglia authored Feb 23, 2021
1 parent 39b816e commit f2ee972
Show file tree
Hide file tree
Showing 74 changed files with 19 additions and 168 deletions.
2 changes: 1 addition & 1 deletion client/docs/statik/init.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package statik

//This just for fixing the error in importing empty github.com/cosmos/cosmos-sdk/client/docs/statik
// This just for fixing the error in importing empty github.com/cosmos/cosmos-sdk/client/docs/statik
1 change: 1 addition & 0 deletions client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func addHTTPDeprecationHeaders(h http.Handler) http.Handler {
// WithHTTPDeprecationHeaders returns a new *mux.Router, identical to its input
// but with the addition of HTTP Deprecation headers. This is used to mark legacy
// amino REST endpoints as deprecated in the REST API.
// nolint: gocritic
func WithHTTPDeprecationHeaders(r *mux.Router) *mux.Router {
subRouter := r.NewRoute().Subrouter()
subRouter.Use(addHTTPDeprecationHeaders)
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/rest"
)

//BlockCommand returns the verified block data for a given heights
// BlockCommand returns the verified block data for a given heights
func BlockCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "block [height]",
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

// TODO these next two functions feel kinda hacky based on their placement

//ValidatorCommand returns the validator set for a given height
// ValidatorCommand returns the validator set for a given height
func ValidatorCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "tendermint-validator-set [height]",
Expand Down
4 changes: 2 additions & 2 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress {
// start at 100 so we can make up to 999 test addresses with valid test addresses
for i := 100; i < (accNum + 100); i++ {
numString := strconv.Itoa(i)
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") //base address string
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string

buffer.WriteString(numString) //adding on final two digits to make addresses unique
buffer.WriteString(numString) // adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHex(buffer.String())
bech := res.String()
addr, _ := TestAddr(buffer.String(), bech)
Expand Down
1 change: 0 additions & 1 deletion store/gaskv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type Store struct {
}

// NewStore returns a reference to a new GasKVStore.
// nolint
func NewStore(parent types.KVStore, gasMeter types.GasMeter, gasConfig types.GasConfig) *Store {
kvs := &Store{
gasMeter: gasMeter,
Expand Down
15 changes: 2 additions & 13 deletions types/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ func precisionMultiplier(prec int64) *big.Int {
return precisionMultipliers[prec]
}

//______________________________________________________________________________________________

// create a new Dec from integer assuming whole number
func NewDec(i int64) Dec {
return NewDecWithPrec(i, 0)
Expand Down Expand Up @@ -195,8 +193,6 @@ func MustNewDecFromStr(s string) Dec {
return dec
}

//______________________________________________________________________________________________
//nolint
func (d Dec) IsNil() bool { return d.i == nil } // is decimal nil
func (d Dec) IsZero() bool { return (d.i).Sign() == 0 } // is equal to zero
func (d Dec) IsNegative() bool { return (d.i).Sign() == -1 } // is negative
Expand All @@ -215,8 +211,8 @@ func (d Dec) BigInt() *big.Int {
return nil
}

copy := new(big.Int)
return copy.Set(d.i)
cp := new(big.Int)
return cp.Set(d.i)
}

// addition
Expand Down Expand Up @@ -561,8 +557,6 @@ func (d Dec) RoundInt() Int {
return NewIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i))
}

//___________________________________________________________________________________

// similar to chopPrecisionAndRound, but always rounds down
func chopPrecisionAndTruncate(d *big.Int) *big.Int {
return d.Quo(d, precisionReuse)
Expand Down Expand Up @@ -612,8 +606,6 @@ func (d Dec) Ceil() Dec {
return NewDecFromBigInt(quo.Add(quo, oneInt))
}

//___________________________________________________________________________________

// MaxSortableDec is the largest Dec that can be passed into SortableDecBytes()
// Its negative form is the least Dec that can be passed in.
var MaxSortableDec = OneDec().Quo(SmallestDec())
Expand Down Expand Up @@ -648,8 +640,6 @@ func SortableDecBytes(dec Dec) []byte {
return []byte(fmt.Sprintf(fmt.Sprintf("%%0%ds", Precision*2+1), dec.String()))
}

//___________________________________________________________________________________

// reuse nil values
var nilJSON []byte

Expand Down Expand Up @@ -758,7 +748,6 @@ func (dp DecProto) String() string {
return dp.Dec.String()
}

//___________________________________________________________________________________
// helpers

// test if two decimal arrays are equal
Expand Down
2 changes: 0 additions & 2 deletions types/decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ func (s *decimalTestSuite) mustNewDecFromStr(str string) (d sdk.Dec) {
return d
}

//_______________________________________

func (s *decimalTestSuite) TestNewDecFromStr() {
largeBigInt, success := new(big.Int).SetString("3144605511029693144278234343371835", 10)
s.Require().True(success)
Expand Down
1 change: 0 additions & 1 deletion types/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const UndefinedCodespace = "undefined"

var (
// errInternal should never be exposed, but we reserve this code for non-specified errors
//nolint
errInternal = Register(UndefinedCodespace, 1, "internal")

// ErrTxDecode is returned if we cannot parse a transaction
Expand Down
8 changes: 0 additions & 8 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

//__________________________________________________________________________________________

// AppModuleBasic is the standard form for basic non-dependant elements of an application module.
type AppModuleBasic interface {
Name() string
Expand Down Expand Up @@ -146,8 +144,6 @@ func (bm BasicManager) AddQueryCommands(rootQueryCmd *cobra.Command) {
}
}

//_________________________________________________________

// AppModuleGenesis is the standard form for an application module genesis functions
type AppModuleGenesis interface {
AppModuleBasic
Expand Down Expand Up @@ -186,8 +182,6 @@ type AppModule interface {
EndBlock(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
}

//___________________________

// GenesisOnlyAppModule is an AppModule that only has import/export functionality
type GenesisOnlyAppModule struct {
AppModuleGenesis
Expand Down Expand Up @@ -226,8 +220,6 @@ func (GenesisOnlyAppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []ab
return []abci.ValidatorUpdate{}
}

//____________________________________________________________________________

// Manager defines a module manager that provides the high level utility for managing and executing
// operations for a group of modules
type Manager struct {
Expand Down
4 changes: 2 additions & 2 deletions types/simulation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type Config struct {
ParamsFile string // custom simulation params file which overrides any random params; cannot be used with genesis

ExportParamsPath string // custom file path to save the exported params JSON
ExportParamsHeight int //height to which export the randomly generated params
ExportStatePath string //custom file path to save the exported app state JSON
ExportParamsHeight int // height to which export the randomly generated params
ExportStatePath string // custom file path to save the exported app state JSON
ExportStatsPath string // custom file path to save the exported simulation statistics JSON

Seed int64 // simulation random seed
Expand Down
2 changes: 0 additions & 2 deletions types/simulation/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ func (om OperationMsg) LogEvent(eventLogger func(route, op, evResult string)) {
eventLogger(om.Route, om.Name, pass)
}

//________________________________________________________________________

// FutureOperation is an operation which will be ran at the beginning of the
// provided BlockHeight. If both a BlockHeight and BlockTime are specified, it
// will use the BlockHeight. In the (likely) event that multiple operations
Expand Down
2 changes: 0 additions & 2 deletions types/uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ func (u *Uint) Size() int {
func (u Uint) MarshalAmino() ([]byte, error) { return u.Marshal() }
func (u *Uint) UnmarshalAmino(bz []byte) error { return u.Unmarshal(bz) }

//__________________________________________________________________________

// UintOverflow returns true if a given unsigned integer overflows and false
// otherwise.
func UintOverflow(i *big.Int) error {
Expand Down
1 change: 0 additions & 1 deletion x/auth/legacy/v034/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// DONTCOVER
// nolint
package v034

import (
Expand Down
1 change: 0 additions & 1 deletion x/auth/legacy/v036/migrate.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// DONTCOVER
// nolint
package v036

import (
Expand Down
1 change: 0 additions & 1 deletion x/auth/legacy/v036/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// DONTCOVER
// nolint
package v036

import v034auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v034"
Expand Down
1 change: 0 additions & 1 deletion x/auth/legacy/v038/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v038

// DONTCOVER
// nolint

import (
"bytes"
Expand Down
1 change: 0 additions & 1 deletion x/auth/legacy/v039/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v039

// DONTCOVER
// nolint

import (
"bytes"
Expand Down
8 changes: 3 additions & 5 deletions x/auth/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the auth module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
panic(err)
}
}

// GetTxCmd returns the root tx command for the auth module.
Expand All @@ -85,8 +87,6 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
types.RegisterInterfaces(registry)
}

//____________________________________________________________________________

// AppModule implements an application module for the auth module.
type AppModule struct {
AppModuleBasic
Expand Down Expand Up @@ -159,8 +159,6 @@ func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Validato
return []abci.ValidatorUpdate{}
}

//____________________________________________________________________________

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the auth module
Expand Down
3 changes: 1 addition & 2 deletions x/auth/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)

// TxConfigTestSuite provides a test suite that can be used to test that a TxConfig implementation is correct
//nolint:golint // type name will be used as tx.TxConfigTestSuite by other packages, and that stutters; consider calling this GeneratorTestSuite
// TxConfigTestSuite provides a test suite that can be used to test that a TxConfig implementation is correct.
type TxConfigTestSuite struct {
suite.Suite
TxConfig client.TxConfig
Expand Down
1 change: 0 additions & 1 deletion x/auth/types/account_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func (ar AccountRetriever) GetAccount(clientCtx client.Context, addr sdk.AccAddr
// GetAccountWithHeight queries for an account given an address. Returns the
// height of the query with the account. An error is returned if the query
// or decoding fails.
//nolint:interfacer
func (ar AccountRetriever) GetAccountWithHeight(clientCtx client.Context, addr sdk.AccAddress) (client.Account, int64, error) {
var header metadata.MD

Expand Down
1 change: 0 additions & 1 deletion x/auth/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func ParamKeyTable() paramtypes.KeyTable {

// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
// pairs of auth module's parameters.
// nolint
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyMaxMemoCharacters, &p.MaxMemoCharacters, validateMaxMemoCharacters),
Expand Down
4 changes: 0 additions & 4 deletions x/auth/vesting/types/vesting_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var (
_ vestexported.VestingAccount = (*DelayedVestingAccount)(nil)
)

//-----------------------------------------------------------------------------
// Base Vesting Account

// NewBaseVestingAccount creates a new BaseVestingAccount object. It is the
Expand Down Expand Up @@ -216,7 +215,6 @@ func (bva BaseVestingAccount) MarshalYAML() (interface{}, error) {
return string(bz), err
}

//-----------------------------------------------------------------------------
// Continuous Vesting Account

var _ vestexported.VestingAccount = (*ContinuousVestingAccount)(nil)
Expand Down Expand Up @@ -345,7 +343,6 @@ func (cva ContinuousVestingAccount) MarshalYAML() (interface{}, error) {
return string(bz), err
}

//-----------------------------------------------------------------------------
// Periodic Vesting Account

var _ vestexported.VestingAccount = (*PeriodicVestingAccount)(nil)
Expand Down Expand Up @@ -504,7 +501,6 @@ func (pva PeriodicVestingAccount) MarshalYAML() (interface{}, error) {
return string(bz), err
}

//-----------------------------------------------------------------------------
// Delayed Vesting Account

var _ vestexported.VestingAccount = (*DelayedVestingAccount)(nil)
Expand Down
1 change: 0 additions & 1 deletion x/bank/legacy/v036/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// DONTCOVER
// nolint
package v036

import (
Expand Down
1 change: 0 additions & 1 deletion x/bank/legacy/v038/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v038

// DONTCOVER
// nolint

const (
ModuleName = "bank"
Expand Down
4 changes: 0 additions & 4 deletions x/bank/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
types.RegisterInterfaces(registry)
}

//____________________________________________________________________________

// AppModule implements an application module for the bank module.
type AppModule struct {
AppModuleBasic
Expand Down Expand Up @@ -166,8 +164,6 @@ func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Validato
return []abci.ValidatorUpdate{}
}

//____________________________________________________________________________

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the bank module.
Expand Down
3 changes: 0 additions & 3 deletions x/bank/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operatio
}

// sendMsgSend sends a transaction with a MsgSend from a provided random account.
// nolint: interfacer
func sendMsgSend(
r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper,
msg *types.MsgSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey,
Expand Down Expand Up @@ -223,7 +222,6 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope

// sendMsgMultiSend sends a transaction with a MsgMultiSend from a provided random
// account.
// nolint: interfacer
func sendMsgMultiSend(
r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper,
msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey,
Expand Down Expand Up @@ -289,7 +287,6 @@ func sendMsgMultiSend(

// randomSendFields returns the sender and recipient simulation accounts as well
// as the transferred amount.
// nolint: interfacer
func randomSendFields(
r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, bk keeper.Keeper, ak types.AccountKeeper,
) (simtypes.Account, simtypes.Account, sdk.Coins, bool) {
Expand Down
2 changes: 0 additions & 2 deletions x/crisis/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ func createTestApp() (*simapp.SimApp, sdk.Context, []sdk.AccAddress) {
return app, ctx, addrs
}

//____________________________________________________________________________

func TestHandleMsgVerifyInvariant(t *testing.T) {
app, ctx, addrs := createTestApp()
sender := addrs[0]
Expand Down
Loading

0 comments on commit f2ee972

Please sign in to comment.