all: more linters (#24783)

This enables the following linters

- typecheck
- unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- gosec

WIth a few exceptions.

- We use a deprecated protobuf in trezor. I didn't want to mess with that, since I cannot meaningfully test any changes there.
- The deprecated TypeMux is used in a few places still, so the warning for it is silenced for now.
- Using string type in context.WithValue is apparently wrong, one should use a custom type, to prevent collisions between different places in the hierarchy of callers. That should be fixed at some point, but may require some attention.
- The warnings for using weak random generator are squashed, since we use a lot of random without need for cryptographic guarantees.
This commit is contained in:
Martin Holst Swende
2022-06-13 16:24:45 +02:00
committed by GitHub
parent eb94896270
commit a907d7e81a
67 changed files with 156 additions and 423 deletions
+2
View File
@@ -302,6 +302,7 @@ func appendUint64(b []byte, x uint64) []byte {
return append(b, a[:]...)
}
//nolint:unused,deadcode
func appendUint32(b []byte, x uint32) []byte {
var a [4]byte
binary.BigEndian.PutUint32(a[:], x)
@@ -313,6 +314,7 @@ func consumeUint64(b []byte) ([]byte, uint64) {
return b[8:], x
}
//nolint:unused,deadcode
func consumeUint32(b []byte) ([]byte, uint32) {
x := binary.BigEndian.Uint32(b)
return b[4:], x
+1
View File
@@ -25,6 +25,7 @@ var precomputed = [10][16]byte{
{10, 8, 7, 1, 2, 4, 6, 5, 15, 9, 3, 13, 11, 14, 12, 0},
}
// nolint:unused,deadcode
func hashBlocksGeneric(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
var m [16]uint64
c0, c1 := c[0], c[1]
-8
View File
@@ -14,14 +14,6 @@ import (
"testing"
)
func fromHex(s string) []byte {
b, err := hex.DecodeString(s)
if err != nil {
panic(err)
}
return b
}
func TestHashes(t *testing.T) {
defer func(sse4, avx, avx2 bool) {
useSSE4, useAVX, useAVX2 = sse4, avx, avx2
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"golang.org/x/sys/cpu"
)
//nolint:varcheck
//nolint:varcheck,unused,deadcode
var hasBMI2 = cpu.X86.HasBMI2
// go:noescape