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

chore: lint tests #14268

Merged
merged 63 commits into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
11bda67
golangci-lint run ./... --fix
faddat Dec 12, 2022
a4f7f2a
Merge remote-tracking branch 'origin/main' into lint-tests
faddat Dec 13, 2022
3e5f32b
fix uneccessary conversions
faddat Dec 13, 2022
419368f
address unused
faddat Dec 13, 2022
7b65ee9
gocritic
faddat Dec 13, 2022
3b7cb34
receiver-naming
faddat Dec 13, 2022
0011196
increment-decrement
faddat Dec 13, 2022
b9ac5a2
simapp specific items
faddat Dec 13, 2022
9a3aa42
exported
faddat Dec 13, 2022
cf93019
Merge branch 'main' into lint-tests
faddat Dec 13, 2022
04a6636
ineffectual assignments
faddat Dec 13, 2022
b8c43ed
blank-imports
faddat Dec 13, 2022
de1d45f
Revert "exported"
faddat Dec 13, 2022
8ff6ecb
fix some errors caused in linting
faddat Dec 13, 2022
1ab5dc4
progress and test ci
faddat Dec 13, 2022
429700c
Revert "progress and test ci"
faddat Dec 13, 2022
b4edee8
Merge remote-tracking branch 'origin/main' into lint-tests
faddat Dec 13, 2022
d3c1073
check out upstream client folder
faddat Dec 13, 2022
8199b84
fixes
faddat Dec 13, 2022
1beb6a4
linting tests, assorted
faddat Dec 13, 2022
947637c
tests linted
faddat Dec 13, 2022
d499b5d
fully linted
faddat Dec 13, 2022
7fce225
responded to feedback
faddat Dec 13, 2022
91145af
Merge remote-tracking branch 'origin/main' into lint-tests
faddat Dec 13, 2022
17f7648
remove unused variables in x/evidence/keeper/keeper_test.go
faddat Dec 13, 2022
7ebdd09
Update x/gov/module.go
faddat Dec 13, 2022
4a8dc19
V45_SetAccount
faddat Dec 13, 2022
e55d7ea
Merge branch 'lint-tests' of https://github.com/faddat/basecoin into …
faddat Dec 13, 2022
0c02349
gov defaultConfig
faddat Dec 13, 2022
40f2b50
Merge branch 'main' into lint-tests
faddat Dec 15, 2022
af63b62
revert changes to app wiring naming
faddat Dec 15, 2022
0ab8d58
fix gov v3 migration
faddat Dec 15, 2022
25e7c46
remove the uneccesary space
faddat Dec 15, 2022
2b8cb8d
ease -> app wiring
faddat Dec 15, 2022
3da992c
//nolint:revive for BankOutputs
faddat Dec 15, 2022
2db8332
Merge branch 'main' into lint-tests
faddat Dec 15, 2022
a6a28ed
Update x/bank/keeper/send.go
faddat Dec 15, 2022
3e6a08e
Merge branch 'main' into lint-tests
faddat Dec 15, 2022
a17a776
use authtypes when referring to auth because we are in bank
faddat Dec 15, 2022
3824be2
Merge branch 'lint-tests' of https://github.com/faddat/basecoin into …
faddat Dec 15, 2022
498ec00
Merge branch 'main' into lint-tests
faddat Dec 15, 2022
5837ab7
fix the swagger statik client
faddat Dec 15, 2022
96ba312
lint run
faddat Dec 15, 2022
e213ce4
remove tagging for deadcode in distribution
faddat Dec 15, 2022
f706455
don't label group orm tests unused and remove everything actually unused
faddat Dec 15, 2022
dc1c445
Merge branch 'main' into lint-tests
faddat Dec 15, 2022
ccca5ea
remove unused
faddat Dec 15, 2022
e77b02c
Merge branch 'lint-tests' of https://github.com/faddat/basecoin into …
faddat Dec 15, 2022
4374c84
bet it passes now
faddat Dec 15, 2022
39975c1
Merge branch 'main' into lint-tests
faddat Dec 15, 2022
b533dc1
Merge branch 'main' into lint-tests
faddat Dec 16, 2022
093aaa3
Merge branch 'main' into lint-tests
faddat Dec 16, 2022
803a659
Merge branch 'main' into lint-tests
faddat Dec 16, 2022
344af2d
revert all changes to x/group
faddat Dec 16, 2022
850742f
Merge branch 'main' into lint-tests
faddat Dec 17, 2022
46059f2
re-clean group
faddat Dec 17, 2022
e82645a
fully linted
faddat Dec 17, 2022
5b0fb22
orm
faddat Dec 18, 2022
d78979a
lint orm
faddat Dec 18, 2022
ee4055b
revert changes to index property test
faddat Dec 18, 2022
f14d03a
ignore gocritic ifElseChain
faddat Dec 18, 2022
0757c05
Update x/group/module/module.go
faddat Dec 18, 2022
699e9c8
address comments
faddat Dec 18, 2022
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
9 changes: 8 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
run:
tests: false
tests: true
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
sort-results: true
allow-parallel-runners: true
exclude-dir: testutil/testdata_pulsar

