Skip to content

Commit

Permalink
fix: Lint fixes 047 (#2228)
Browse files Browse the repository at this point in the history
Co-authored-by: Pablo Estrada <[email protected]>
Co-authored-by: Jeancarlo Barrios <[email protected]>
  • Loading branch information
3 people authored Dec 17, 2024
1 parent bfc3cb6 commit 2c39b73
Show file tree
Hide file tree
Showing 105 changed files with 256 additions and 165 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ generate:

lint:
@echo "Linting all go modules..."
@find . -name 'go.mod' -type f -execdir golangci-lint run --out-format=tab \;
@find . -name 'go.mod' -type f | while read modfile; do \
moddir=$$(dirname "$$modfile"); \
echo "Linting module at $$moddir"; \
(cd "$$moddir" && golangci-lint run --out-format=tab); \
done

lint-fix: format
@echo "Attempting to fix lint errors in all go modules..."
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand Down
6 changes: 4 additions & 2 deletions app/simulation/app_after_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ package simulation

import (
"fmt"
"os"
"testing"

"github.com/cometbft/cometbft/libs/log"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/server"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"os"
"testing"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/stretchr/testify/require"
Expand Down
3 changes: 2 additions & 1 deletion app/simulation/app_determinism_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (

dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/baseapp"

simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"

Expand Down
12 changes: 7 additions & 5 deletions app/simulation/app_import_export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ package simulation
import (
"encoding/json"
"fmt"
"os"
"runtime/debug"
"strings"
"testing"

"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/server"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
Expand All @@ -30,11 +37,6 @@ import (
regen "github.com/regen-network/regen-ledger/v5/app"
"github.com/regen-network/regen-ledger/x/data/v3"
"github.com/regen-network/regen-ledger/x/ecocredit/v3"
"github.com/stretchr/testify/require"
"os"
"runtime/debug"
"strings"
"testing"
)

func TestAppImportExport(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion app/simulation/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"os"
"testing"

"github.com/stretchr/testify/require"

simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"
"github.com/stretchr/testify/require"

regen "github.com/regen-network/regen-ledger/v5/app"
)
Expand Down
5 changes: 3 additions & 2 deletions app/testsuite/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package testsuite

import (
"fmt"
"os"
"testing"

simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/v7/testing/simapp"
regenapp "github.com/regen-network/regen-ledger/v5/app"
"os"
"testing"

dbm "github.com/cometbft/cometbft-db"
"github.com/stretchr/testify/require"
Expand Down
3 changes: 2 additions & 1 deletion app/testsuite/modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package testsuite
import (
"testing"

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/testutil/network"

data "github.com/regen-network/regen-ledger/x/data/v3/client/testsuite"
ecocredit "github.com/regen-network/regen-ledger/x/ecocredit/v3/client/testsuite"
)
Expand Down
1 change: 1 addition & 0 deletions app/testsuite/network_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down
1 change: 1 addition & 0 deletions app/testsuite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/suite"

tmtypes "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down
3 changes: 2 additions & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"github.com/cometbft/cometbft/libs/log"

ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -72,7 +73,7 @@ func (app *RegenApp) registerUpgrade6_0(upgradeInfo upgradetypes.Plan) {
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())

app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
printPlanName(planName, ctx.Logger())

// Migrate CometBFT consensus parameters from x/params module to a dedicated x/consensus module.
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v5_0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Name = "v5.0"
var Upgrade = upgrades.Upgrade{
UpgradeName: Name,
CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// set regen module consensus version
fromVM[ecocredit.ModuleName] = 2
fromVM[data.ModuleName] = 1
Expand Down
1 change: 1 addition & 0 deletions app/upgrades/v5_0/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

abci "github.com/cometbft/cometbft/abci/types"

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/regen-network/regen-ledger/v5/app/testsuite"
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v5_1/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Name = "v5.1"
var Upgrade = upgrades.Upgrade{
UpgradeName: Name,
CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// run in-place store migrations for ecocredit module
return mm.RunMigrations(ctx, cfg, fromVM)
}
Expand Down
1 change: 1 addition & 0 deletions types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"

sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down
1 change: 1 addition & 0 deletions types/coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/assert"

basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/regen-network/regen-ledger/types/v2"
Expand Down
2 changes: 1 addition & 1 deletion types/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/golang/mock v1.6.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/regen-network/gocuke v1.1.0
github.com/regen-network/regen-ledger/api/v2 v2.0.0-00010101000000-000000000000
github.com/regen-network/regen-ledger/api/v2 v2.0.0
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.62.1
Expand Down
1 change: 1 addition & 0 deletions types/ormstore/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1"

"github.com/cosmos/cosmos-sdk/orm/model/ormdb"
"github.com/cosmos/cosmos-sdk/orm/model/ormtable"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand Down
1 change: 1 addition & 0 deletions types/ormstore/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1"

"github.com/cosmos/cosmos-sdk/orm/model/ormdb"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand Down
1 change: 1 addition & 0 deletions types/ormutil/compatability.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"google.golang.org/protobuf/proto"

queryv1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1"

"github.com/cosmos/cosmos-sdk/orm/model/ormlist"
"github.com/cosmos/cosmos-sdk/types/query"
)
Expand Down
1 change: 1 addition & 0 deletions types/ormutil/tm_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ormutil

import (
dbm "github.com/cometbft/cometbft-db"

"github.com/cosmos/cosmos-sdk/orm/types/kv"
// tdbm "github.com/tendermint/tm-db"
)
Expand Down
3 changes: 2 additions & 1 deletion types/testutil/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"fmt"

abci "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// MatchEvent matches the values in a proto message to a sdk.Event.
Expand Down
7 changes: 4 additions & 3 deletions types/testutil/fixture/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/regen-network/gocuke"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkmodules "github.com/cosmos/cosmos-sdk/types/module"
"github.com/regen-network/gocuke"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
)

type factoryImpl struct {
Expand Down
2 changes: 1 addition & 1 deletion x/data/client/testsuite/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (s *IntegrationTestSuite) TestRegisterResolverCmd() {
},
{
"invalid resolver id",
[]string{fmt.Sprintf("%s", "123a5"), filePath},
[]string{"123a5", filePath},
true,
false,
"invalid resolver id",
Expand Down
1 change: 1 addition & 0 deletions x/data/iri.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/cosmos/btcutil/base58"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

Expand Down
1 change: 1 addition & 0 deletions x/data/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package data

import (
ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1"

api "github.com/regen-network/regen-ledger/api/v2/regen/data/v1"
)

Expand Down
8 changes: 4 additions & 4 deletions x/data/msg_anchor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func (m *MsgAnchor) GetSigners() []sdk.AccAddress {
}

// LegacyMsg.Type implementations
func (msg MsgAnchor) Route() string { return "" }
func (msg MsgAnchor) Type() string { return sdk.MsgTypeURL(&msg) }
func (msg *MsgAnchor) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
func (m MsgAnchor) Route() string { return "" }
func (m MsgAnchor) Type() string { return sdk.MsgTypeURL(&m) }
func (m *MsgAnchor) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(m)
return sdk.MustSortJSON(bz)
}
8 changes: 4 additions & 4 deletions x/data/msg_attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func (m *MsgAttest) GetSigners() []sdk.AccAddress {
}

// LegacyMsg.Type implementations
func (msg MsgAttest) Route() string { return "" }
func (msg MsgAttest) Type() string { return sdk.MsgTypeURL(&msg) }
func (msg *MsgAttest) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
func (m MsgAttest) Route() string { return "" }
func (m MsgAttest) Type() string { return sdk.MsgTypeURL(&m) }
func (m *MsgAttest) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(m)
return sdk.MustSortJSON(bz)
}
8 changes: 4 additions & 4 deletions x/data/msg_define_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func (m *MsgDefineResolver) GetSigners() []sdk.AccAddress {
}

// LegacyMsg.Type implementations
func (msg MsgDefineResolver) Route() string { return "" }
func (msg MsgDefineResolver) Type() string { return sdk.MsgTypeURL(&msg) }
func (msg *MsgDefineResolver) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
func (m MsgDefineResolver) Route() string { return "" }
func (m MsgDefineResolver) Type() string { return sdk.MsgTypeURL(&m) }
func (m *MsgDefineResolver) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(m)
return sdk.MustSortJSON(bz)
}
3 changes: 2 additions & 1 deletion x/data/server/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package server
import (
"encoding/json"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/orm/types/ormjson"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/cometbft/cometbft/abci/types"
)

// InitGenesis performs genesis initialization for the data module. It
Expand Down
4 changes: 4 additions & 0 deletions x/data/server/hasher/hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package hasher

import (
"encoding/binary"
"fmt"
"hash"

"golang.org/x/crypto/blake2b"
Expand Down Expand Up @@ -95,6 +96,9 @@ func (t hasher) CreateID(value []byte, collisions int) (id []byte) {
id = append(id, hashBz[collisions])
} else {
id = id[:t.bufLen]
if collisions < 0 {
panic(fmt.Sprintf("collisions must be non-negative, got %d", collisions))
}
n := binary.PutUvarint(id[t.hashLen:], uint64(collisions))
id = id[:t.hashLen+n]
}
Expand Down
3 changes: 2 additions & 1 deletion x/data/server/hasher/hasher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/crypto/blake2b"

"github.com/cosmos/cosmos-sdk/store/mem"
"github.com/cometbft/cometbft/libs/rand"

"github.com/cosmos/cosmos-sdk/store/mem"
)

func TestHasher(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/data/server/query_anchor_by_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (s serverImpl) AnchorByHash(ctx context.Context, request *data.QueryAnchorB

anchor, err := s.stateStore.DataAnchorTable().Get(ctx, dataID.Id)
if err != nil {
return nil, regenerrors.ErrNotFound.Wrapf(err.Error())
return nil, regenerrors.ErrNotFound.Wrap(err.Error())
}

return &data.QueryAnchorByHashResponse{
Expand Down
3 changes: 2 additions & 1 deletion x/data/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package server
import (
"encoding/json"

"github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/orm/model/ormdb"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cometbft/cometbft/abci/types"

api "github.com/regen-network/regen-ledger/api/v2/regen/data/v1"
"github.com/regen-network/regen-ledger/types/v2/ormstore"
Expand Down
Loading

0 comments on commit 2c39b73

Please sign in to comment.