8000 Fix linting on `main` by sergio-mena · Pull Request #1531 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix linting on main #1531

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

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ linters-settings:
max-blank-identifiers: 3
golint:
min-confidence: 0
goconst:
ignore-tests: true
maligned:
suggest-new: true
misspell:
Expand Down
6 changes: 3 additions & 3 deletions crypto/merkle/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"

cmtrand "github.com/cometbft/cometbft/libs/rand"
. "github.com/cometbft/cometbft/libs/test"
"github.com/cometbft/cometbft/libs/test"

"github.com/cometbft/cometbft/crypto/tmhash"
)
Expand Down Expand Up @@ -92,11 +92,11 @@ func TestProof(t *testing.T) {
proof.Aunts = origAunts

// Mutating the itemHash should make it fail.
err = proof.Verify(rootHash, MutateByteSlice(item))
err = proof.Verify(rootHash, test.MutateByteSlice(item))
require.Error(t, err, "Expected verification to fail for mutated leaf hash")

// Mutating the rootHash should make it fail.
err = proof.Verify(MutateByteSlice(rootHash), item)
err = proof.Verify(test.MutateByteSlice(rootHash), item)
require.Error(t, err, "Expected verification to fail for mutated root hash")
}
}
Expand Down
3 changes: 1 addition & 2 deletions libs/protoio/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ func getSize(v interface{}) (int, bool) {
ProtoSize() (n int)
}); ok {
return sz.ProtoSize(), true
} else {
return 0, false
}
return 0, false
}

// byteReader wraps an io.Reader and implements io.ByteReader, required by
Expand Down
8 changes: 4 additions & 4 deletions p2p/netaddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func NewNetAddress(id ID, addr net.Addr) *NetAddress {
if !ok {
if flag.Lookup("test.v") == nil { // normal run
panic(fmt.Sprintf("Only TCPAddrs are supported. Got: %v", addr))
} else { // in testing
netAddr := NewNetAddressIPPort(net.IP("127.0.0.1"), 0)
netAddr.ID = id
return netAddr
}
// in testing
netAddr := NewNetAddressIPPort(net.IP("127.0.0.1"), 0)
netAddr.ID = id
return netAddr
}

if err := validateID(id); err != nil {
Expand Down
22 changes: 14 additions & 8 deletions state/indexer/sink/psql/psql.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ func insertEvents(dbtx *sql.Tx, blockID, txID uint32, evts []abci.Event) error {
txIDArg = txID
}

const (
insertEventQuery = `
INSERT INTO ` + tableEvents + ` (block_id, tx_id, type)
VALUES ($1, $2, $3)
RETURNING rowid;
`
insertAttributeQuery = `
INSERT INTO ` + tableAttributes + ` (event_id, key, composite_key, value)
VALUES ($1, $2, $3, $4);
`
)

// Add each event to the events table, and retrieve its row ID to use when
// adding any attributes the event provides.
for _, evt := range evts {
Expand All @@ -98,10 +110,7 @@ func insertEvents(dbtx *sql.Tx, blockID, txID uint32, evts []abci.Event) error {
continue
}

eid, err := queryWithID(dbtx, `
INSERT INTO `+tableEvents+` (block_id, tx_id, type) VALUES ($1, $2, $3)
RETURNING rowid;
`, blockID, txIDArg, evt.Type)
eid, err := queryWithID(dbtx, insertEventQuery, blockID, txIDArg, evt.Type)
if err != nil {
return err
}
Expand All @@ -112,10 +121,7 @@ INSERT INTO `+tableEvents+` (block_id, tx_id, type) VALUES ($1, $2, $3)
continue
}
compositeKey := evt.Type + "." + attr.Key
if _, err := dbtx.Exec(`
INSERT INTO `+tableAttributes+` (event_id, key, composite_key, value)
VALUES ($1, $2, $3, $4);
`, eid, attr.Key, compositeKey, attr.Value); err != nil {
if _, err := dbtx.Exec(insertAttributeQuery, eid, attr.Key, compositeKey, attr.Value); err != nil {
return err
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,11 @@ func (app *Application) ExtendVote(_ context.Context, req *abci.RequestExtendVot
extLen = len(ext)
} else {
ext = make([]byte, 8)
if num, err := rand.Int(rand.Reader, big.NewInt(voteExtensionMaxVal)); err != nil {
num, err := rand.Int(rand.Reader, big.NewInt(voteExtensionMaxVal))
if err != nil {
panic(fmt.Errorf("could not extend vote. Len:%d", len(ext)))
} else {
extLen = binary.PutVarint(ext, num.Int64())
}
extLen = binary.PutVarint(ext, num.Int64())
}

app.logger.Info("generated vote extension", "height", appHeight, "vote_extension", fmt.Sprintf("%x", ext[:4]), "len", extLen)
Expand Down
3 changes: 1 addition & 2 deletions types/vote_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,8 @@ func (voteSet *VoteSet) addVerifiedVote(
if existing := voteSet.votes[valIndex]; existing != nil {
if existing.BlockID.Equals(vote.BlockID) {
panic("addVerifiedVote does not expect duplicate votes")
} else {
conflicting = existing
}
conflicting = existing
// Replace vote if blockKey matches voteSet.maj23.
if voteSet.maj23 != nil && voteSet.maj23.Key() == blockKey {
voteSet.votes[valIndex] = vote
Expand Down
0