mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-21 07:24:36 +00:00
linter: (1/2) enable errcheck (#5064)
## Description
partially cleanup in preparation for errcheck
i ignored a bunch of defer errors in tests but with the update to go 1.14 we can use `t.Cleanup(func() { if err := <>; err != nil {..}}` to cover those errors, I will do this in pr number two of enabling errcheck.
ref #5059
This commit is contained in:
@@ -61,7 +61,7 @@ func (a ABCIApp) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error
|
||||
c := a.App.CheckTx(abci.RequestCheckTx{Tx: tx})
|
||||
// and this gets written in a background thread...
|
||||
if !c.IsErr() {
|
||||
go func() { a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) }() // nolint: errcheck
|
||||
go func() { a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) }()
|
||||
}
|
||||
return &ctypes.ResultBroadcastTx{
|
||||
Code: c.Code,
|
||||
@@ -76,7 +76,7 @@ func (a ABCIApp) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
|
||||
c := a.App.CheckTx(abci.RequestCheckTx{Tx: tx})
|
||||
// and this gets written in a background thread...
|
||||
if !c.IsErr() {
|
||||
go func() { a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) }() // nolint: errcheck
|
||||
go func() { a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) }()
|
||||
}
|
||||
return &ctypes.ResultBroadcastTx{
|
||||
Code: c.Code,
|
||||
|
||||
@@ -177,7 +177,7 @@ func (c *Client) Call(method string, params map[string]interface{}, result inter
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("post failed: %w", err)
|
||||
}
|
||||
defer httpResponse.Body.Close() // nolint: errcheck
|
||||
defer httpResponse.Body.Close()
|
||||
|
||||
responseBytes, err := ioutil.ReadAll(httpResponse.Body)
|
||||
if err != nil {
|
||||
@@ -221,7 +221,7 @@ func (c *Client) sendBatch(requests []*jsonRPCBufferedRequest) ([]interface{}, e
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("post failed: %w", err)
|
||||
}
|
||||
defer httpResponse.Body.Close() // nolint: errcheck
|
||||
defer httpResponse.Body.Close()
|
||||
|
||||
responseBytes, err := ioutil.ReadAll(httpResponse.Body)
|
||||
if err != nil {
|
||||
|
||||
@@ -59,7 +59,7 @@ func (c *URIClient) Call(method string, params map[string]interface{}, result in
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("post form failed: %w", err)
|
||||
}
|
||||
defer resp.Body.Close() // nolint: errcheck
|
||||
defer resp.Body.Close()
|
||||
|
||||
responseBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
|
||||
@@ -34,7 +34,7 @@ func (h *myHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer conn.Close() // nolint: errcheck
|
||||
defer conn.Close()
|
||||
for {
|
||||
messageType, in, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
@@ -72,7 +72,7 @@ func TestWSClientReconnectsAfterReadFailure(t *testing.T) {
|
||||
defer s.Close()
|
||||
|
||||
c := startClient(t, "//"+s.Listener.Addr().String())
|
||||
defer c.Stop()
|
||||
defer c.Stop() // nolint:errcheck // ignore for tests
|
||||
|
||||
wg.Add(1)
|
||||
go callWgDoneOnResult(t, c, &wg)
|
||||
@@ -104,7 +104,7 @@ func TestWSClientReconnectsAfterWriteFailure(t *testing.T) {
|
||||
s := httptest.NewServer(h)
|
||||
|
||||
c := startClient(t, "//"+s.Listener.Addr().String())
|
||||
defer c.Stop()
|
||||
defer c.Stop() // nolint:errcheck // ignore for tests
|
||||
|
||||
wg.Add(2)
|
||||
go callWgDoneOnResult(t, c, &wg)
|
||||
@@ -132,7 +132,7 @@ func TestWSClientReconnectFailure(t *testing.T) {
|
||||
s := httptest.NewServer(h)
|
||||
|
||||
c := startClient(t, "//"+s.Listener.Addr().String())
|
||||
defer c.Stop()
|
||||
defer c.Stop() // nolint:errcheck // ignore for tests
|
||||
|
||||
go func() {
|
||||
for {
|
||||
@@ -181,14 +181,15 @@ func TestNotBlockingOnStop(t *testing.T) {
|
||||
timeout := 2 * time.Second
|
||||
s := httptest.NewServer(&myHandler{})
|
||||
c := startClient(t, "//"+s.Listener.Addr().String())
|
||||
c.Call(context.Background(), "a", make(map[string]interface{}))
|
||||
c.Call(context.Background(), "a", make(map[string]interface{})) // nolint:errcheck // ignore for tests
|
||||
// Let the readRoutine get around to blocking
|
||||
time.Sleep(time.Second)
|
||||
passCh := make(chan struct{})
|
||||
go func() {
|
||||
// Unless we have a non-blocking write to ResponsesCh from readRoutine
|
||||
// this blocks forever ont the waitgroup
|
||||
c.Stop()
|
||||
err := c.Stop()
|
||||
require.NoError(t, err)
|
||||
passCh <- struct{}{}
|
||||
}()
|
||||
select {
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestMaxOpenConnections(t *testing.T) {
|
||||
l, err := Listen("tcp://127.0.0.1:0", config)
|
||||
require.NoError(t, err)
|
||||
defer l.Close()
|
||||
go Serve(l, mux, log.TestingLogger(), config)
|
||||
go Serve(l, mux, log.TestingLogger(), config) //nolint:errcheck // ignore for tests
|
||||
|
||||
// Make N GET calls to the server.
|
||||
attempts := max * 2
|
||||
@@ -55,7 +55,8 @@ func TestMaxOpenConnections(t *testing.T) {
|
||||
return
|
||||
}
|
||||
defer r.Body.Close()
|
||||
io.Copy(ioutil.Discard, r.Body)
|
||||
_, err = io.Copy(ioutil.Discard, r.Body)
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
@@ -38,5 +38,8 @@ func main() {
|
||||
if err != nil {
|
||||
tmos.Exit(err.Error())
|
||||
}
|
||||
rpcserver.Serve(listener, mux, logger, config)
|
||||
|
||||
if err = rpcserver.Serve(listener, mux, logger, config); err != nil {
|
||||
tmos.Exit(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user