Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: Enable errcheck, fix failures (#1345)
This enables linting with errcheck on the repository. Exclusions were added for functions that are known to never fail, e.g. all Write methods on Zap's buffer.Buffer. In attempting to enable exclusions for these functions, I discovered and fixed a typo in the golangci.yml. <details> <summary>Complete list of issues fixed</summary> ``` encoder_test.go:44:18: Error return value is not checked (errcheck) encoder_test.go:55:18: Error return value is not checked (errcheck) error.go:64:19: Error return value of `arr.AppendObject` is not checked (errcheck) http_handler.go:83:13: Error return value of `enc.Encode` is not checked (errcheck) http_handler.go:88:14: Error return value of `enc.Encode` is not checked (errcheck) http_handler.go:92:13: Error return value of `enc.Encode` is not checked (errcheck) http_handler.go:95:13: Error return value of `enc.Encode` is not checked (errcheck) http_handler_test.go:170:24: Error return value of `res.Body.Close` is not checked (errcheck) logger.go:377:24: Error return value of `log.errorOutput.Sync` is not checked (errcheck) sink.go:69:17: Error return value of `sr.RegisterSink` is not checked (errcheck) stacktrace_ext_test.go:178:13: Error return value of `os.MkdirAll` is not checked (errcheck) writer.go:65:11: Error return value of `c.Close` is not checked (errcheck) writer_test.go:94:11: Error return value of `os.Remove` is not checked (errcheck) writer_test.go:258:9: Error return value of `w.Write` is not checked (errcheck) zapcore/buffered_write_syncer_bench_test.go:43:15: Error return value of `w.Stop` is not checked (errcheck) zapcore/buffered_write_syncer_bench_test.go:47:12: Error return value of `w.Write` is not checked (errcheck) zapcore/buffered_write_syncer_test.go:104:11: Error return value of `ws.Write` is not checked (errcheck) zapcore/core.go:107:9: Error return value of `c.Sync` is not checked (errcheck) zapcore/core_test.go:151:13: Error return value of `core.Write` is not checked (errcheck) zapcore/encoder_test.go:288:17: Error return value of `enc.AddArray` is not checked (errcheck) zapcore/encoder_test.go:316:17: Error return value of `enc.AddArray` is not checked (errcheck) zapcore/encoder_test.go:723:14: Error return value of `mem.AddArray` is not checked (errcheck) zapcore/entry.go:245:23: Error return value of `ce.ErrorOutput.Sync` is not checked (errcheck) zapcore/entry.go:257:22: Error return value of `ce.ErrorOutput.Sync` is not checked (errcheck) zapcore/error.go:101:19: Error return value of `arr.AppendObject` is not checked (errcheck) zapcore/json_encoder_bench_test.go:34:16: Error return value of `enc.AddObject` is not checked (errcheck) zapcore/json_encoder_bench_test.go:98:16: Error return value of `json.Marshal` is not checked (errcheck) zapcore/json_encoder_impl_test.go:252:16: Error return value of `e.AddObject` is not checked (errcheck) zapcore/json_encoder_impl_test.go:260:16: Error return value of `e.AddObject` is not checked (errcheck) zapcore/json_encoder_impl_test.go:268:16: Error return value of `e.AddObject` is not checked (errcheck) zapcore/json_encoder_impl_test.go:292:13: Error return value of `e.AddArray` is not checked (errcheck) zapcore/json_encoder_impl_test.go:423:21: Error return value of `arr.AppendObject` is not checked (errcheck) zapcore/json_encoder_impl_test.go:431:21: Error return value of `arr.AppendObject` is not checked (errcheck) zapcore/json_encoder_impl_test.go:533:20: Error return value of `arr.AppendObject` is not checked (errcheck) zapcore/level_test.go:162:16: Error return value of `l.MarshalText` is not checked (errcheck) zapcore/memory_encoder_test.go:221:16: Error return value of `e.AddObject` is not checked (errcheck) zapcore/memory_encoder_test.go:235:16: Error return value of `e.AddObject` is not checked (errcheck) zapcore/memory_encoder_test.go:288:54: Error return value of `e.AppendReflected` is not checked (errcheck) zapcore/memory_encoder_test.go:294:18: Error return value of `e.AppendArray` is not checked (errcheck) zapcore/memory_encoder_test.go:305:18: Error return value of `e.AppendArray` is not checked (errcheck) zapcore/memory_encoder_test.go:306:24: Error return value of `inner.AppendObject` is not checked (errcheck) zapcore/memory_encoder_test.go:321:18: Error return value of `e.AppendArray` is not checked (errcheck) zapcore/memory_encoder_test.go:322:24: Error return value of `inner.AppendObject` is not checked (errcheck) zapcore/tee_test.go:123:13: Error return value of `tee.Write` is not checked (errcheck) zapcore/write_syncer_bench_test.go:40:12: Error return value of `w.Write` is not checked (errcheck) zapcore/write_syncer_bench_test.go:54:12: Error return value of `w.Write` is not checked (errcheck) zapcore/write_syncer_bench_test.go:67:15: Error return value of `w.Stop` is not checked (errcheck) zapcore/write_syncer_bench_test.go:71:12: Error return value of `w.Write` is not checked (errcheck) zapcore/write_syncer_bench_test.go:86:12: Error return value of `w.Write` is not checked (errcheck) zapcore/write_syncer_test.go:73:9: Error return value of `ws.Sync` is not checked (errcheck) zaptest/observer/observer_test.go:176:15: Error return value of `logger.Write` is not checked (errcheck) ``` </details>
- Loading branch information