Skip to content

Commit

Permalink
build: clean linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi committed May 13, 2020
1 parent bc8d63b commit f7399e6
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion blockchain/difficulty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestCalcWork(t *testing.T) {
}

for x, test := range tests {
bits := uint32(test.in)
bits := test.in

r := CalcWork(bits)
if r.Int64() != test.out {
Expand Down
4 changes: 2 additions & 2 deletions blockchain/indexers/addrindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (b *addrIndexBucket) printLevels(addrKey [addrKeySize]byte) string {
if !bytes.Equal(k[:levelOffset], addrKey[:]) {
continue
}
level := uint8(k[levelOffset])
level := k[levelOffset]
if level > highestLevel {
highestLevel = level
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (b *addrIndexBucket) sanityCheck(addrKey [addrKeySize]byte, expectedTotal i
if !bytes.Equal(k[:levelOffset], addrKey[:]) {
continue
}
level := uint8(k[levelOffset])
level := k[levelOffset]
if level > highestLevel {
highestLevel = level
}
Expand Down
6 changes: 3 additions & 3 deletions btcec/pubkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ func TestPubKeys(t *testing.T) {
var pkStr []byte
switch test.format {
case pubkeyUncompressed:
pkStr = (*PublicKey)(pk).SerializeUncompressed()
pkStr = pk.SerializeUncompressed()
case pubkeyCompressed:
pkStr = (*PublicKey)(pk).SerializeCompressed()
pkStr = pk.SerializeCompressed()
case pubkeyHybrid:
pkStr = (*PublicKey)(pk).SerializeHybrid()
pkStr = pk.SerializeHybrid()
}
if !bytes.Equal(test.key, pkStr) {
t.Errorf("%s pubkey: serialized keys do not match.",
Expand Down
3 changes: 1 addition & 2 deletions btcec/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ func TestSignatureSerialize(t *testing.T) {

func testSignCompact(t *testing.T, tag string, curve *KoblitzCurve,
data []byte, isCompressed bool) {
tmp, _ := NewPrivateKey(curve)
priv := (*PrivateKey)(tmp)
priv, _ := NewPrivateKey(curve)

hashed := []byte("testing")
sig, err := SignCompact(curve, priv, hashed, isCompressed)
Expand Down
2 changes: 1 addition & 1 deletion btcjson/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,6 @@ func RegisteredCmdMethods() []string {
methods = append(methods, k)
}

sort.Sort(sort.StringSlice(methods))
sort.Strings(methods)
return methods
}
2 changes: 1 addition & 1 deletion btcjson/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func TestRegisteredCmdMethods(t *testing.T) {
// Ensure the returned methods are sorted.
sortedMethods := make([]string, len(methods))
copy(sortedMethods, methods)
sort.Sort(sort.StringSlice(sortedMethods))
sort.Strings(sortedMethods)
if !reflect.DeepEqual(sortedMethods, methods) {
t.Fatal("RegisteredCmdMethods: methods are not sorted")
}
Expand Down
4 changes: 2 additions & 2 deletions database/ffldb/whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,9 @@ func TestFailureScenarios(t *testing.T) {
// context.
maxSize := int64(-1)
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}
return file, nil
}
Expand Down
3 changes: 0 additions & 3 deletions goclean.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash
# The script does automatic checking on a Go package and its sub-packages, including:
# 1. gofmt (http://golang.org/cmd/gofmt/)
# 2. golint (https://github.com/golang/lint)
# 3. go vet (http://golang.org/cmd/vet)
# 4. gosimple (https://github.com/dominikh/go-simple)
# 5. unconvert (https://github.com/mdempsky/unconvert)
Expand All @@ -14,8 +13,6 @@ go test -tags="rpctest" ./...
# Automatic checks
golangci-lint run --deadline=10m --disable-all \
--enable=gofmt \
--enable=golint \
--enable=vet \
--enable=gosimple \
--enable=unconvert

2 changes: 1 addition & 1 deletion rpcserverhelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
return c.usage, nil
}
Expand Down
4 changes: 1 addition & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2270,9 +2270,7 @@ out:
// When an InvVect has been added to a block, we can
// now remove it, if it was present.
case broadcastInventoryDel:
if _, ok := pendingInvs[*msg]; ok {
delete(pendingInvs, *msg)
}
delete(pendingInvs, *msg)
}

case <-timer.C:
Expand Down
4 changes: 2 additions & 2 deletions txscript/opcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestOpcodeDisasm(t *testing.T) {

// OP_UNKNOWN#.
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}
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestOpcodeDisasm(t *testing.T) {

// OP_UNKNOWN#.
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}
Expand Down
12 changes: 6 additions & 6 deletions wire/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ func TestElementWire(t *testing.T) {
},
},
{
ServiceFlag(SFNodeNetwork),
SFNodeNetwork,
[]byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
},
{
InvType(InvTypeTx),
InvTypeTx,
[]byte{0x01, 0x00, 0x00, 0x00},
},
{
BitcoinNet(MainNet),
MainNet,
[]byte{0xf9, 0xbe, 0xb4, 0xd9},
},
// Type not supported by the "fast" path and requires reflection.
Expand Down Expand Up @@ -211,9 +211,9 @@ func TestElementWireErrors(t *testing.T) {
}),
0, io.ErrShortWrite, io.EOF,
},
{ServiceFlag(SFNodeNetwork), 0, io.ErrShortWrite, io.EOF},
{InvType(InvTypeTx), 0, io.ErrShortWrite, io.EOF},
{BitcoinNet(MainNet), 0, io.ErrShortWrite, io.EOF},
{SFNodeNetwork, 0, io.ErrShortWrite, io.EOF},
{InvTypeTx, 0, io.ErrShortWrite, io.EOF},
{MainNet, 0, io.ErrShortWrite, io.EOF},
}

t.Logf("Running %d tests", len(tests))
Expand Down

0 comments on commit f7399e6

Please sign in to comment.