linters:
disable-all: true
Expand All @@ -20,6 +23,7 @@ linters:
- nakedret
- nolintlint
- staticcheck
- revive
faddat marked this conversation as resolved.
Show resolved Hide resolved
- stylecheck
- typecheck
- unconvert
Expand All @@ -42,6 +46,9 @@ issues:
text: "SA1019:"
linters:
- staticcheck
- text: "leading space"
linters:
- nolintlint

max-issues-per-linter: 10000
max-same-issues: 10000
Expand Down
4 changes: 2 additions & 2 deletions api/cosmos/distribution/v1beta1/query_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func createTestTx(txConfig client.TxConfig, txBuilder client.TxBuilder, privs []
Sequence: accSeqs[i],
}
sigV2, err := tx.SignWithPrivKey(
nil, txConfig.SignModeHandler().DefaultMode(), signerData,
nil, txConfig.SignModeHandler().DefaultMode(), signerData, //nolint:staticcheck
txBuilder, priv, txConfig, accSeqs[i])
if err != nil {
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion baseapp/msg_service_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestMsgService(t *testing.T) {
Sequence: 0,
}
sigV2, err = tx.SignWithPrivKey(
nil, txConfig.SignModeHandler().DefaultMode(), signerData,
nil, txConfig.SignModeHandler().DefaultMode(), signerData, //nolint:staticcheck // SA1019: txConfig.SignModeHandler().DefaultMode() is deprecated: use txConfig.SignModeHandler().DefaultMode() instead.
txBuilder, priv, txConfig, 0)
require.NoError(t, err)
err = txBuilder.SetSignatures(sigV2)
Expand Down
4 changes: 1 addition & 3 deletions baseapp/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)

var (
ParamStoreKey = []byte("paramstore")
)
var ParamStoreKey = []byte("paramstore")

