Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a lot of linting issues. #1982

Merged
merged 7 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -119,6 +120,8 @@ linters-settings:

- github.com/cosmos/gogoproto

- github.com/golang/protobuf/proto

- github.com/google/uuid

- github.com/gorilla/mux
Expand Down Expand Up @@ -155,6 +158,8 @@ linters-settings:
- github.com/cometbft/cometbft-db

- github.com/rs/zerolog

- sigs.k8s.io/yaml
test:
files:
- "$test"
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions cmd/provenanced/cmd/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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"
Expand Down Expand Up @@ -609,7 +610,7 @@
return err
}

_, ok := msg.(sdk.Msg)

Check failure on line 613 in cmd/provenanced/cmd/genesis.go

View workflow job for this annotation

GitHub Actions / golangci-lint

S1040: type assertion to the same type: msg already has type sdk.Msg (gosimple)
if !ok {
return fmt.Errorf("message type is not a sdk message: %v", msgTypeURL)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/provenanced/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 3 additions & 7 deletions internal/handlers/msg_service_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions testutil/cli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
sdkcli "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"

Taztingo marked this conversation as resolved.
Show resolved Hide resolved
"github.com/provenance-io/provenance/testutil/assertions"
"github.com/provenance-io/provenance/testutil/queries"
)
Expand All @@ -26,7 +27,7 @@
//
// The result code and raw log are only checked if a Tx result is available.
// It's considered a failure if the command did not return an error, but the Tx result is not available.
type CLITxExecutor struct {

Check failure on line 30 in testutil/cli/exec.go

View workflow job for this annotation

GitHub Actions / golangci-lint

exported: type name will be used as cli.CLITxExecutor by other packages, and that stutters; consider calling this TxExecutor (revive)
// Name is the name of the test. It's not actually used in here, but included
// in case you want to use []CLITxExecutor to define your test cases.
Name string
Expand Down
2 changes: 1 addition & 1 deletion testutil/ibc/testchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion testutil/queries/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions x/attribute/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions x/attribute/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions x/attribute/simulation/proposals.go

This file was deleted.

6 changes: 0 additions & 6 deletions x/exchange/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion x/exchange/simulation/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Taztingo marked this conversation as resolved.
Show resolved Hide resolved
// TODO[1658]: Write NewDecodeStore.
return "not implemented"
}
Expand Down
6 changes: 0 additions & 6 deletions x/hold/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
8 changes: 1 addition & 7 deletions x/ibchooks/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions x/ibcratelimit/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions x/marker/types/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions x/metadata/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion x/metadata/types/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Taztingo marked this conversation as resolved.
Show resolved Hide resolved
require.EqualValues(t, 17, length)

_, err = VerifyMetadataAddressFormat(padded)
Expand Down Expand Up @@ -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))
Taztingo marked this conversation as resolved.
Show resolved Hide resolved

// Ensure a second instance is equal to the first
scopeID2 := ScopeMetadataAddress(s.scopeUUID)
Expand Down
2 changes: 1 addition & 1 deletion x/metadata/types/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions x/metadata/types/specification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ func (s *SpecificationTestSuite) TestDescriptionValidateBasic() {
"",
"",
),
fmt.Sprintf("description Name cannot be empty"),
"description Name cannot be empty",
},
{
"invalid name - too long",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion x/msgfees/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions x/oracle/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions x/quarantine/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions x/sanction/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions x/trigger/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading