From 05a3eec1d6a87731c2d3e575c679a4c469f2a430 Mon Sep 17 00:00:00 2001 From: anilCSE Date: Tue, 6 Sep 2022 22:17:11 +0530 Subject: [PATCH 1/3] fix linters --- .golangci.yml | 22 +++++++------------ app/ante/eth.go | 1 - app/app.go | 7 +++--- app/test_helpers.go | 5 ++--- cmd/config/config.go | 2 +- ethereum/eip712/eip712.go | 1 - gql/resolver.go | 2 -- gql/server.go | 3 ++- gql/util.go | 1 + rpc/ethereum/backend/utils.go | 1 - rpc/ethereum/namespaces/debug/api.go | 2 +- rpc/ethereum/namespaces/eth/api.go | 2 +- .../namespaces/eth/filters/filters.go | 2 +- server/util.go | 1 - testutil/network/network.go | 1 - testutil/network/util.go | 4 ++-- utils/json.go | 1 - utils/mnemonic.go | 2 +- x/auction/client/cli/tx.go | 2 +- x/auction/keeper/keeper.go | 4 +--- x/auction/keeper/msg_server.go | 1 - x/auction/module.go | 2 +- x/auction/types/msgs.go | 2 -- x/bond/client/cli/tx.go | 2 +- x/bond/client/testutil/grpc.go | 2 -- x/bond/client/testutil/query.go | 1 - x/bond/genesis.go | 4 ++-- x/bond/keeper/invariants.go | 1 + x/bond/keeper/msg_server.go | 1 + x/bond/module.go | 1 + x/bond/types/params.go | 1 + x/evm/types/logs.go | 4 ++-- x/feemarket/types/keys.go | 2 +- x/nameservice/client/cli/query.go | 1 - x/nameservice/client/cli/tx.go | 1 - x/nameservice/client/testutil/grpc.go | 14 +++--------- x/nameservice/client/testutil/query.go | 14 +++++------- x/nameservice/client/testutil/tx.go | 17 +++++--------- x/nameservice/genesis.go | 2 -- x/nameservice/helpers/helpers.go | 4 +--- x/nameservice/keeper/invariants.go | 4 ++-- x/nameservice/keeper/keeper.go | 7 ++---- x/nameservice/keeper/naming_keeper.go | 1 - x/nameservice/keeper/record_keeper.go | 2 -- x/nameservice/module.go | 2 +- x/nameservice/types/msg.go | 2 -- x/nameservice/types/params.go | 7 +++--- x/nameservice/types/types.go | 2 +- 48 files changed, 62 insertions(+), 108 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e5e9ae6e..40e4d037 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,38 +13,30 @@ linters: - errcheck - goconst - gocritic - - gofmt - - goimports + - gofumpt - revive - gosec - gosimple - govet - ineffassign - # - lll TODO: enable + - lll - misspell - nakedret - prealloc - exportloopref - staticcheck - - structcheck - stylecheck - # - typecheck #TODO: enable + - typecheck - unconvert - unparam - unused - varcheck - nolintlint - asciicheck - # - exhaustive - exportloopref - gofumpt - gomodguard - # - nestif - # - nlreturn - - noctx - - rowserrcheck - # - whitespace - # - wsl + - whitespace issues: exclude-rules: @@ -57,6 +49,8 @@ issues: max-same-issues: 50 linters-settings: + lll: + line-length: 150 dogsled: max-blank-identifiers: 3 golint: @@ -71,7 +65,7 @@ linters-settings: require-explanation: false require-specific: false gofumpt: - lang-version: "1.17" + lang-version: "1.18" gomodguard: blocked: versions: # List of blocked module version constraints @@ -80,4 +74,4 @@ linters-settings: reason: "CVE-2020-15114; CVE-2020-15136; CVE-2020-15115" # Reason why the version constraint exists. (Optional) - https://github.com/dgrijalva/jwt-go: # Blocked module with version constraint version: ">= 4.0.0-preview1" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons - reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional) + reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional) \ No newline at end of file diff --git a/app/ante/eth.go b/app/ante/eth.go index 27350448..4c15d479 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -126,7 +126,6 @@ func (avd EthAccountVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx if err := evmkeeper.CheckSenderBalance(sdk.NewIntFromBigInt(acct.Balance), txData); err != nil { return ctx, sdkerrors.Wrap(err, "failed to check sender balance") } - } return next(ctx, tx, simulate) } diff --git a/app/app.go b/app/app.go index df95b394..167c90b6 100644 --- a/app/app.go +++ b/app/app.go @@ -156,8 +156,10 @@ var ( mint.AppModuleBasic{}, distr.AppModuleBasic{}, gov.NewAppModuleBasic( - []govclient.ProposalHandler{paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler, - ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler}, + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler, + ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler, + }, ), params.AppModuleBasic{}, crisis.AppModuleBasic{}, @@ -491,7 +493,6 @@ func NewEthermintApp( transferModule := transfer.NewAppModule(app.TransferKeeper) transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) - //Create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) app.IBCKeeper.SetRouter(ibcRouter) diff --git a/app/test_helpers.go b/app/test_helpers.go index 31312207..0fa4354e 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -121,7 +121,6 @@ func NewTestAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOpti // Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp. func Setup(t *testing.T, isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState) simapp.GenesisState) *EthermintApp { - t.Helper() privVal := mock.NewPV() @@ -202,7 +201,8 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, patchGen } func genesisStateWithValSet(t *testing.T, app *EthermintApp, genesisState simapp.GenesisState, - valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) simapp.GenesisState { + valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance, +) simapp.GenesisState { // set genesis accounts authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) @@ -232,7 +232,6 @@ func genesisStateWithValSet(t *testing.T, app *EthermintApp, genesisState simapp } validators = append(validators, validator) delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) - } // set validators and delegations stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations) diff --git a/cmd/config/config.go b/cmd/config/config.go index b2d3dc01..6876ac23 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -40,7 +40,7 @@ func SetBech32Prefixes(config *sdk.Config) { func SetBip44CoinType(config *sdk.Config) { config.SetCoinType(ethermint.Bip44CoinType) config.SetPurpose(sdk.Purpose) // Shared - config.SetFullFundraiserPath(ethermint.BIP44HDPath) // nolint: staticcheck + config.SetFullFundraiserPath(ethermint.BIP44HDPath) //nolint: staticcheck } // RegisterDenoms registers the base and display denominations to the SDK. diff --git a/ethereum/eip712/eip712.go b/ethereum/eip712/eip712.go index 35a05dc2..d78f6de3 100644 --- a/ethereum/eip712/eip712.go +++ b/ethereum/eip712/eip712.go @@ -309,7 +309,6 @@ func traverseFields( } if fieldType.Kind() == reflect.Struct { - var fieldTypedef string if isCollection { diff --git a/gql/resolver.go b/gql/resolver.go index 7b02db5d..fd99f157 100644 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -125,7 +125,6 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI All: (all != nil && *all), }, ) - if err != nil { return nil, err } @@ -142,7 +141,6 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI } return gqlResponse, nil - } func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error) { diff --git a/gql/server.go b/gql/server.go index 3429f254..fd75f702 100644 --- a/gql/server.go +++ b/gql/server.go @@ -2,12 +2,13 @@ package gql import ( "fmt" + "net/http" + "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/playground" "github.com/cosmos/cosmos-sdk/client" "github.com/ethereum/go-ethereum/log" "github.com/spf13/viper" - "net/http" ) // Server configures and starts the GQL server. diff --git a/gql/util.go b/gql/util.go index 7af2aa0e..b69fd28f 100644 --- a/gql/util.go +++ b/gql/util.go @@ -38,6 +38,7 @@ func getGQLCoins(coins sdk.Coins) []*Coin { return gqlCoins } + func GetGQLNameAuthorityRecord(record *nstypes.NameAuthority) (*AuthorityRecord, error) { if record == nil { return nil, nil diff --git a/rpc/ethereum/backend/utils.go b/rpc/ethereum/backend/utils.go index 440ae673..01a4c0bf 100644 --- a/rpc/ethereum/backend/utils.go +++ b/rpc/ethereum/backend/utils.go @@ -55,7 +55,6 @@ func (e *EVMBackend) SetTxDefaults(args evmtypes.TransactionArgs) (evmtypes.Tran if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 { return args, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas) } - } else { if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil { return args, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet") diff --git a/rpc/ethereum/namespaces/debug/api.go b/rpc/ethereum/namespaces/debug/api.go index 3b667196..606b38a0 100644 --- a/rpc/ethereum/namespaces/debug/api.go +++ b/rpc/ethereum/namespaces/debug/api.go @@ -284,7 +284,7 @@ func (a *API) BlockProfile(file string, nsec uint) error { // CpuProfile turns on CPU profiling for nsec seconds and writes // profile data to file. -func (a *API) CpuProfile(file string, nsec uint) error { // nolint: golint, stylecheck, revive +func (a *API) CpuProfile(file string, nsec uint) error { //nolint: golint, stylecheck, revive a.logger.Debug("debug_cpuProfile", "file", file, "nsec", nsec) if err := a.StartCPUProfile(file); err != nil { return err diff --git a/rpc/ethereum/namespaces/eth/api.go b/rpc/ethereum/namespaces/eth/api.go index dd258b00..8e2ac51a 100644 --- a/rpc/ethereum/namespaces/eth/api.go +++ b/rpc/ethereum/namespaces/eth/api.go @@ -127,7 +127,7 @@ func (e *PublicAPI) ProtocolVersion() hexutil.Uint { } // ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config. -func (e *PublicAPI) ChainId() (*hexutil.Big, error) { // nolint +func (e *PublicAPI) ChainId() (*hexutil.Big, error) { //nolint e.logger.Debug("eth_chainId") // if current block is at or past the EIP-155 replay-protection fork block, return chainID from config bn, err := e.backend.BlockNumber() diff --git a/rpc/ethereum/namespaces/eth/filters/filters.go b/rpc/ethereum/namespaces/eth/filters/filters.go index e9adb5a5..24f7e626 100644 --- a/rpc/ethereum/namespaces/eth/filters/filters.go +++ b/rpc/ethereum/namespaces/eth/filters/filters.go @@ -45,7 +45,7 @@ func NewRangeFilter(logger log.Logger, backend Backend, begin, end int64, addres // Flatten the address and topic filter clauses into a single bloombits filter // system. Since the bloombits are not positional, nil topics are permitted, // which get flattened into a nil byte slice. - var filtersBz [][][]byte // nolint: prealloc + var filtersBz [][][]byte //nolint: prealloc if len(addresses) > 0 { filter := make([][]byte, len(addresses)) for i, address := range addresses { diff --git a/server/util.go b/server/util.go index d597c775..3b7feae0 100644 --- a/server/util.go +++ b/server/util.go @@ -82,7 +82,6 @@ func MountGRPCWebServices( logger tmlog.Logger, ) { for _, res := range grpcResources { - logger.Info("[GRPC Web] HTTP POST mounted", "resource", res) s := router.Methods("POST").Subrouter() diff --git a/testutil/network/network.go b/testutil/network/network.go index b262e927..2b2dbab1 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -431,7 +431,6 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()), sdk.OneInt(), ) - if err != nil { return nil, err } diff --git a/testutil/network/util.go b/testutil/network/util.go index 55eb2f93..aa4a2f22 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -253,12 +253,12 @@ func WriteFile(name string, dir string, contents []byte) error { writePath := filepath.Join(dir) file := filepath.Join(writePath, name) - err := tmos.EnsureDir(writePath, 0755) + err := tmos.EnsureDir(writePath, 0o755) if err != nil { return err } - err = ioutil.WriteFile(file, contents, 0644) // nolint: gosec + err = ioutil.WriteFile(file, contents, 0o644) //nolint: gosec if err != nil { return err } diff --git a/utils/json.go b/utils/json.go index a1062e73..2ef404e8 100644 --- a/utils/json.go +++ b/utils/json.go @@ -36,7 +36,6 @@ func GenerateHash(json map[string]interface{}) (string, []byte, error) { return "", nil, err } - //cid, err := CIDFromJSONBytes(content) cidString, err := CIDFromJSONBytesUsingIpldPrime(content) if err != nil { return "", nil, err diff --git a/utils/mnemonic.go b/utils/mnemonic.go index 80dce1ac..4cb6591f 100644 --- a/utils/mnemonic.go +++ b/utils/mnemonic.go @@ -16,7 +16,7 @@ func GenerateMnemonic() (string, error) { return "", err } - mnemonic, err := bip39.NewMnemonic(entropySeed[:]) + mnemonic, err := bip39.NewMnemonic(entropySeed) if err != nil { return "", err } diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 2728716d..cc1a01c3 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -134,7 +134,7 @@ func GetCmdCommitBid() *cobra.Command { } // Save reveal file. - ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0600) + ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600) msg := types.NewMsgCommitBid(auctionID, commitHash, clientCtx.GetFromAddress()) err = msg.ValidateBasic() diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 120978fc..4a4a2156 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -382,7 +382,7 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg types.MsgCommitBid) (*types.Bid, return &bid, nil } -// RevealBid reeals a bid comitted earlier. +// RevealBid reeals a bid committed earlier. func (k Keeper) RevealBid(ctx sdk.Context, msg types.MsgRevealBid) (*types.Auction, error) { if !k.HasAuction(ctx, msg.AuctionId) { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.") @@ -561,7 +561,6 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) { ctx.Logger().Info(fmt.Sprintf("Updated 1st bid %s %s", highestBid.BidderAddress, highestBid.BidAmount.String())) ctx.Logger().Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String())) - } else if secondHighestBid == nil || secondHighestBid.BidAmount.IsLT(bid.BidAmount) { ctx.Logger().Info(fmt.Sprintf("New 2nd highest bid %s %s", bid.BidderAddress, bid.BidAmount.String())) @@ -588,7 +587,6 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) { ctx.Logger().Info(fmt.Sprintf("Auction %s winner %s.", auction.Id, auction.WinnerAddress)) ctx.Logger().Info(fmt.Sprintf("Auction %s winner bid %s.", auction.Id, auction.WinningBid.String())) ctx.Logger().Info(fmt.Sprintf("Auction %s winner price %s.", auction.Id, auction.WinningPrice.String())) - } else { ctx.Logger().Info(fmt.Sprintf("Auction %s has no valid revealed bids (no winner).", auction.Id)) } diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index d0c99fbe..9efae775 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -79,7 +79,6 @@ func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types return &types.MsgCommitBidResponse{Bid: resp}, nil } -//RevealBid is the command for revealing a bid func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) { ctx := sdk.UnwrapSDKContext(c) diff --git a/x/auction/module.go b/x/auction/module.go index b4d59ddb..35caa77e 100644 --- a/x/auction/module.go +++ b/x/auction/module.go @@ -56,7 +56,7 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEnc if err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } - // Once json successfully marshalled, passes along to genesis.go + // Once json successfully marshaled, passes along to genesis.go return ValidateGenesis(data) } diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 7b2069d8..fa5f916f 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -63,7 +63,6 @@ func (msg MsgCreateAuction) GetSigners() []sdk.AccAddress { // NewMsgCommitBid is the constructor function for MsgCommitBid. func NewMsgCommitBid(auctionID string, commitHash string, signer sdk.AccAddress) MsgCommitBid { - return MsgCommitBid{ AuctionId: auctionID, CommitHash: commitHash, @@ -107,7 +106,6 @@ func (msg MsgCommitBid) GetSigners() []sdk.AccAddress { // NewMsgRevealBid is the constructor function for MsgRevealBid. func NewMsgRevealBid(auctionID string, reveal string, signer sdk.AccAddress) MsgRevealBid { - return MsgRevealBid{ AuctionId: auctionID, Reveal: reveal, diff --git a/x/bond/client/cli/tx.go b/x/bond/client/cli/tx.go index c39eec75..7510df3a 100644 --- a/x/bond/client/cli/tx.go +++ b/x/bond/client/cli/tx.go @@ -104,7 +104,7 @@ func WithdrawBondCmd() *cobra.Command { return cmd } -// CancelBondCmd is the CLI command for cancelling a bond. +// CancelBondCmd is the CLI command for canceling a bond. func CancelBondCmd() *cobra.Command { cmd := &cobra.Command{ Use: "cancel [bond Id]", diff --git a/x/bond/client/testutil/grpc.go b/x/bond/client/testutil/grpc.go index f5cbddf5..c436ecaa 100644 --- a/x/bond/client/testutil/grpc.go +++ b/x/bond/client/testutil/grpc.go @@ -28,7 +28,6 @@ func (s *IntegrationTestSuite) TestGRPCGetBonds() { true, "", func() { - }, }, { @@ -87,7 +86,6 @@ func (s *IntegrationTestSuite) TestGRPCGetBondsByOwner() { fmt.Sprintf(reqUrl, "asdasd"), true, func() { - }, }, { diff --git a/x/bond/client/testutil/query.go b/x/bond/client/testutil/query.go index ac965e18..30f24b39 100644 --- a/x/bond/client/testutil/query.go +++ b/x/bond/client/testutil/query.go @@ -251,7 +251,6 @@ func (s *IntegrationTestSuite) TestGetQueryBondListsByOwner() { }, true, func() { - }, }, { diff --git a/x/bond/genesis.go b/x/bond/genesis.go index 5457122c..ceff56d5 100644 --- a/x/bond/genesis.go +++ b/x/bond/genesis.go @@ -10,8 +10,8 @@ import ( // InitGenesis initializes genesis state based on exported genesis func InitGenesis( ctx sdk.Context, - k keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate { - + k keeper.Keeper, data types.GenesisState, +) []abci.ValidatorUpdate { k.SetParams(ctx, data.Params) for _, bond := range data.Bonds { diff --git a/x/bond/keeper/invariants.go b/x/bond/keeper/invariants.go index f7c8a4d8..aed8995f 100644 --- a/x/bond/keeper/invariants.go +++ b/x/bond/keeper/invariants.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tharsis/ethermint/x/bond/types" ) diff --git a/x/bond/keeper/msg_server.go b/x/bond/keeper/msg_server.go index f34a60b8..826a9514 100644 --- a/x/bond/keeper/msg_server.go +++ b/x/bond/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tharsis/ethermint/x/bond/types" ) diff --git a/x/bond/module.go b/x/bond/module.go index eb9f0103..d6f8c06b 100644 --- a/x/bond/module.go +++ b/x/bond/module.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/bond/types/params.go b/x/bond/types/params.go index 587f8c6f..c5933c3f 100644 --- a/x/bond/types/params.go +++ b/x/bond/types/params.go @@ -3,6 +3,7 @@ package types import ( "errors" "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) diff --git a/x/evm/types/logs.go b/x/evm/types/logs.go index 4cf73c94..f442aac3 100644 --- a/x/evm/types/logs.go +++ b/x/evm/types/logs.go @@ -89,7 +89,7 @@ func (log *Log) ToEthereum() *ethtypes.Log { } func NewLogsFromEth(ethlogs []*ethtypes.Log) []*Log { - var logs []*Log // nolint: prealloc + var logs []*Log //nolint: prealloc for _, ethlog := range ethlogs { logs = append(logs, NewLogFromEth(ethlog)) } @@ -99,7 +99,7 @@ func NewLogsFromEth(ethlogs []*ethtypes.Log) []*Log { // LogsToEthereum casts the Ethermint Logs to a slice of Ethereum Logs. func LogsToEthereum(logs []*Log) []*ethtypes.Log { - var ethLogs []*ethtypes.Log // nolint: prealloc + var ethLogs []*ethtypes.Log //nolint: prealloc for i := range logs { ethLogs = append(ethLogs, logs[i].ToEthereum()) } diff --git a/x/feemarket/types/keys.go b/x/feemarket/types/keys.go index 53302154..5b3a9981 100644 --- a/x/feemarket/types/keys.go +++ b/x/feemarket/types/keys.go @@ -15,7 +15,7 @@ const ( // prefix bytes for the feemarket persistent store const ( prefixBlockGasUsed = iota + 1 - deprecatedPrefixBaseFee // nolint + deprecatedPrefixBaseFee //nolint ) // KVStore key prefixes diff --git a/x/nameservice/client/cli/query.go b/x/nameservice/client/cli/query.go index 71257932..dd0e7247 100644 --- a/x/nameservice/client/cli/query.go +++ b/x/nameservice/client/cli/query.go @@ -266,7 +266,6 @@ $ %s query %s query-by-bond [bond id] return err } return clientCtx.PrintProto(res) - }, } flags.AddQueryFlagsToCmd(cmd) diff --git a/x/nameservice/client/cli/tx.go b/x/nameservice/client/cli/tx.go index 02840a76..7715d3f2 100644 --- a/x/nameservice/client/cli/tx.go +++ b/x/nameservice/client/cli/tx.go @@ -371,7 +371,6 @@ $ %s tx %s delete-name [crn] return cmd } -//GetPayloadFromFile Load payload object from YAML file. func GetPayloadFromFile(filePath string) (*types.PayloadType, error) { var payload types.PayloadType diff --git a/x/nameservice/client/testutil/grpc.go b/x/nameservice/client/testutil/grpc.go index 2256cee6..eabf1b96 100644 --- a/x/nameservice/client/testutil/grpc.go +++ b/x/nameservice/client/testutil/grpc.go @@ -64,7 +64,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() { val := s.network.Validators[0] sr := s.Require() reqUrl := val.APIAddress + "/vulcanize/nameservice/v1beta1/whois/%s" - var authorityName = "QueryWhoIS" + authorityName := "QueryWhoIS" testCases := []struct { name string url string @@ -78,7 +78,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() { true, "", func(authorityName string) { - }, }, { @@ -132,7 +131,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() { val := s.network.Validators[0] sr := s.Require() reqUrl := val.APIAddress + "/vulcanize/nameservice/v1beta1/lookup?crn=%s" - var authorityName = "QueryLookUp" + authorityName := "QueryLookUp" testCases := []struct { name string @@ -147,7 +146,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() { true, "", func(authorityName string) { - }, }, { @@ -199,7 +197,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() { true, "", func(bondId string) { - }, }, { @@ -271,7 +268,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() { true, "", func(authorityName string) { - }, }, { @@ -307,7 +303,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() { if !tc.expectErr { tc.preRun("QueryAuthorityExpiryQueue") } - // wait 12 seconds to name authorites expires + // wait 12 seconds to name authorities expires time.Sleep(time.Second * 12) resp, _ := rest.GetRequest(tc.url) @@ -343,7 +339,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() { true, "", func(bondId string) { - }, }, { @@ -483,7 +478,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByBondID() { true, "", func(bondId string) { - }, }, { @@ -538,7 +532,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetNameServiceModuleBalance() { true, "", func(bondId string) { - }, }, { @@ -590,7 +583,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryNamesList() { true, "", func(authorityName string) { - }, }, { diff --git a/x/nameservice/client/testutil/query.go b/x/nameservice/client/testutil/query.go index 0616fb0b..33d81ec2 100644 --- a/x/nameservice/client/testutil/query.go +++ b/x/nameservice/client/testutil/query.go @@ -66,7 +66,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryForRecords() { true, 0, func() { - }, }, { @@ -235,7 +234,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryForRecords() { func (s *IntegrationTestSuite) TestGetCmdWhoIs() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "test2" + authorityName := "test2" testCases := []struct { name string args []string @@ -249,7 +248,6 @@ func (s *IntegrationTestSuite) TestGetCmdWhoIs() { true, 1, func(authorityName string) { - }, }, { @@ -306,7 +304,7 @@ func (s *IntegrationTestSuite) TestGetCmdWhoIs() { func (s *IntegrationTestSuite) TestGetCmdLookupCRN() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "test1" + authorityName := "test1" testCases := []struct { name string args []string @@ -320,7 +318,6 @@ func (s *IntegrationTestSuite) TestGetCmdLookupCRN() { true, 0, func(authorityName string) { - }, }, { @@ -400,7 +397,7 @@ func (s *IntegrationTestSuite) TestGetCmdLookupCRN() { func (s *IntegrationTestSuite) GetRecordExpiryQueue() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "GetRecordExpiryQueue" + authorityName := "GetRecordExpiryQueue" testCasesForRecordsExpiry := []struct { name string @@ -415,7 +412,6 @@ func (s *IntegrationTestSuite) GetRecordExpiryQueue() { true, 0, func(authorityName string, s *IntegrationTestSuite) { - }, }, { @@ -451,10 +447,11 @@ func (s *IntegrationTestSuite) GetRecordExpiryQueue() { }) } } + func (s *IntegrationTestSuite) TestGetAuthorityExpiryQueue() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "TestGetAuthorityExpiryQueue" + authorityName := "TestGetAuthorityExpiryQueue" testCases := []struct { name string @@ -467,7 +464,6 @@ func (s *IntegrationTestSuite) TestGetAuthorityExpiryQueue() { []string{"invalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, true, func(authorityName string) { - }, }, { diff --git a/x/nameservice/client/testutil/tx.go b/x/nameservice/client/testutil/tx.go index 963fc542..71ec281a 100644 --- a/x/nameservice/client/testutil/tx.go +++ b/x/nameservice/client/testutil/tx.go @@ -42,7 +42,7 @@ func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") - var genesisState = s.cfg.GenesisState + genesisState := s.cfg.GenesisState var nsData nstypes.GenesisState s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[nstypes.ModuleName], &nsData)) @@ -222,7 +222,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() { func (s *IntegrationTestSuite) TestGetCmdReserveName() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "testtest" + authorityName := "testtest" testCases := []struct { name string args []string @@ -289,7 +289,7 @@ func (s *IntegrationTestSuite) TestGetCmdReserveName() { func (s *IntegrationTestSuite) TestGetCmdSetName() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "TestGetCmdSetName" + authorityName := "TestGetCmdSetName" testCases := []struct { name string args []string @@ -307,7 +307,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() { }, true, func(authorityName string) { - }, }, { @@ -394,7 +393,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() { func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "TestGetCmdSetAuthorityBond" + authorityName := "TestGetCmdSetAuthorityBond" testCases := []struct { name string @@ -413,7 +412,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() { }, true, func(authorityName string) { - }, }, { @@ -480,7 +478,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() { func (s *IntegrationTestSuite) TestGetCmdDeleteName() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "TestGetCmdDeleteName" + authorityName := "TestGetCmdDeleteName" testCasesForDeletingName := []struct { name string args []string @@ -498,7 +496,6 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() { }, true, func(authorityName string, s *IntegrationTestSuite) { - }, }, { @@ -564,7 +561,6 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() { return "" }, func(recordId string, s *IntegrationTestSuite) { - }, }, { @@ -659,7 +655,7 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() { } // -//func (s *IntegrationTestSuite) TestGetCmdDissociateRecords() { +// func (s *IntegrationTestSuite) TestGetCmdDissociateRecords() { // val := s.network.Validators[0] // sr := s.Require() // testCasesForDeletingName := []struct { @@ -807,7 +803,6 @@ func (s *IntegrationTestSuite) TestGetCmdAssociateBond() { return "", "" }, func(recordId, bondId string, s *IntegrationTestSuite) { - }, }, { diff --git a/x/nameservice/genesis.go b/x/nameservice/genesis.go index 040eea5a..27fe6770 100644 --- a/x/nameservice/genesis.go +++ b/x/nameservice/genesis.go @@ -17,7 +17,6 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) // Add to record expiry queue if expiry time is in the future. expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) - if err != nil { panic(err) } @@ -33,7 +32,6 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) } for _, authority := range data.Authorities { - //Only import authorities that are marked active. if authority.Entry.Status == types.AuthorityActive { keeper.SetNameAuthority(ctx, authority.Name, authority.Entry) diff --git a/x/nameservice/helpers/helpers.go b/x/nameservice/helpers/helpers.go index f2f4ed5d..da0ef91c 100644 --- a/x/nameservice/helpers/helpers.go +++ b/x/nameservice/helpers/helpers.go @@ -7,11 +7,10 @@ import ( "encoding/gob" "encoding/hex" "encoding/json" + "sort" set "github.com/deckarep/golang-set" wnsUtils "github.com/tharsis/ethermint/utils" - - "sort" ) func StringToBytes(val string) []byte { @@ -62,7 +61,6 @@ func MarshalMapToJSONBytes(val map[string]interface{}) (bytes []byte) { func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} { var val map[string]interface{} err := json.Unmarshal(bytes, &val) - if err != nil { panic("Marshal error.") } diff --git a/x/nameservice/keeper/invariants.go b/x/nameservice/keeper/invariants.go index 00069e31..c7c0d27e 100644 --- a/x/nameservice/keeper/invariants.go +++ b/x/nameservice/keeper/invariants.go @@ -15,8 +15,8 @@ func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) { // (2) associated bond exists, if bondID is not null. func RecordInvariants(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { - //store := ctx.KVStore(k.storeKey) - //itr := sdk.KVStorePrefixIterator(store, PrefixCIDToRecordIndex) + // store := ctx.KVStore(k.storeKey) + // itr := sdk.KVStorePrefixIterator(store, PrefixCIDToRecordIndex) //defer itr.Close() //for ; itr.Valid(); itr.Next() { // bz := store.Get(itr.Key()) diff --git a/x/nameservice/keeper/keeper.go b/x/nameservice/keeper/keeper.go index c4d1c7a9..0f866afa 100644 --- a/x/nameservice/keeper/keeper.go +++ b/x/nameservice/keeper/keeper.go @@ -73,7 +73,8 @@ type Keeper struct { // NewKeeper creates new instances of the nameservice Keeper func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, recordKeeper RecordKeeper, - bondKeeper bondkeeper.Keeper, auctionKeeper auctionkeeper.Keeper, storeKey storetypes.StoreKey, ps paramtypes.Subspace) Keeper { + bondKeeper bondkeeper.Keeper, auctionKeeper auctionkeeper.Keeper, storeKey storetypes.StoreKey, ps paramtypes.Subspace, +) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { ps = ps.WithKeyTable(types.ParamKeyTable()) @@ -295,7 +296,6 @@ func (k Keeper) GetRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Ti // InsertRecordExpiryQueue inserts a record CID to the appropriate timeslice in the record expiry queue. func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record) { expiryTime, err := time.Parse(time.RFC3339, val.ExpiryTime) - if err != nil { panic(err) } @@ -308,7 +308,6 @@ func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record) { // DeleteRecordExpiryQueue deletes a record CID from the record expiry queue. func (k Keeper) DeleteRecordExpiryQueue(ctx sdk.Context, record types.Record) { expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) - if err != nil { panic(err) } @@ -344,7 +343,6 @@ func (k Keeper) GetAllExpiredRecords(ctx sdk.Context, currTime time.Time) (expir for ; itr.Valid(); itr.Next() { timeslice, err := helpers.BytesArrToStringArr(itr.Value()) - if err != nil { panic(err) } @@ -426,7 +424,6 @@ func recordObjToRecord(store sdk.KVStore, codec codec.BinaryCodec, record types. if store.Has(reverseNameIndexKey) { names, err := helpers.BytesArrToStringArr(store.Get(reverseNameIndexKey)) - if err != nil { panic(err) } diff --git a/x/nameservice/keeper/naming_keeper.go b/x/nameservice/keeper/naming_keeper.go index cc61f567..a51fb50f 100644 --- a/x/nameservice/keeper/naming_keeper.go +++ b/x/nameservice/keeper/naming_keeper.go @@ -653,7 +653,6 @@ func (k Keeper) GetAllExpiredAuthorities(ctx sdk.Context, currTime time.Time) (e for ; itr.Valid(); itr.Next() { timeslice := []string{} timeslice, err := helpers.BytesArrToStringArr(itr.Value()) - if err != nil { panic(err) } diff --git a/x/nameservice/keeper/record_keeper.go b/x/nameservice/keeper/record_keeper.go index 8c390498..a59860fa 100644 --- a/x/nameservice/keeper/record_keeper.go +++ b/x/nameservice/keeper/record_keeper.go @@ -162,7 +162,6 @@ func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) er // Check if renewal is required (i.e. expired record marked as deleted). record := k.GetRecord(ctx, msg.RecordId) expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) - if err != nil { panic(err) } @@ -182,7 +181,6 @@ func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) er // ProcessAssociateBond associates a record with a bond. func (k Keeper) ProcessAssociateBond(ctx sdk.Context, msg types.MsgAssociateBond) error { - if !k.HasRecord(ctx, msg.RecordId) { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") } diff --git a/x/nameservice/module.go b/x/nameservice/module.go index d1011fc7..583b3980 100644 --- a/x/nameservice/module.go +++ b/x/nameservice/module.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -105,7 +106,6 @@ func (am AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { } func (am AppModule) RegisterServices(cfg module.Configurator) { - querier := keeper.Querier{Keeper: am.keeper} types.RegisterQueryServer(cfg.QueryServer(), querier) diff --git a/x/nameservice/types/msg.go b/x/nameservice/types/msg.go index 309ab017..72e58653 100644 --- a/x/nameservice/types/msg.go +++ b/x/nameservice/types/msg.go @@ -31,7 +31,6 @@ func (msg MsgSetName) Type() string { return "set-name" } // ValidateBasic Implements Msg. func (msg MsgSetName) ValidateBasic() error { - if msg.Crn == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "CRN is required.") } @@ -76,7 +75,6 @@ func (msg MsgReserveAuthority) Type() string { return "reserve-authority" } // ValidateBasic Implements Msg. func (msg MsgReserveAuthority) ValidateBasic() error { - if len(msg.Name) == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "name is required.") } diff --git a/x/nameservice/types/params.go b/x/nameservice/types/params.go index a6aa6b80..b32fbdd0 100644 --- a/x/nameservice/types/params.go +++ b/x/nameservice/types/params.go @@ -3,9 +3,10 @@ package types import ( "bytes" "fmt" + "time" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "time" ) // Default parameter values. @@ -75,8 +76,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { func NewParams(recordRent sdk.Coin, recordRentDuration time.Duration, authorityRent sdk.Coin, authorityRentDuration time.Duration, authorityGracePeriod time.Duration, authorityAuctionEnabled bool, commitsDuration time.Duration, revealsDuration time.Duration, - commitFee sdk.Coin, revealFee sdk.Coin, minimumBid sdk.Coin) Params { - + commitFee sdk.Coin, revealFee sdk.Coin, minimumBid sdk.Coin, +) Params { return Params{ RecordRent: recordRent, RecordRentDuration: recordRentDuration, diff --git a/x/nameservice/types/types.go b/x/nameservice/types/types.go index f60b0cea..8d69a4ce 100644 --- a/x/nameservice/types/types.go +++ b/x/nameservice/types/types.go @@ -22,7 +22,7 @@ type PayloadType struct { // ToPayload converts PayloadType to Payload object. // Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4. func (payloadObj *PayloadType) ToPayload() Payload { - var payload = Payload{ + payload := Payload{ Record: &Record{ Deleted: false, Owners: nil, -- 2.45.2 From 89b64fffefa0e0fc39eb1f0f38eee28cb8a5cf18 Mon Sep 17 00:00:00 2001 From: anilCSE Date: Tue, 6 Sep 2022 22:22:16 +0530 Subject: [PATCH 2/3] update golang-ci-action version --- .github/workflows/lint.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ca4509ea..2e9c9630 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,13 +14,15 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v3 + with: + go-version: 1.18 - uses: technote-space/get-diff-action@v6.0.1 with: SUFFIX_FILTER: | .go .mod .sum - - uses: golangci/golangci-lint-action@v2.5.2 + - uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: v1.42.1 -- 2.45.2 From 984db173f09f88b78cd9ba324cfa2723c925dd81 Mon Sep 17 00:00:00 2001 From: anilCSE Date: Tue, 6 Sep 2022 22:30:47 +0530 Subject: [PATCH 3/3] fix lint --- .github/workflows/lint.yml | 60 +++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2e9c9630..4fcccbb2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,20 +13,64 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 with: go-version: 1.18 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: actions/checkout@v3 + - uses: technote-space/get-diff-action@v6.1.0 with: - SUFFIX_FILTER: | - .go - .mod - .sum + PATTERNS: | + **/**.go + go.mod + go.sum - uses: golangci/golangci-lint-action@v3 with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.42.1 + version: v1.48.0 args: --timeout 10m github-token: ${{ secrets.github_token }} # Check only if there are differences in the source code if: "env.GIT_DIFF" + markdown-lint: + name: Run markdown-lint + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + - uses: technote-space/get-diff-action@v6.1.0 + with: + PATTERNS: | + docs/**/*.md + x/**/*.md + README.md + - uses: articulate/actions-markdownlint@v1.1.0 + # Check only if there are differences in the source code + if: env.GIT_DIFF + python-lint: + name: Run flake8 on python integration tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v17 + - uses: cachix/cachix-action@v10 + with: + name: ethermint + - uses: technote-space/get-diff-action@v6.1.0 + with: + PATTERNS: | + **/**.py + - run: | + nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py" + if: env.GIT_DIFF + gomod2nix: + name: Check gomod2nix.toml file is up to date + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - uses: cachix/install-nix-action@v17 + - uses: cachix/cachix-action@v10 + with: + name: ethermint + - name: run gomod2nix + run: | + nix run -f ./nix gomod2nix + git diff --no-ext-diff --exit-code \ No newline at end of file -- 2.45.2