Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

De-lint 'tftp-go' #3

Merged
merged 2 commits into from
Oct 1, 2021
Merged

De-lint 'tftp-go' #3

merged 2 commits into from
Oct 1, 2021

Conversation

tstromberg
Copy link

This PR does 3 things:

handler.go:115:71: (*session).writeAndWaitForPacket - result 0 (github.com/tinkerbell/tftp-go.packet) is never used (unparam)
func (s *session) writeAndWaitForPacket(p packet, v packetValidator) (packet, error) {
                                                                      ^
handler.go:130:7: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
			if err == ErrTimeout {
			   ^
handler.go:182:3: ifElseChain: rewrite if-else to switch statement (gocritic)
		if i < 8 {
		^
handler.go:201:3: ifElseChain: rewrite if-else to switch statement (gocritic)
		if i < 1 {
		^
handler.go:230:3: switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors (errorlint)
		switch err {
		^
handler.go:280:3: switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors (errorlint)
		switch readErr {
		^
handler.go:303:28: unused-parameter: parameter 'p' seems to be unused, consider removing or renaming it as _ (revive)
func (s *session) serveWRQ(p *packetWRQ) {
                           ^
handler_test.go:69:29: Comment should end in a period (godot)
// To implement packetReader
                            ^
handler_test.go:70:31: unused-parameter: parameter 'timeout' seems to be unused, consider removing or renaming it as _ (revive)
func (h *handlerContext) read(timeout time.Duration) (packet, error) {
                              ^
handler_test.go:86:26: Comment should end in a period (godot)
// Implement packetWriter
                         ^
handler_test.go:92:24: Comment should end in a period (godot)
// To implement Handler
                       ^
handler_test.go:100:24: Comment should end in a period (godot)
// To implement Handler
                       ^
handler_test.go:120:26: test helper function should start from t.Helper() (thelper)
func (h *handlerContext) Negotiate(t *testing.T, o map[string]string) {
                         ^
handler_test.go:126:2: type assertion must be checked (forcetypeassert)
	oack := poack.(*packetOACK)
	^
handler_test.go:144:2: type assertion must be checked (forcetypeassert)
	p := px.(*packetERROR)
	^
handler_test.go:156:2: type assertion must be checked (forcetypeassert)
	p := px.(*packetERROR)
	^
handler_test.go:200:3: type assertion must be checked (forcetypeassert)
		p := px.(*packetERROR)
		^
handler_test.go:317: File is not `gofmt`-ed with `-s` (gofmt)
				&packetDATA{blockNr: 1, data: []byte{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7}},
				&packetDATA{blockNr: 2, data: []byte{0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}},
				&packetDATA{blockNr: 3, data: []byte{}},
handler_test.go:341:4: type assertion must be checked (forcetypeassert)
			actual := pdata.(*packetDATA)
			^
handler_test.go:370:2: type assertion must be checked (forcetypeassert)
	data := pdata.(*packetDATA)
	^
packet.go:54:2: `tftpErrDiskFull` is unused (deadcode)
	tftpErrDiskFull          = tftpError{3, "Disk full or allocation exceeded."}
	^
packet.go:56:2: `tftpErrUnknownTransferID` is unused (deadcode)
	tftpErrUnknownTransferID = tftpError{5, "Unknown transfer ID."}
	^
packet.go:57:2: `tftpErrFileAlreadyExists` is unused (deadcode)
	tftpErrFileAlreadyExists = tftpError{6, "File already exists."}
	^
packet.go:58:2: `tftpErrNoSuchUser` is unused (deadcode)
	tftpErrNoSuchUser        = tftpError{7, "No such user."}
	^
packet.go:90:5: variable 'err' is only used in the if-statement (packet.go:91:2); consider using short syntax (ifshort)
	_, err := b.WriteString(line)
	   ^
packet.go:161:31: unnecessary conversion (unconvert)
	if err = writeChunk(b, string(p.filename)); err != nil {
	                             ^
packet.go:167:2: if-return: redundant if ...; err != nil check, just return error instead. (revive)
	if err = writeOptions(b, p.options); err != nil {
		return err
	}
packet.go:321:2: if-return: redundant if ...; err != nil check, just return error instead. (revive)
	if err = p.Write(b); err != nil {
		return err
	}
packet_test.go:49:6: test helper function should start from t.Helper() (thelper)
func testReadPacketXRQ(t *testing.T, prefix []byte) {
     ^
packet_test.go:207:3: type assertion must be checked (forcetypeassert)
		px := p.(*packetDATA)
		^
packet_test.go:248:3: type assertion must be checked (forcetypeassert)
		px := p.(*packetACK)
		^
packet_test.go:298:3: type assertion must be checked (forcetypeassert)
		px := p.(*packetERROR)
		^
packet_test.go:312:3: type assertion must be checked (forcetypeassert)
		px := p.(*packetERROR)
		^
packet_test.go:372:3: type assertion must be checked (forcetypeassert)
		px := p.(*packetOACK)
		^

@tstromberg tstromberg merged commit 0e6da46 into tinkerbell:master Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants