gordonklaus / ineffassign

Detect ineffectual assignments in Go code.
MIT License
394 stars 22 forks source link

False positive #25

Closed or-else closed 6 years ago

or-else commented 6 years ago

https://goreportcard.com/report/github.com/tinode/chat

Line 1021: warning: err assigned and not used (ineffassign)

This is the line it complains about: https://github.com/tinode/chat/blob/master/server/db/rethinkdb/adapter.go#L1021

Thanks.

gordonklaus commented 6 years ago

@or-else I had to refresh the report card (it was 4 months old) to find the line. It is now https://github.com/tinode/chat/blob/master/server/db/rethinkdb/adapter.go#L1231

Take a closer look. The err it is complaining about is declared in the outermost else block. It's the not the named result err that you think it is.

It could be beneficial to try to rewrite this function with early returns.