Include error return checking in golangci-lint results
displague opened this issue · 0 comments
displague commented
Expected Behaviour
Linting prevents risky code from being introduced into the project.
Current Behaviour
The current “golanglint-ci” thresholds overlook common problems from building up due to not checking for errors. When overlooked these problems lead to error-prone code.
Possible Solution
If I had to guess, this linter was disabled for main.go:48
: defer sync()
.
An inline // nolint:errcheck
could be used to call out awareness in this one situation, without disabling the linter elsewhere.
In drone configurations,
- Increase the version of
golangci-lint
to the latest. - Remove
-D errcheck
from the calling arguments.
.drone.yml: image: golangci/golangci-lint:v1.24.0
.drone.yml: - golangci-lint run -v -D errcheck
The PR that introduces this for CI should include (or be preceded) by one that addresses the outstanding issues, as reflected by the default golangci-lint reporting settings, in this project.
Context
$ golangci-lint run ./...
api/bmc.go:29:10: Error return value of `c.Error` is not checked (errcheck)
c.Error(err)
^
api/boot.go:27:10: Error return value of `c.Error` is not checked (errcheck)
c.Error(err)
^
api/lan.go:29:10: Error return value of `c.Error` is not checked (errcheck)
c.Error(err)
^
main.go:48:12: Error return value of `sync` is not checked (errcheck)
defer sync()
^