Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate using errcheck #101

Closed
tomwilkie opened this issue May 25, 2015 · 4 comments · Fixed by #107
Closed

Investigate using errcheck #101

tomwilkie opened this issue May 25, 2015 · 4 comments · Fixed by #107
Assignees

Comments

@tomwilkie
Copy link
Contributor

https://github.com/kisielk/errcheck

@peterbourgon
Copy link
Contributor

Sure, we can run it occasionally.

@tomwilkie
Copy link
Contributor Author

It seems to highlight a few times when we don't check the err:

vagrant@ubuntu-14:~/src/github.com/weaveworks/scope$ errcheck github.com/weaveworks/scope/app
github.com/weaveworks/scope/app/api_topology.go:62:14   r.ParseForm()
github.com/weaveworks/scope/app/api_topology.go:122:18  defer conn.Close()
github.com/weaveworks/scope/app/api_topology.go:143:24  conn.SetWriteDeadline(time.Now().Add(websocketTimeout))
github.com/weaveworks/scope/app/api_topology_test.go:134:16 defer ws.Close()
github.com/weaveworks/scope/app/main.go:46:16   defer w.Close()
github.com/weaveworks/scope/app/main.go:56:16   defer f.Close()
github.com/weaveworks/scope/app/main.go:66:18   defer os.Remove(*pidfile)
github.com/weaveworks/scope/app/scope_test.go:63:16 res.Body.Close()
github.com/weaveworks/scope/app/server_helpers.go:12:27 json.NewEncoder(w).Encode(response)
vagrant@ubuntu-14:~/src/github.com/weaveworks/scope$ errcheck github.com/weaveworks/scope/probe
github.com/weaveworks/scope/probe/main.go:56:25 go http.ListenAndServe(*httpListen, nil)
github.com/weaveworks/scope/probe/process_mapper.go:74:10   fh.Close()
github.com/weaveworks/scope/probe/process_mapper.go:113:10  f.Close()
github.com/weaveworks/scope/probe/process_mapper_test.go:20:20  defer os.RemoveAll(tmp)
github.com/weaveworks/scope/probe/process_mapper_test.go:47:16  os.RemoveAll(tmp)
github.com/weaveworks/scope/probe/process_mapper_test.go:52:16  os.RemoveAll(tmp)

@tomwilkie
Copy link
Contributor Author

You can filter out close, which it seems pretty safe to ignore:

vagrant@ubuntu-14:~/src/github.com/weaveworks/scope$ errcheck -ignore 'Close' github.com/weaveworks/scope/app
github.com/weaveworks/scope/app/api_topology.go:62:14   r.ParseForm()
github.com/weaveworks/scope/app/api_topology.go:143:24  conn.SetWriteDeadline(time.Now().Add(websocketTimeout))
github.com/weaveworks/scope/app/main.go:66:18   defer os.Remove(*pidfile)
github.com/weaveworks/scope/app/server_helpers.go:12:27 json.NewEncoder(w).Encode(response)

@peterbourgon
Copy link
Contributor

All of those are effectively harmless. But, I'm happy to throw in some checks. (And remove that pidfile stuff altogether.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants