lint: add errchecks (#5316)

## Description

Work towards enabling errcheck

ref #5059
This commit is contained in:
Marko
2020-09-04 11:58:03 +00:00
committed by GitHub
parent 59ec3d91e4
commit b8d08b9ef4
43 changed files with 420 additions and 143 deletions
+1 -1
View File
@@ -6,6 +6,6 @@ import (
func Sha256(bytes []byte) []byte {
hasher := sha256.New()
hasher.Write(bytes)
hasher.Write(bytes) //nolint:errcheck // ignore error
return hasher.Sum(nil)
}
+3 -3
View File
@@ -80,13 +80,13 @@ func (op ValueOp) Run(args [][]byte) ([][]byte, error) {
}
value := args[0]
hasher := tmhash.New()
hasher.Write(value) // does not error
hasher.Write(value) //nolint: errcheck // does not error
vhash := hasher.Sum(nil)
bz := new(bytes.Buffer)
// Wrap <op.Key, vhash> to hash the KVPair.
encodeByteSlice(bz, op.key) // does not error
encodeByteSlice(bz, vhash) // does not error
encodeByteSlice(bz, op.key) //nolint: errcheck // does not error
encodeByteSlice(bz, vhash) //nolint: errcheck // does not error
kvhash := leafHash(bz.Bytes())
if !bytes.Equal(kvhash, op.Proof.LeafHash) {
+16 -4
View File
@@ -23,10 +23,22 @@ func TestRandom(t *testing.T) {
pl := mr.Intn(16384)
ad := make([]byte, al)
plaintext := make([]byte, pl)
cr.Read(key[:])
cr.Read(nonce[:])
cr.Read(ad)
cr.Read(plaintext)
_, err := cr.Read(key[:])
if err != nil {
t.Errorf("error on read: %w", err)
}
_, err = cr.Read(nonce[:])
if err != nil {
t.Errorf("error on read: %w", err)
}
_, err = cr.Read(ad)
if err != nil {
t.Errorf("error on read: %w", err)
}
_, err = cr.Read(plaintext)
if err != nil {
t.Errorf("error on read: %w", err)
}
aead, err := New(key[:])
if err != nil {