Skip to content

Commit 42cae90

Browse files
authored
chore: remove deprecated errcheck.ignore lint option (#3062)
1 parent 1a59d58 commit 42cae90

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

‎.golangci.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ run:
33

44
linters-settings:
55
errcheck:
6-
ignore: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy
6+
exclude-functions:
7+
- (io.Writer).Write
8+
- io.Copy
9+
- io.WriteString
710
revive:
811
enable-all-rules: false
912
rules:
@@ -48,3 +51,4 @@ issues:
4851
- path: _test\.go
4952
linters:
5053
- dupl
54+
- errcheck

‎client/websocket.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (p *Client) Websocket(query string, options ...Option) *Subscription {
4747
// Grab a single response from a websocket based query
4848
func (p *Client) WebsocketOnce(query string, resp interface{}, options ...Option) error {
4949
sock := p.Websocket(query, options...)
50-
defer sock.Close()
50+
defer func() { _ = sock.Close() }()
5151
if reflect.ValueOf(resp).Kind() == reflect.Ptr {
5252
return sock.Next(resp)
5353
}

‎client/withfilesoption.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func WithFiles() Option {
5555
//
5656
// {"query":"mutation ($input: Input!) {}","variables":{"input":{"file":{}}}
5757
requestBody, _ := json.Marshal(bd)
58-
bodyWriter.WriteField("operations", string(requestBody))
58+
_ = bodyWriter.WriteField("operations", string(requestBody))
5959

6060
// --b7955bd2e1d17b67ac157b9e9ddb6238888caefc6f3541920a1debad284d
6161
// Content-Disposition: form-data; name="map"
@@ -97,7 +97,7 @@ func WithFiles() Option {
9797

9898
mapData = `{` + strings.Join(mapDataFiles, ",") + `}`
9999
}
100-
bodyWriter.WriteField("map", mapData)
100+
_ = bodyWriter.WriteField("map", mapData)
101101

102102
// --b7955bd2e1d17b67ac157b9e9ddb6238888caefc6f3541920a1debad284d
103103
// Content-Disposition: form-data; name="0"; filename="tempFile"

‎graphql/handler/server.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
107107
resp := &graphql.Response{Errors: []*gqlerror.Error{gqlErr}}
108108
b, _ := json.Marshal(resp)
109109
w.WriteHeader(http.StatusUnprocessableEntity)
110-
w.Write(b)
110+
_, _ = w.Write(b)
111111
}
112112
}()
113113

@@ -128,7 +128,7 @@ func sendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) {
128128
if err != nil {
129129
panic(err)
130130
}
131-
w.Write(b)
131+
_, _ = w.Write(b)
132132
}
133133

134134
func sendErrorf(w http.ResponseWriter, code int, format string, args ...interface{}) {

‎graphql/handler/transport/error.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func SendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) {
1818
if err != nil {
1919
panic(err)
2020
}
21-
w.Write(b)
21+
_, _ = w.Write(b)
2222
}
2323

2424
// SendErrorf wraps SendError to add formatted messages

‎graphql/handler/transport/websocket.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (t Websocket) Do(w http.ResponseWriter, r *http.Request, exec graphql.Graph
103103
switch ws.Subprotocol() {
104104
default:
105105
msg := websocket.FormatCloseMessage(websocket.CloseProtocolError, fmt.Sprintf("unsupported negotiated subprotocol %s", ws.Subprotocol()))
106-
ws.WriteMessage(websocket.CloseMessage, msg)
106+
_ = ws.WriteMessage(websocket.CloseMessage, msg)
107107
return
108108
case graphqlwsSubprotocol, "":
109109
// clients are required to send a subprotocol, to be backward compatible with the previous implementation we select
@@ -272,7 +272,7 @@ func (c *wsConnection) run() {
272272
if !c.MissingPongOk {
273273
// Note: when the connection is closed by this deadline, the client
274274
// will receive an "invalid close code"
275-
c.conn.SetReadDeadline(time.Now().UTC().Add(2 * c.PingPongInterval))
275+
_ = c.conn.SetReadDeadline(time.Now().UTC().Add(2 * c.PingPongInterval))
276276
}
277277
go c.ping(ctx)
278278
}
@@ -312,7 +312,7 @@ func (c *wsConnection) run() {
312312
c.receivedPong = true
313313
c.mu.Unlock()
314314
// Clear ReadTimeout -- 0 time val clears.
315-
c.conn.SetReadDeadline(time.Time{})
315+
_ = c.conn.SetReadDeadline(time.Time{})
316316
default:
317317
c.sendConnectionError("unexpected message %s", m.t)
318318
c.close(websocket.CloseProtocolError, "unexpected message")
@@ -357,7 +357,7 @@ func (c *wsConnection) ping(ctx context.Context) {
357357
// if we have not yet received a pong, don't reset the deadline.
358358
c.mu.Lock()
359359
if !c.MissingPongOk && c.receivedPong {
360-
c.conn.SetReadDeadline(time.Now().UTC().Add(2 * c.PingPongInterval))
360+
_ = c.conn.SetReadDeadline(time.Now().UTC().Add(2 * c.PingPongInterval))
361361
}
362362
c.receivedPong = false
363363
c.mu.Unlock()

0 commit comments

Comments
 (0)