go-imap icon indicating copy to clipboard operation
go-imap copied to clipboard

Error return value is not checked

Open tegk opened this issue 6 years ago • 5 comments

message.go:935:21: Error return value of `bs.Envelope.Parse` is not checked 
			bs.Envelope.Parse(envelope)
			                 
message.go:939:26: Error return value of `bs.BodyStructure.Parse` is not checked 
			bs.BodyStructure.Parse(structure)
read.go:218:14: Error return value of `r.UnreadRune` is not checked 
	r.UnreadRune()
	            
read.go:289:17: Error return value of `r.UnreadRune` is not checked 
				r.UnreadRune()
read.go:347:17: Error return value of `r.UnreadRune` is not checked 
				r.UnreadRune()
responses/authenticate.go:49:11: Error return value of `r.cancel` is not checked 
		r.cancel()
responses/authenticate.go:55:11: Error return value of `r.cancel` is not checked 
		r.cancel()
server/cmd_any_test.go:27:16: Error return value of `io.WriteString` is not checked 
	io.WriteString(c, "a001 CAPABILITY\r\n")
server/conn.go:146:20: Error return value of `c.Conn.SetDeadline` is not checked 
	c.Conn.SetDeadline(t)
server/conn.go:159:20: Error return value of `c.ctx.User.Logout` is not checked 
		c.ctx.User.Logout()
server/conn.go:277:15: Error return value of `c.WriteResp` is not checked 
			c.WriteResp(&imap.StatusResp{
server/server.go:229:17: Error return value of `s.serveConn` is not checked 
		go s.serveConn(conn)

tegk avatar Jun 12 '19 13:06 tegk

Waiting for your great PRs!

foxcpp avatar Jun 12 '19 15:06 foxcpp

Waiting for your great PRs!

@foxcpp Why so salty?

I would prefer a technical discussion why the values are not checked as this seems to be a pattern in the code base and perhaps was the intended style of the author.

tegk avatar Jun 12 '19 15:06 tegk

@foxcpp Why so salty?

Sorry, just got a bit upset while replying to all these issues.

foxcpp avatar Jun 12 '19 15:06 foxcpp

message.go:935:21: Error return value of `bs.Envelope.Parse` is not checked 
			bs.Envelope.Parse(envelope)
			                 

message.go:939:26: Error return value of `bs.BodyStructure.Parse` is not checked 
			bs.BodyStructure.Parse(structure)

These indeed should be checked and it was briefly mentioned in some discussion (#166, I think), feel free to fix it.

read.go:218:14: Error return value of `r.UnreadRune` is not checked 
	r.UnreadRune()
read.go:289:17: Error return value of `r.UnreadRune` is not checked 
				r.UnreadRune()

read.go:347:17: Error return value of `r.UnreadRune` is not checked 
				r.UnreadRune()

Unread* functions don't fail with the exception of one extreme case. Generally not worth checking.

responses/authenticate.go:49:11: Error return value of `r.cancel` is not checked 
		r.cancel()

responses/authenticate.go:55:11: Error return value of `r.cancel` is not checked 
		r.cancel()

You can check this function a few lines before, it never fails. Though it is related to I/O and we might change it in the future. If you are that pedantic - feel free to send a fix.

server/conn.go:146:20: Error return value of `c.Conn.SetDeadline` is not checked 
	c.Conn.SetDeadline(t)

Not sure about this one. @emersion?

server/server.go:229:17: Error return value of `s.serveConn` is not checked 
		go s.serveConn(conn)

There is no context to report error to. We may log it to ErrorLog though. PRs are welcome.

foxcpp avatar Jun 12 '19 15:06 foxcpp

c.Conn.SetDeadline(t)

Could be checked, I guess.

If you are that pedantic

Side note: don't take it personally, it's a reference to the -Wpedantic flag from C compilers.

emersion avatar Jun 12 '19 15:06 emersion