func defaultLogger() log.Logger {
if testing.Verbose() {
Expand Down
4 changes: 2 additions & 2 deletions client/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
// initClientContext initiates client Context for tests
func initClientContext(t *testing.T, envVar string) (client.Context, func()) {
home := t.TempDir()
chainId := "test-chain"
chainId := "test-chain" //nolint:revive
clientCtx := client.Context{}.
WithHomeDir(home).
WithViper("").
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestConfigCmd(t *testing.T) {
_, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
require.NoError(t, err)

//./build/simd config node //http://localhost:1
// ./build/simd config node //http://localhost:1
b := bytes.NewBufferString("")
cmd.SetOut(b)
cmd.SetArgs([]string{"node"})
Expand Down
4 changes: 2 additions & 2 deletions client/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestContext_PrintProto(t *testing.T) {
// json
buf := &bytes.Buffer{}
ctx = ctx.WithOutput(buf)
ctx.OutputFormat = "json"
ctx.OutputFormat = "json" //nolint:goconst
err = ctx.PrintProto(hasAnimal)
require.NoError(t, err)
require.Equal(t,
Expand All @@ -56,7 +56,7 @@ func TestContext_PrintProto(t *testing.T) {
// yaml
buf = &bytes.Buffer{}
ctx = ctx.WithOutput(buf)
ctx.OutputFormat = "text"
ctx.OutputFormat = "text" //nolint:goconst
err = ctx.PrintProto(hasAnimal)
require.NoError(t, err)
require.Equal(t,
Expand Down
5 changes: 2 additions & 3 deletions client/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

type IntegrationTestSuite struct {
Expand Down Expand Up @@ -65,7 +64,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.genesisAccountBalance = 100000000000000
senderPrivKey := secp256k1.GenPrivKey()
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0)
balance := banktypes.Balance{
balance := types.Balance{
Address: acc.GetAddress().String(),
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(s.genesisAccountBalance))),
}
Expand Down Expand Up @@ -120,7 +119,7 @@ func (s *IntegrationTestSuite) TestGRPCQuery() {
var header metadata.MD
res, err := s.bankClient.Balance(
context.Background(),
&banktypes.QueryBalanceRequest{Address: s.genesisAccount.GetAddress().String(), Denom: denom},
&types.QueryBalanceRequest{Address: s.genesisAccount.GetAddress().String(), Denom: denom},
grpc.Header(&header), // Also fetch grpc header
)
s.Require().NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion client/keys/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO
t.Cleanup(cleanupKeys(t, kb, "keyname1"))

keyfile := filepath.Join(kbHome, "key.asc")
require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0o644))
require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0o644)) //nolint:gosec

defer func() {
_ = os.RemoveAll(kbHome)
Expand Down
3 changes: 2 additions & 1 deletion client/keys/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package keys

import (
"fmt"
"testing"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"testing"

"github.com/stretchr/testify/require"

Expand Down
4 changes: 2 additions & 2 deletions client/pruning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (

const FlagAppDBBackend = "app-db-backend"

// PruningCmd prunes the sdk root multi store history versions based on the pruning options
// Cmd prunes the sdk root multi store history versions based on the pruning options
// specified by command flags.
func PruningCmd(appCreator servertypes.AppCreator) *cobra.Command {
func Cmd(appCreator servertypes.AppCreator) *cobra.Command {
cmd := &cobra.Command{
Use: "prune",
Short: "Prune app history states by keeping the recent heights and deleting old heights",
Expand Down
2 changes: 1 addition & 1 deletion client/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"cosmossdk.io/core/appconfig"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/codec"
_ "github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/runtime" // Register runtime module
)

var TestConfig = appconfig.Compose(&appv1alpha1.Config{
Expand Down
1 change: 0 additions & 1 deletion client/tx/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func buildTestTx(t *testing.T, builder client.TxBuilder) {

type TestSuite struct {
suite.Suite
codec codec.Codec
amino *codec.LegacyAmino
protoCfg client.TxConfig
aminoCfg client.TxConfig
Expand Down
5 changes: 3 additions & 2 deletions client/tx/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func TestSign(t *testing.T) {
var prevSigs []signingtypes.SignatureV2
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err = tx.Sign(nil, tc.txf, tc.from, tc.txb, tc.overwrite)
err = tx.Sign(nil, tc.txf, tc.from, tc.txb, tc.overwrite) //nolint:staticcheck
if len(tc.expectedPKs) == 0 {
requireT.Error(err)
} else {
Expand Down Expand Up @@ -422,8 +422,9 @@ func TestPreprocessHook(t *testing.T) {
msg1 := banktypes.NewMsgSend(addr1, sdk.AccAddress("to"), nil)
msg2 := banktypes.NewMsgSend(addr2, sdk.AccAddress("to"), nil)
txb, err := txfDirect.BuildUnsignedTx(msg1, msg2)
requireT.NoError(err)

err = tx.Sign(nil, txfDirect, from, txb, false)
err = tx.Sign(nil, txfDirect, from, txb, false) //nolint:staticcheck
requireT.NoError(err)

// Run preprocessing
Expand Down
11 changes: 5 additions & 6 deletions codec/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import (
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func NewTestInterfaceRegistry() types.InterfaceRegistry {
registry := types.NewInterfaceRegistry()
func NewTestInterfaceRegistry() codectypes.InterfaceRegistry {
registry := codectypes.NewInterfaceRegistry()
registry.RegisterInterface("Animal", (*testdata.Animal)(nil))
registry.RegisterImplementations(
(*testdata.Animal)(nil),
Expand All @@ -26,10 +25,10 @@ func NewTestInterfaceRegistry() types.InterfaceRegistry {
}

func TestMarshalAny(t *testing.T) {
catRegistry := types.NewInterfaceRegistry()
catRegistry := codectypes.NewInterfaceRegistry()
catRegistry.RegisterImplementations((*testdata.Animal)(nil), &testdata.Cat{})

registry := types.NewInterfaceRegistry()
registry := codectypes.NewInterfaceRegistry()

cdc := codec.NewProtoCodec(registry)

Expand Down Expand Up @@ -65,7 +64,7 @@ func TestMarshalAny(t *testing.T) {
require.Equal(t, kitty, animal)

// nil should fail
registry = NewTestInterfaceRegistry()
_ = NewTestInterfaceRegistry()
err = cdc.UnmarshalInterface(catBz, nil)
require.Error(t, err)
}
Expand Down
2 changes: 1 addition & 1 deletion codec/proto_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestProtoCodecMarshal(t *testing.T) {
err = cdc.UnmarshalInterface(bz, &animal)
require.NoError(t, err)

bz, err = cdc.MarshalInterface(bird)
_, err = cdc.MarshalInterface(bird)
require.ErrorContains(t, err, "does not have a registered interface")

bz, err = cartoonCdc.MarshalInterface(bird)
Expand Down
1 change: 1 addition & 0 deletions codec/types/any.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// nolint
package types

import (
Expand Down
2 changes: 1 addition & 1 deletion codec/types/any_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (d Dog) Greet() string { return d.Name }
func (d *Dog) Reset() { d.Name = "" }
func (d *Dog) String() string { return d.Name }
func (d *Dog) ProtoMessage() {}
func (d *Dog) XXX_MessageName() string { return "tests/dog" }
func (d *Dog) XXX_MessageName() string { return "tests/dog" } //nolint:revive

type Animal interface {
Greet() string
Expand Down
2 changes: 1 addition & 1 deletion codec/types/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _ proto.Message = (*errOnMarshal)(nil)

var errAlways = fmt.Errorf("always erroring")

func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { //nolint:revive
return nil, errAlways
}

Expand Down
2 changes: 1 addition & 1 deletion codec/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
func (dog FakeDog) Reset() {}
func (dog FakeDog) String() string { return "fakedog" }
func (dog FakeDog) ProtoMessage() {}
func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) }
func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) } //nolint:revive
func (dog FakeDog) Greet() string { return "fakedog" }

func TestRegister(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion crypto/hd/fundraiser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestFundraiserCompatibility(t *testing.T) {

require.Equal(t, seedB, seed)
require.Equal(t, master[:], masterB, fmt.Sprintf("Expected masters to match for %d", i))
require.Equal(t, priv[:], privB, "Expected priv keys to match")
require.Equal(t, priv, privB, "Expected priv keys to match")
pubBFixed := make([]byte, secp256k1.PubKeySize)
copy(pubBFixed, pubB)
require.Equal(t, pub, &secp256k1.PubKey{Key: pubBFixed}, fmt.Sprintf("Expected pub keys to match for %d", i))
Expand Down
20 changes: 10 additions & 10 deletions crypto/hd/hdpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestDeriveHDPathRange(t *testing.T) {
}
}

func ExampleStringifyPathParams() {
func ExampleStringifyPathParams() { //nolint:govet
path := hd.NewParams(44, 0, 0, false, 0)
fmt.Println(path.String())
path = hd.NewParams(44, 33, 7, true, 9)
Expand All @@ -195,7 +195,7 @@ func ExampleStringifyPathParams() {
// m/44'/33'/7'/1/9
}

func ExampleSomeBIP32TestVecs() {
func ExampleSomeBIP32TestVecs() { //nolint:govet
seed := mnemonicToSeed("barrel original fuel morning among eternal " +
"filter ball stove pluck matrix mechanic")
master, ch := hd.ComputeMastersFromSeed(seed)
Expand All @@ -206,34 +206,34 @@ func ExampleSomeBIP32TestVecs() {
if err != nil {
fmt.Println("INVALID")
} else {
fmt.Println(hex.EncodeToString(priv[:]))
fmt.Println(hex.EncodeToString(priv))
}
// bitcoin
priv, err = hd.DerivePrivateKeyForPath(master, ch, "44'/0'/0'/0/0")
if err != nil {
fmt.Println("INVALID")
} else {
fmt.Println(hex.EncodeToString(priv[:]))
fmt.Println(hex.EncodeToString(priv))
}
// ether
priv, err = hd.DerivePrivateKeyForPath(master, ch, "44'/60'/0'/0/0")
if err != nil {
fmt.Println("INVALID")
} else {
fmt.Println(hex.EncodeToString(priv[:]))
fmt.Println(hex.EncodeToString(priv))
}
// INVALID
priv, err = hd.DerivePrivateKeyForPath(master, ch, "X/0'/0'/0/0")
if err != nil {
fmt.Println("INVALID")
} else {
fmt.Println(hex.EncodeToString(priv[:]))
fmt.Println(hex.EncodeToString(priv))
}
priv, err = hd.DerivePrivateKeyForPath(master, ch, "-44/0'/0'/0/0")
if err != nil {
fmt.Println("INVALID")
} else {
fmt.Println(hex.EncodeToString(priv[:]))
fmt.Println(hex.EncodeToString(priv))
}

fmt.Println()
Expand All @@ -245,13 +245,13 @@ func ExampleSomeBIP32TestVecs() {
"gorilla ranch hour rival razor call lunar mention taste vacant woman sister")
master, ch = hd.ComputeMastersFromSeed(seed)
priv, _ = hd.DerivePrivateKeyForPath(master, ch, "44'/1'/1'/0/4")
fmt.Println(hex.EncodeToString(priv[:]))
fmt.Println(hex.EncodeToString(priv))

seed = mnemonicToSeed("idea naive region square margin day captain habit " +
"gun second farm pact pulse someone armed")
master, ch = hd.ComputeMastersFromSeed(seed)
priv, _ = hd.DerivePrivateKeyForPath(master, ch, "44'/0'/0'/0/420")
fmt.Println(hex.EncodeToString(priv[:]))
fmt.Println(hex.EncodeToString(priv))

fmt.Println()
fmt.Println("BIP 32 example")
Expand All @@ -261,7 +261,7 @@ func ExampleSomeBIP32TestVecs() {
seed = mnemonicToSeed("monitor flock loyal sick object grunt duty ride develop assault harsh history")
master, ch = hd.ComputeMastersFromSeed(seed)
priv, _ = hd.DerivePrivateKeyForPath(master, ch, "0/7")
fmt.Println(hex.EncodeToString(priv[:]))
fmt.Println(hex.EncodeToString(priv))

// Output: keys from fundraiser test-vector (cosmos, bitcoin, ether)
//
Expand Down
Loading