Skip to content

Commit

Permalink
chore: refactor code quality issues (cosmos#8932)
Browse files Browse the repository at this point in the history
Co-authored-by: Amaury <[email protected]>
Co-authored-by: Alessio Treglia <[email protected]>
Co-authored-by: Marko <[email protected]>
  • Loading branch information
4 people authored Mar 22, 2021
1 parent 5bd93bf commit 7b1d80e
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 13 deletions.
20 changes: 20 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version = 1

test_patterns = [
"tests/**",
"**_test.go"
]

exclude_patterns = [
"third_party/proto/**",
"testutil/**",
"proto/cosmos/**",
"contrib/**"
]

[[analyzers]]
name = "go"
enabled = true

[analyzers.meta]
import_paths = ["github.com/cosmos/cosmos-sdk"]
8 changes: 4 additions & 4 deletions client/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestContext_PrintObject(t *testing.T) {
require.NoError(t, err)
require.Equal(t,
`{"animal":{"@type":"/testdata.Dog","size":"big","name":"Spot"},"x":"10"}
`, string(buf.Bytes()))
`, buf.String())

// yaml
buf = &bytes.Buffer{}
Expand All @@ -65,7 +65,7 @@ func TestContext_PrintObject(t *testing.T) {
name: Spot
size: big
x: "10"
`, string(buf.Bytes()))
`, buf.String())

//
// amino
Expand All @@ -81,7 +81,7 @@ x: "10"
require.NoError(t, err)
require.Equal(t,
`{"type":"testdata/HasAnimal","value":{"animal":{"type":"testdata/Dog","value":{"size":"big","name":"Spot"}},"x":"10"}}
`, string(buf.Bytes()))
`, buf.String())

// yaml
buf = &bytes.Buffer{}
Expand All @@ -98,7 +98,7 @@ value:
name: Spot
size: big
x: "10"
`, string(buf.Bytes()))
`, buf.String())
}

func TestCLIQueryConn(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions x/auth/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,7 @@ func generatePubKeysAndSignatures(n int, msg []byte, _ bool) (pubkeys []cryptoty
pubkeys = make([]cryptotypes.PubKey, n)
signatures = make([][]byte, n)
for i := 0; i < n; i++ {
var privkey cryptotypes.PrivKey
privkey = secp256k1.GenPrivKey()
var privkey cryptotypes.PrivKey = secp256k1.GenPrivKey()

// TODO: also generate ed25519 keys as below when ed25519 keys are
// actually supported, https://github.com/cosmos/cosmos-sdk/issues/4789
Expand Down
2 changes: 1 addition & 1 deletion x/auth/client/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *IntegrationTestSuite) TestEncodeDecode() {
err = cdc.UnmarshalJSON(res, &encodeResp)
require.NoError(err)

bz, err = cdc.MarshalJSON(authrest.DecodeReq{Tx: encodeResp.Tx})
bz, err = cdc.MarshalJSON(authrest.DecodeReq(encodeResp))
require.NoError(err)

res, err = rest.PostRequest(fmt.Sprintf("%s/txs/decode", val.APIAddress), "application/json", bz)
Expand Down
3 changes: 1 addition & 2 deletions x/auth/tx/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func TestTxBuilder(t *testing.T) {
Sequence: accSeq,
})

var sig signing.SignatureV2
sig = signing.SignatureV2{
var sig signing.SignatureV2 = signing.SignatureV2{
PubKey: pubkey,
Data: &signing.SingleSignatureData{
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/legacy/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestStoreMigration(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if bytes.Compare(tc.oldKey, tc.newKey) != 0 {
if !bytes.Equal(tc.oldKey, tc.newKey) {
require.Nil(t, store.Get(tc.oldKey))
}
require.Equal(t, value, store.Get(tc.newKey))
Expand Down
2 changes: 1 addition & 1 deletion x/gov/legacy/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestStoreMigration(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if bytes.Compare(tc.oldKey, tc.newKey) != 0 {
if !bytes.Equal(tc.oldKey, tc.newKey) {
require.Nil(t, store.Get(tc.oldKey))
}
require.Equal(t, tc.newValue, store.Get(tc.newKey))
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/legacy/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestStoreMigration(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if bytes.Compare(tc.oldKey, tc.newKey) != 0 {
if !bytes.Equal(tc.oldKey, tc.newKey) {
require.Nil(t, store.Get(tc.oldKey))
}
require.Equal(t, value, store.Get(tc.newKey))
Expand Down
2 changes: 1 addition & 1 deletion x/staking/legacy/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestStoreMigration(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if bytes.Compare(tc.oldKey, tc.newKey) != 0 {
if !bytes.Equal(tc.oldKey, tc.newKey) {
require.Nil(t, store.Get(tc.oldKey))
}
require.Equal(t, value, store.Get(tc.newKey))
Expand Down

0 comments on commit 7b1d80e

Please sign in to comment.