build: clean linter warnings

This commit is contained in:
David Hill 2020-05-13 08:58:39 -04:00
parent bc8d63bf15
commit f7399e6157
12 changed files with 21 additions and 27 deletions

View file

@ -63,7 +63,7 @@ func TestCalcWork(t *testing.T) {
} }
for x, test := range tests { for x, test := range tests {
bits := uint32(test.in) bits := test.in
r := CalcWork(bits) r := CalcWork(bits)
if r.Int64() != test.out { if r.Int64() != test.out {

View file

@ -68,7 +68,7 @@ func (b *addrIndexBucket) printLevels(addrKey [addrKeySize]byte) string {
if !bytes.Equal(k[:levelOffset], addrKey[:]) { if !bytes.Equal(k[:levelOffset], addrKey[:]) {
continue continue
} }
level := uint8(k[levelOffset]) level := k[levelOffset]
if level > highestLevel { if level > highestLevel {
highestLevel = level highestLevel = level
} }
@ -105,7 +105,7 @@ func (b *addrIndexBucket) sanityCheck(addrKey [addrKeySize]byte, expectedTotal i
if !bytes.Equal(k[:levelOffset], addrKey[:]) { if !bytes.Equal(k[:levelOffset], addrKey[:]) {
continue continue
} }
level := uint8(k[levelOffset]) level := k[levelOffset]
if level > highestLevel { if level > highestLevel {
highestLevel = level highestLevel = level
} }

View file

@ -232,11 +232,11 @@ func TestPubKeys(t *testing.T) {
var pkStr []byte var pkStr []byte
switch test.format { switch test.format {
case pubkeyUncompressed: case pubkeyUncompressed:
pkStr = (*PublicKey)(pk).SerializeUncompressed() pkStr = pk.SerializeUncompressed()
case pubkeyCompressed: case pubkeyCompressed:
pkStr = (*PublicKey)(pk).SerializeCompressed() pkStr = pk.SerializeCompressed()
case pubkeyHybrid: case pubkeyHybrid:
pkStr = (*PublicKey)(pk).SerializeHybrid() pkStr = pk.SerializeHybrid()
} }
if !bytes.Equal(test.key, pkStr) { if !bytes.Equal(test.key, pkStr) {
t.Errorf("%s pubkey: serialized keys do not match.", t.Errorf("%s pubkey: serialized keys do not match.",

View file

@ -464,8 +464,7 @@ func TestSignatureSerialize(t *testing.T) {
func testSignCompact(t *testing.T, tag string, curve *KoblitzCurve, func testSignCompact(t *testing.T, tag string, curve *KoblitzCurve,
data []byte, isCompressed bool) { data []byte, isCompressed bool) {
tmp, _ := NewPrivateKey(curve) priv, _ := NewPrivateKey(curve)
priv := (*PrivateKey)(tmp)
hashed := []byte("testing") hashed := []byte("testing")
sig, err := SignCompact(curve, priv, hashed, isCompressed) sig, err := SignCompact(curve, priv, hashed, isCompressed)

View file

@ -287,6 +287,6 @@ func RegisteredCmdMethods() []string {
methods = append(methods, k) methods = append(methods, k)
} }
sort.Sort(sort.StringSlice(methods)) sort.Strings(methods)
return methods return methods
} }

View file

@ -256,7 +256,7 @@ func TestRegisteredCmdMethods(t *testing.T) {
// Ensure the returned methods are sorted. // Ensure the returned methods are sorted.
sortedMethods := make([]string, len(methods)) sortedMethods := make([]string, len(methods))
copy(sortedMethods, methods) copy(sortedMethods, methods)
sort.Sort(sort.StringSlice(sortedMethods)) sort.Strings(sortedMethods)
if !reflect.DeepEqual(sortedMethods, methods) { if !reflect.DeepEqual(sortedMethods, methods) {
t.Fatal("RegisteredCmdMethods: methods are not sorted") t.Fatal("RegisteredCmdMethods: methods are not sorted")
} }

View file

@ -643,9 +643,9 @@ func TestFailureScenarios(t *testing.T) {
// context. // context.
maxSize := int64(-1) maxSize := int64(-1)
if maxFileSize, ok := tc.maxFileSizes[fileNum]; ok { if maxFileSize, ok := tc.maxFileSizes[fileNum]; ok {
maxSize = int64(maxFileSize) maxSize = maxFileSize
} }
file := &mockFile{maxSize: int64(maxSize)} file := &mockFile{maxSize: maxSize}
tc.files[fileNum] = &lockableFile{file: file} tc.files[fileNum] = &lockableFile{file: file}
return file, nil return file, nil
} }

View file

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
# The script does automatic checking on a Go package and its sub-packages, including: # The script does automatic checking on a Go package and its sub-packages, including:
# 1. gofmt (http://golang.org/cmd/gofmt/) # 1. gofmt (http://golang.org/cmd/gofmt/)
# 2. golint (https://github.com/golang/lint)
# 3. go vet (http://golang.org/cmd/vet) # 3. go vet (http://golang.org/cmd/vet)
# 4. gosimple (https://github.com/dominikh/go-simple) # 4. gosimple (https://github.com/dominikh/go-simple)
# 5. unconvert (https://github.com/mdempsky/unconvert) # 5. unconvert (https://github.com/mdempsky/unconvert)
@ -14,8 +13,6 @@ go test -tags="rpctest" ./...
# Automatic checks # Automatic checks
golangci-lint run --deadline=10m --disable-all \ golangci-lint run --deadline=10m --disable-all \
--enable=gofmt \ --enable=gofmt \
--enable=golint \
--enable=vet \ --enable=vet \
--enable=gosimple \ --enable=gosimple \
--enable=unconvert --enable=unconvert

View file

@ -818,7 +818,7 @@ func (c *helpCacher) rpcUsage(includeWebsockets bool) (string, error) {
} }
} }
sort.Sort(sort.StringSlice(usageTexts)) sort.Strings(usageTexts)
c.usage = strings.Join(usageTexts, "\n") c.usage = strings.Join(usageTexts, "\n")
return c.usage, nil return c.usage, nil
} }

View file

@ -2270,9 +2270,7 @@ out:
// When an InvVect has been added to a block, we can // When an InvVect has been added to a block, we can
// now remove it, if it was present. // now remove it, if it was present.
case broadcastInventoryDel: case broadcastInventoryDel:
if _, ok := pendingInvs[*msg]; ok { delete(pendingInvs, *msg)
delete(pendingInvs, *msg)
}
} }
case <-timer.C: case <-timer.C:

View file

@ -124,7 +124,7 @@ func TestOpcodeDisasm(t *testing.T) {
// OP_UNKNOWN#. // OP_UNKNOWN#.
case opcodeVal >= 0xba && opcodeVal <= 0xf9 || opcodeVal == 0xfc: case opcodeVal >= 0xba && opcodeVal <= 0xf9 || opcodeVal == 0xfc:
expectedStr = "OP_UNKNOWN" + strconv.Itoa(int(opcodeVal)) expectedStr = "OP_UNKNOWN" + strconv.Itoa(opcodeVal)
} }
pop := parsedOpcode{opcode: &opcodeArray[opcodeVal], data: data} pop := parsedOpcode{opcode: &opcodeArray[opcodeVal], data: data}
@ -190,7 +190,7 @@ func TestOpcodeDisasm(t *testing.T) {
// OP_UNKNOWN#. // OP_UNKNOWN#.
case opcodeVal >= 0xba && opcodeVal <= 0xf9 || opcodeVal == 0xfc: case opcodeVal >= 0xba && opcodeVal <= 0xf9 || opcodeVal == 0xfc:
expectedStr = "OP_UNKNOWN" + strconv.Itoa(int(opcodeVal)) expectedStr = "OP_UNKNOWN" + strconv.Itoa(opcodeVal)
} }
pop := parsedOpcode{opcode: &opcodeArray[opcodeVal], data: data} pop := parsedOpcode{opcode: &opcodeArray[opcodeVal], data: data}

View file

@ -118,15 +118,15 @@ func TestElementWire(t *testing.T) {
}, },
}, },
{ {
ServiceFlag(SFNodeNetwork), SFNodeNetwork,
[]byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, []byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
}, },
{ {
InvType(InvTypeTx), InvTypeTx,
[]byte{0x01, 0x00, 0x00, 0x00}, []byte{0x01, 0x00, 0x00, 0x00},
}, },
{ {
BitcoinNet(MainNet), MainNet,
[]byte{0xf9, 0xbe, 0xb4, 0xd9}, []byte{0xf9, 0xbe, 0xb4, 0xd9},
}, },
// Type not supported by the "fast" path and requires reflection. // Type not supported by the "fast" path and requires reflection.
@ -211,9 +211,9 @@ func TestElementWireErrors(t *testing.T) {
}), }),
0, io.ErrShortWrite, io.EOF, 0, io.ErrShortWrite, io.EOF,
}, },
{ServiceFlag(SFNodeNetwork), 0, io.ErrShortWrite, io.EOF}, {SFNodeNetwork, 0, io.ErrShortWrite, io.EOF},
{InvType(InvTypeTx), 0, io.ErrShortWrite, io.EOF}, {InvTypeTx, 0, io.ErrShortWrite, io.EOF},
{BitcoinNet(MainNet), 0, io.ErrShortWrite, io.EOF}, {MainNet, 0, io.ErrShortWrite, io.EOF},
} }
t.Logf("Running %d tests", len(tests)) t.Logf("Running %d tests", len(tests))