Skip to content

Commit ce48a4b

Browse files
authored
small cleans from go report card (#1268)
I went through the list and cleaned things up here and there. Signed-off-by: Miek Gieben <miek@miek.nl>
1 parent 9922549 commit ce48a4b

File tree

8 files changed

+28
-29
lines changed

8 files changed

+28
-29
lines changed

acceptfunc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var DefaultMsgAcceptFunc MsgAcceptFunc = defaultMsgAcceptFunc
2525
// MsgAcceptAction represents the action to be taken.
2626
type MsgAcceptAction int
2727

28+
// Allowed returned values from a MsgAcceptFunc.
2829
const (
2930
MsgAccept MsgAcceptAction = iota // Accept the message
3031
MsgReject // Reject the message with a RcodeFormatError

dnssec.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"crypto/elliptic"
99
"crypto/rand"
1010
"crypto/rsa"
11-
_ "crypto/sha1"
12-
_ "crypto/sha256"
13-
_ "crypto/sha512"
11+
_ "crypto/sha1" // need its init function
12+
_ "crypto/sha256" // need its init function
13+
_ "crypto/sha512" // need its init function
1414
"encoding/asn1"
1515
"encoding/binary"
1616
"encoding/hex"

edns.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (*OPT) parse(c *zlexer, origin string) *ParseError {
9595
return &ParseError{err: "OPT records do not have a presentation format"}
9696
}
9797

98-
func (r1 *OPT) isDuplicate(r2 RR) bool { return false }
98+
func (rr *OPT) isDuplicate(r2 RR) bool { return false }
9999

100100
// return the old value -> delete SetVersion?
101101

@@ -465,7 +465,7 @@ func (e *EDNS0_LLQ) copy() EDNS0 {
465465
return &EDNS0_LLQ{e.Code, e.Version, e.Opcode, e.Error, e.Id, e.LeaseLife}
466466
}
467467

468-
// EDNS0_DUA implements the EDNS0 "DNSSEC Algorithm Understood" option. See RFC 6975.
468+
// EDNS0_DAU implements the EDNS0 "DNSSEC Algorithm Understood" option. See RFC 6975.
469469
type EDNS0_DAU struct {
470470
Code uint16 // Always EDNS0DAU
471471
AlgCode []uint8

privaterr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Fetch:
9090
return nil
9191
}
9292

93-
func (r1 *PrivateRR) isDuplicate(r2 RR) bool { return false }
93+
func (r *PrivateRR) isDuplicate(r2 RR) bool { return false }
9494

9595
// PrivateHandle registers a private resource record type. It requires
9696
// string and numeric representation of private RR type and generator function as argument.

scan_rr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ func (rr *HIP) parse(c *zlexer, o string) *ParseError {
735735
}
736736
rr.PublicKey = l.token // This cannot contain spaces
737737
decodedPK, decodedPKerr := base64.StdEncoding.DecodeString(rr.PublicKey)
738-
if decodedPKerr != nil{
738+
if decodedPKerr != nil {
739739
return &ParseError{"", "bad HIP PublicKey", l}
740740
}
741741
rr.PublicKeyLength = uint16(len(decodedPK))

svcb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strings"
1111
)
1212

13+
// SVCBKey is the type of the keys used in the SVCB RR.
1314
type SVCBKey uint16
1415

1516
// Keys defined in draft-ietf-dnsop-svcb-https-01 Section 12.3.2.

tsig_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ func TestTSIGHMAC224And384(t *testing.T) {
242242
const testGoodKeyName = "goodkey."
243243

244244
var (
245-
testErrBadKey = errors.New("this is an intentional error")
246-
testGoodMAC = []byte{0, 1, 2, 3}
245+
errBadKey = errors.New("this is an intentional error")
246+
testGoodMAC = []byte{0, 1, 2, 3}
247247
)
248248

249249
// testProvider always generates the same MAC and only accepts the one signature
@@ -255,14 +255,14 @@ func (provider *testProvider) Generate(_ []byte, t *TSIG) ([]byte, error) {
255255
if t.Hdr.Name == testGoodKeyName || provider.GenerateAllKeys {
256256
return testGoodMAC, nil
257257
}
258-
return nil, testErrBadKey
258+
return nil, errBadKey
259259
}
260260

261261
func (*testProvider) Verify(_ []byte, t *TSIG) error {
262262
if t.Hdr.Name == testGoodKeyName {
263263
return nil
264264
}
265-
return testErrBadKey
265+
return errBadKey
266266
}
267267

268268
func TestTsigGenerateProvider(t *testing.T) {
@@ -279,7 +279,7 @@ func TestTsigGenerateProvider(t *testing.T) {
279279
{
280280
"badkey.",
281281
nil,
282-
testErrBadKey,
282+
errBadKey,
283283
},
284284
}
285285

@@ -321,7 +321,7 @@ func TestTsigVerifyProvider(t *testing.T) {
321321
},
322322
{
323323
"badkey.",
324-
testErrBadKey,
324+
errBadKey,
325325
},
326326
}
327327

types.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,9 @@ const (
152152
)
153153

154154
// Used in ZONEMD https://tools.ietf.org/html/rfc8976
155-
156155
const (
157-
// ZoneMD Accepted Schemes
158156
ZoneMDSchemeSimple = 1
159157

160-
// ZoneMD Hash Algorithms
161158
ZoneMDHashAlgSHA384 = 1
162159
ZoneMDHashAlgSHA512 = 2
163160
)
@@ -1416,13 +1413,13 @@ func (rr *APL) String() string {
14161413
}
14171414

14181415
// str returns presentation form of the APL prefix.
1419-
func (p *APLPrefix) str() string {
1416+
func (a *APLPrefix) str() string {
14201417
var sb strings.Builder
1421-
if p.Negation {
1418+
if a.Negation {
14221419
sb.WriteByte('!')
14231420
}
14241421

1425-
switch len(p.Network.IP) {
1422+
switch len(a.Network.IP) {
14261423
case net.IPv4len:
14271424
sb.WriteByte('1')
14281425
case net.IPv6len:
@@ -1431,20 +1428,20 @@ func (p *APLPrefix) str() string {
14311428

14321429
sb.WriteByte(':')
14331430

1434-
switch len(p.Network.IP) {
1431+
switch len(a.Network.IP) {
14351432
case net.IPv4len:
1436-
sb.WriteString(p.Network.IP.String())
1433+
sb.WriteString(a.Network.IP.String())
14371434
case net.IPv6len:
14381435
// add prefix for IPv4-mapped IPv6
1439-
if v4 := p.Network.IP.To4(); v4 != nil {
1436+
if v4 := a.Network.IP.To4(); v4 != nil {
14401437
sb.WriteString("::ffff:")
14411438
}
1442-
sb.WriteString(p.Network.IP.String())
1439+
sb.WriteString(a.Network.IP.String())
14431440
}
14441441

14451442
sb.WriteByte('/')
14461443

1447-
prefix, _ := p.Network.Mask.Size()
1444+
prefix, _ := a.Network.Mask.Size()
14481445
sb.WriteString(strconv.Itoa(prefix))
14491446

14501447
return sb.String()
@@ -1458,17 +1455,17 @@ func (a *APLPrefix) equals(b *APLPrefix) bool {
14581455
}
14591456

14601457
// copy returns a copy of the APL prefix.
1461-
func (p *APLPrefix) copy() APLPrefix {
1458+
func (a *APLPrefix) copy() APLPrefix {
14621459
return APLPrefix{
1463-
Negation: p.Negation,
1464-
Network: copyNet(p.Network),
1460+
Negation: a.Negation,
1461+
Network: copyNet(a.Network),
14651462
}
14661463
}
14671464

14681465
// len returns size of the prefix in wire format.
1469-
func (p *APLPrefix) len() int {
1466+
func (a *APLPrefix) len() int {
14701467
// 4-byte header and the network address prefix (see Section 4 of RFC 3123)
1471-
prefix, _ := p.Network.Mask.Size()
1468+
prefix, _ := a.Network.Mask.Size()
14721469
return 4 + (prefix+7)/8
14731470
}
14741471

0 commit comments

Comments
 (0)