From 340a84cdc01cd9c6ec1db74e5ca0f36024014593 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 20 Sep 2017 14:54:17 +0100 Subject: [PATCH] Add staticcheck lint (#245) --- linter.json | 3 +-- .../matrix-org/dendrite/cmd/dendrite-room-server/main.go | 4 +++- .../dendrite/cmd/mediaapi-integration-tests/main.go | 2 +- .../dendrite/cmd/syncserver-integration-tests/testdata.go | 2 +- src/github.com/matrix-org/dendrite/common/httpapi.go | 3 ++- .../matrix-org/dendrite/mediaapi/writers/download.go | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/linter.json b/linter.json index 5fff5598..271a13cc 100644 --- a/linter.json +++ b/linter.json @@ -17,7 +17,6 @@ "unparam", "errcheck", "vet", - "unused", - "gosimple" + "megacheck" ] } diff --git a/src/github.com/matrix-org/dendrite/cmd/dendrite-room-server/main.go b/src/github.com/matrix-org/dendrite/cmd/dendrite-room-server/main.go index dea61f74..9da258c0 100644 --- a/src/github.com/matrix-org/dendrite/cmd/dendrite-room-server/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/dendrite-room-server/main.go @@ -80,7 +80,9 @@ func main() { aliasAPI.SetupHTTP(http.DefaultServeMux) - http.DefaultServeMux.Handle("/metrics", prometheus.Handler()) + // This is deprecated, but prometheus are still arguing on what to replace + // it with. Alternatively we could set it up manually. + http.DefaultServeMux.Handle("/metrics", prometheus.Handler()) // nolint: staticcheck, megacheck log.Info("Started room server on ", cfg.Listen.RoomServer) diff --git a/src/github.com/matrix-org/dendrite/cmd/mediaapi-integration-tests/main.go b/src/github.com/matrix-org/dendrite/cmd/mediaapi-integration-tests/main.go index c190c10b..722cb80f 100644 --- a/src/github.com/matrix-org/dendrite/cmd/mediaapi-integration-tests/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/mediaapi-integration-tests/main.go @@ -190,7 +190,7 @@ func getMediaURI(host, endpoint, query string, components []string) string { func testUpload(host, filePath string) { fmt.Printf("==TESTING== upload %v to %v\n", filePath, host) file, err := os.Open(filePath) - defer file.Close() // nolint: errcheck + defer file.Close() // nolint: errcheck, staticcheck, megacheck if err != nil { panic(err) } diff --git a/src/github.com/matrix-org/dendrite/cmd/syncserver-integration-tests/testdata.go b/src/github.com/matrix-org/dendrite/cmd/syncserver-integration-tests/testdata.go index bde34ae7..4ff5d1ee 100644 --- a/src/github.com/matrix-org/dendrite/cmd/syncserver-integration-tests/testdata.go +++ b/src/github.com/matrix-org/dendrite/cmd/syncserver-integration-tests/testdata.go @@ -14,7 +14,7 @@ package main -// nolint: varcheck, deadcode, unused +// nolint: varcheck, deadcode, unused, megacheck const ( i0StateRoomCreate = iota i1StateAliceJoin diff --git a/src/github.com/matrix-org/dendrite/common/httpapi.go b/src/github.com/matrix-org/dendrite/common/httpapi.go index 8d93e58d..0a1542b3 100644 --- a/src/github.com/matrix-org/dendrite/common/httpapi.go +++ b/src/github.com/matrix-org/dendrite/common/httpapi.go @@ -52,6 +52,7 @@ func MakeFedAPI( // SetupHTTPAPI registers an HTTP API mux under /api and sets up a metrics // listener. func SetupHTTPAPI(servMux *http.ServeMux, apiMux *mux.Router) { - servMux.Handle("/metrics", prometheus.Handler()) + // This is deprecated. + servMux.Handle("/metrics", prometheus.Handler()) // nolint: megacheck, staticcheck servMux.Handle("/api/", http.StripPrefix("/api", apiMux)) } diff --git a/src/github.com/matrix-org/dendrite/mediaapi/writers/download.go b/src/github.com/matrix-org/dendrite/mediaapi/writers/download.go index c69f5ae9..901ab6d3 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/writers/download.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/writers/download.go @@ -236,7 +236,7 @@ func (r *downloadRequest) respondFromLocalFile( return nil, errors.Wrap(err, "failed to get file path from metadata") } file, err := os.Open(filePath) - defer file.Close() // nolint: errcheck + defer file.Close() // nolint: errcheck, staticcheck, megacheck if err != nil { return nil, errors.Wrap(err, "failed to open file") }