From 27e85c80e7d96096ab8e0122c7b7673bf975939a Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 17 May 2024 16:59:16 -0400 Subject: [PATCH] Fixed a lot of linting. --- .golangci.yml | 5 +++++ Makefile | 2 -- app/app.go | 2 +- cmd/provenanced/cmd/genesis.go | 1 + cmd/provenanced/cmd/root.go | 1 + internal/handlers/msg_service_router.go | 10 +++------- testutil/cli/exec.go | 1 + testutil/ibc/testchain.go | 2 +- testutil/queries/generic.go | 2 +- x/attribute/keeper/keeper.go | 10 ++-------- x/attribute/module.go | 6 ------ x/attribute/simulation/proposals.go | 12 ------------ x/exchange/module/module.go | 6 ------ x/exchange/simulation/decoder.go | 2 +- x/hold/module/module.go | 6 ------ x/ibchooks/module.go | 8 +------- x/ibcratelimit/module/module.go | 5 ----- x/marker/types/key.go | 3 --- x/metadata/module.go | 6 ------ x/metadata/types/address_test.go | 3 ++- x/metadata/types/scope_test.go | 2 +- x/metadata/types/specification_test.go | 6 +++--- x/msgfees/client/cli/tx.go | 1 - x/oracle/module/module.go | 6 ------ x/quarantine/module/module.go | 6 ------ x/sanction/module/module.go | 9 --------- x/trigger/module/module.go | 6 ------ 27 files changed, 24 insertions(+), 105 deletions(-) delete mode 100644 x/attribute/simulation/proposals.go diff --git a/.golangci.yml b/.golangci.yml index 1570dfcd6a..c34ef8d4a1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -83,6 +83,7 @@ linters-settings: - github.com/armon/go-metrics + - cosmossdk.io/client/v2/autocli - cosmossdk.io/core - cosmossdk.io/errors - cosmossdk.io/log @@ -119,6 +120,8 @@ linters-settings: - github.com/cosmos/gogoproto + - github.com/golang/protobuf/proto + - github.com/google/uuid - github.com/gorilla/mux @@ -155,6 +158,8 @@ linters-settings: - github.com/cometbft/cometbft-db - github.com/rs/zerolog + + - sigs.k8s.io/yaml test: files: - "$test" diff --git a/Makefile b/Makefile index 018b7bdde5..61b7dab098 100644 --- a/Makefile +++ b/Makefile @@ -132,8 +132,6 @@ install: go.sum CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install $(BUILD_FLAGS) ./cmd/provenanced build: validate-go-version go.sum -# TODO[1760]: Remove this delay once we're stable again. - @if [ -z "${ACK_50}" ]; then printf '\033[93mWARNING:\033[0m This branch is currently unstable and should not be built for use.\n To bypass this 10 second delay: ACK_50=1 make build\n'; sleep 10; fi mkdir -p $(BUILDDIR) CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build -o $(BUILDDIR)/ $(BUILD_FLAGS) ./cmd/provenanced diff --git a/app/app.go b/app/app.go index 93d9e9ddcb..4e55e909bc 100644 --- a/app/app.go +++ b/app/app.go @@ -960,7 +960,7 @@ func New( sanction.ModuleName, hold.ModuleName, exchange.ModuleName, - consensusparamtypes.ModuleName, // TODO[1760]: Is this the correct placement? + consensusparamtypes.ModuleName, ibcratelimit.ModuleName, ibchookstypes.ModuleName, diff --git a/cmd/provenanced/cmd/genesis.go b/cmd/provenanced/cmd/genesis.go index 4850602a0a..a5b97a9618 100644 --- a/cmd/provenanced/cmd/genesis.go +++ b/cmd/provenanced/cmd/genesis.go @@ -23,6 +23,7 @@ import ( genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/provenance-io/provenance/x/exchange" exchangecli "github.com/provenance-io/provenance/x/exchange/client/cli" markercli "github.com/provenance-io/provenance/x/marker/client/cli" diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index d60b872a03..7c53da56e5 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -44,6 +44,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" + "github.com/provenance-io/provenance/app" "github.com/provenance-io/provenance/app/params" "github.com/provenance-io/provenance/cmd/provenanced/config" diff --git a/internal/handlers/msg_service_router.go b/internal/handlers/msg_service_router.go index 25c120c8c4..aa1f400f4a 100644 --- a/internal/handlers/msg_service_router.go +++ b/internal/handlers/msg_service_router.go @@ -100,7 +100,7 @@ func (msr *PioMsgServiceRouter) registerHybridHandler(sd *grpc.ServiceDesc, meth return nil } -func (msr *PioMsgServiceRouter) registerMsgServiceHandler(sd *grpc.ServiceDesc, method grpc.MethodDesc, handler interface{}) error { +func (msr *PioMsgServiceRouter) registerMsgServiceHandler(sd *grpc.ServiceDesc, method grpc.MethodDesc, handler interface{}) { fqMethod := fmt.Sprintf("/%s/%s", sd.ServiceName, method.MethodName) methodHandler := method.Handler @@ -201,7 +201,6 @@ func (msr *PioMsgServiceRouter) registerMsgServiceHandler(sd *grpc.ServiceDesc, return sdk.WrapServiceResult(ctx, resMsg, err) } - return nil } // RegisterService implements the gRPC Server.RegisterService method. sd is a gRPC @@ -214,11 +213,8 @@ func (msr *PioMsgServiceRouter) registerMsgServiceHandler(sd *grpc.ServiceDesc, func (msr *PioMsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler interface{}) { // Adds a top-level query handler based on the gRPC service name. for _, method := range sd.Methods { - err := msr.registerMsgServiceHandler(sd, method, handler) - if err != nil { - panic(err) - } - err = msr.registerHybridHandler(sd, method, handler) + msr.registerMsgServiceHandler(sd, method, handler) + err := msr.registerHybridHandler(sd, method, handler) if err != nil { panic(err) } diff --git a/testutil/cli/exec.go b/testutil/cli/exec.go index 2f751abda2..516552a074 100644 --- a/testutil/cli/exec.go +++ b/testutil/cli/exec.go @@ -9,6 +9,7 @@ import ( sdkcli "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/testutil/assertions" "github.com/provenance-io/provenance/testutil/queries" ) diff --git a/testutil/ibc/testchain.go b/testutil/ibc/testchain.go index 2ab7aabaaa..ea7d984bcd 100644 --- a/testutil/ibc/testchain.go +++ b/testutil/ibc/testchain.go @@ -158,7 +158,7 @@ func (chain *TestChain) commitBlock(suite *suite.Suite, res *abci.ResponseFinali // from ibctesting func SignAndDeliver( txCfg client.TxConfig, app *baseapp.BaseApp, msgs []sdk.Msg, - chainID string, accNums, accSeqs []uint64, expPass bool, blockTime time.Time, nextValHash []byte, priv ...cryptotypes.PrivKey, + chainID string, accNums, accSeqs []uint64, _ bool, blockTime time.Time, nextValHash []byte, priv ...cryptotypes.PrivKey, ) (*abci.ResponseFinalizeBlock, error) { // tb.Helper() tx, err := simtestutil.GenSignedMockTx( diff --git a/testutil/queries/generic.go b/testutil/queries/generic.go index c8a1cd927b..c38ab33112 100644 --- a/testutil/queries/generic.go +++ b/testutil/queries/generic.go @@ -53,7 +53,7 @@ func createQueryCmd[T proto.Message](n *network.Network, cmdName, url string, em Use: "generic-" + cmdName, Args: cobra.NoArgs, SilenceUsage: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/attribute/keeper/keeper.go b/x/attribute/keeper/keeper.go index 4808d8d77c..f1df26a9ec 100644 --- a/x/attribute/keeper/keeper.go +++ b/x/attribute/keeper/keeper.go @@ -101,14 +101,8 @@ func (k Keeper) IterateRecords(ctx sdk.Context, prefix []byte, handle Handler) e for ; iterator.Valid(); iterator.Next() { record := types.Attribute{} // get proto objects for legacy prefix with legacy amino codec. - if bytes.Equal(types.AttributeKeyPrefixAmino, prefix) { - if err := k.cdc.Unmarshal(iterator.Value(), &record); err != nil { - return err - } - } else { - if err := k.cdc.Unmarshal(iterator.Value(), &record); err != nil { - return err - } + if err := k.cdc.Unmarshal(iterator.Value(), &record); err != nil { + return err } if err := handle(record); err != nil { return err diff --git a/x/attribute/module.go b/x/attribute/module.go index 61b43bb8ef..52a8783ad9 100644 --- a/x/attribute/module.go +++ b/x/attribute/module.go @@ -162,12 +162,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns all the attribute content functions used to -// simulate attribute governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return simulation.ProposalContents(am.keeper) -} - // RandomizedParams creates randomized attribute param changes for the simulator. func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.LegacyParamChange { return simulation.ParamChanges(r) diff --git a/x/attribute/simulation/proposals.go b/x/attribute/simulation/proposals.go deleted file mode 100644 index e7f68ad0e7..0000000000 --- a/x/attribute/simulation/proposals.go +++ /dev/null @@ -1,12 +0,0 @@ -package simulation - -import ( - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - - "github.com/provenance-io/provenance/x/attribute/keeper" -) - -// ProposalContents defines the module weighted proposals' contents (none for attribute) -func ProposalContents(_ keeper.Keeper) []simtypes.WeightedProposalContent { - return []simtypes.WeightedProposalContent{} -} diff --git a/x/exchange/module/module.go b/x/exchange/module/module.go index 14ced0e1df..c4241ca095 100644 --- a/x/exchange/module/module.go +++ b/x/exchange/module/module.go @@ -134,12 +134,6 @@ func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns all the exchange content functions used to -// simulate governance proposals, of which there are none for the exchange module. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - // RandomizedParams returns randomized exchange param changes for the simulator, // of which there are none since this module doesn't use the params module. func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { return nil } diff --git a/x/exchange/simulation/decoder.go b/x/exchange/simulation/decoder.go index c89dc0dbc2..49728b7928 100644 --- a/x/exchange/simulation/decoder.go +++ b/x/exchange/simulation/decoder.go @@ -7,7 +7,7 @@ import ( // NewDecodeStore returns a new store decoder for the exchange state. func NewDecodeStore(_ codec.Codec) func(kvA, kvB kv.Pair) string { - return func(kvA, kvB kv.Pair) string { + return func(_, _ kv.Pair) string { // TODO[1658]: Write NewDecodeStore. return "not implemented" } diff --git a/x/hold/module/module.go b/x/hold/module/module.go index 64da569821..84abdf2ce4 100644 --- a/x/hold/module/module.go +++ b/x/hold/module/module.go @@ -133,12 +133,6 @@ func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns all the hold content functions used to -// simulate governance proposals, of which there are none for the hold module. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - // RandomizedParams returns randomized hold param changes for the simulator, // of which there are none since this module doesn't use the params module. func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { return nil } diff --git a/x/ibchooks/module.go b/x/ibchooks/module.go index 2aebeab425..5f89ce4627 100644 --- a/x/ibchooks/module.go +++ b/x/ibchooks/module.go @@ -45,7 +45,7 @@ func (AppModuleBasic) Name() string { } // RegisterLegacyAminoCodec registers the ibchooks module's types on the given LegacyAmino codec. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} // RegisterInterfaces registers the module's interface types func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { @@ -146,12 +146,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns all the name content functions used to -// simulate governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return []simtypes.WeightedProposalContent{} -} - // RandomizedParams creates randomized name param changes for the simulator. func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { return nil diff --git a/x/ibcratelimit/module/module.go b/x/ibcratelimit/module/module.go index 6e05a17163..52e7e9ab61 100644 --- a/x/ibcratelimit/module/module.go +++ b/x/ibcratelimit/module/module.go @@ -119,11 +119,6 @@ func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns content functions used to simulate governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - // RandomizedParams returns randomized module parameters for param change proposals. func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { return nil diff --git a/x/marker/types/key.go b/x/marker/types/key.go index c4bac08065..370ea0cac3 100644 --- a/x/marker/types/key.go +++ b/x/marker/types/key.go @@ -19,9 +19,6 @@ const ( // RouterKey to be used for routing msgs RouterKey = ModuleName - // QuerierRoute to be used for queries - QuerierRoute = ModuleName // TODO[1760]: marker: Delete this variable. - // CoinPoolName to be used for coin pool associated with mint/burn activities. CoinPoolName = ModuleName diff --git a/x/metadata/module.go b/x/metadata/module.go index d38e48aeea..d4ed3a2184 100644 --- a/x/metadata/module.go +++ b/x/metadata/module.go @@ -152,12 +152,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns all the metadata content functions used to -// simulate metadata governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return []simtypes.WeightedProposalContent{} // simulation.ProposalContents(am.keeper) -} - // RandomizedParams creates randomized metadata param changes for the simulator. func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { return nil diff --git a/x/metadata/types/address_test.go b/x/metadata/types/address_test.go index 249486ef34..5f0631c6ea 100644 --- a/x/metadata/types/address_test.go +++ b/x/metadata/types/address_test.go @@ -559,6 +559,7 @@ func (s *AddressTestSuite) TestMetadataAddressWithInvalidData() { scopeID := ScopeMetadataAddress(s.scopeUUID) padded := make([]byte, 20) length, err := scopeID.MarshalTo(padded) + require.NoError(t, err, "must marshal to metadata address") require.EqualValues(t, 17, length) _, err = VerifyMetadataAddressFormat(padded) @@ -721,7 +722,7 @@ func (s *AddressTestSuite) TestScopeMetadataAddress() { // Check the string formatter for the scopeID require.Equal(t, s.scopeBech32, fmt.Sprintf("%s", scopeID)) - require.Equal(t, fmt.Sprintf("%s", s.scopeHex), fmt.Sprintf("%X", scopeID)) + require.Equal(t, s.scopeHex, fmt.Sprintf("%X", scopeID)) // Ensure a second instance is equal to the first scopeID2 := ScopeMetadataAddress(s.scopeUUID) diff --git a/x/metadata/types/scope_test.go b/x/metadata/types/scope_test.go index 4f5d8ff5c0..edbfcaed1f 100644 --- a/x/metadata/types/scope_test.go +++ b/x/metadata/types/scope_test.go @@ -1063,7 +1063,7 @@ func (s *ScopeTestSuite) TestValidateOptionalParties() { } func (s *ScopeTestSuite) TestValidatePartiesAreUnique() { - oneCapParty := make([]Party, 1, 1) + oneCapParty := make([]Party, 1) oneCapParty[0] = Party{Address: "one", Role: 1} tests := []struct { diff --git a/x/metadata/types/specification_test.go b/x/metadata/types/specification_test.go index 49936b6100..fa8d4641d7 100644 --- a/x/metadata/types/specification_test.go +++ b/x/metadata/types/specification_test.go @@ -860,7 +860,7 @@ func (s *SpecificationTestSuite) TestDescriptionValidateBasic() { "", "", ), - fmt.Sprintf("description Name cannot be empty"), + "description Name cannot be empty", }, { "invalid name - too long", @@ -954,7 +954,7 @@ func (s *SpecificationTestSuite) TestDescriptionValidateBasic() { "www.test.com", "", ), - fmt.Sprintf("url WebsiteUrl must use the http, https, or data protocol"), + "url WebsiteUrl must use the http, https, or data protocol", }, { "valid website url - http", @@ -1046,7 +1046,7 @@ func (s *SpecificationTestSuite) TestDescriptionValidateBasic() { "", "www.test.com", ), - fmt.Sprintf("url IconUrl must use the http, https, or data protocol"), + "url IconUrl must use the http, https, or data protocol", }, { "valid icon url - http", diff --git a/x/msgfees/client/cli/tx.go b/x/msgfees/client/cli/tx.go index 7cd95a3088..8f81df5b14 100644 --- a/x/msgfees/client/cli/tx.go +++ b/x/msgfees/client/cli/tx.go @@ -91,7 +91,6 @@ $ %[1]s tx msgfees remove --msg-type=/provenance.metadata.v1.MsgWriteRecordReque if err := types.ValidateBips(recipient, bips); err != nil { return fmt.Errorf("error validating basis points args: %w", err) } - } var addFee sdk.Coin diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index 007fe3b387..d5882534e9 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -124,12 +124,6 @@ func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns content functions used to simulate governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - // currently no gov proposals exist - return nil -} - // RandomizedParams returns randomized module parameters for param change proposals. func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { // currently no module params exist diff --git a/x/quarantine/module/module.go b/x/quarantine/module/module.go index cc0bac33b8..ed424f5025 100644 --- a/x/quarantine/module/module.go +++ b/x/quarantine/module/module.go @@ -147,12 +147,6 @@ func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState, am.keeper.GetFundsHolder()) } -// ProposalContents returns all the quarantine content functions used to -// simulate governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - // RandomizedParams creates randomized quarantine param changes for the simulator. func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { return nil diff --git a/x/sanction/module/module.go b/x/sanction/module/module.go index 060c1b2df7..30e8b532d5 100644 --- a/x/sanction/module/module.go +++ b/x/sanction/module/module.go @@ -143,15 +143,6 @@ func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns all the sanction content functions used to -// simulate governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - // This is for stuff that uses the v1beta1 gov module's Content interface. - // This module use the v1 gov stuff, though, so there's nothing to do here. - // It's all handled in the WeightedOperations. - return nil -} - // RandomizedParams creates randomized sanction param changes for the simulator. func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { // While the x/sanction module does have "Params", it doesn't use the x/params module. diff --git a/x/trigger/module/module.go b/x/trigger/module/module.go index e56c59ed6e..c3f50e67c0 100644 --- a/x/trigger/module/module.go +++ b/x/trigger/module/module.go @@ -124,12 +124,6 @@ func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents returns content functions used to simulate governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - // currently no gov proposals exist - return nil -} - // RandomizedParams returns randomized module parameters for param change proposals. func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { // currently no module params exist