From 744c2e82b57a99d99de17af7448b7f01faf45d12 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sat, 17 Dec 2016 15:27:44 +0100 Subject: [PATCH] build: Enable gometalinter "staticcheck" check --- build.go | 2 ++ cmd/strelaysrv/status.go | 2 +- lib/model/rwfolder.go | 2 +- lib/sync/sync_test.go | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.go b/build.go index fc0846eb0..795693536 100644 --- a/build.go +++ b/build.go @@ -300,6 +300,7 @@ func runCommand(cmd string, target target) { ok = gometalinter("varcheck", dirs) && ok ok = gometalinter("ineffassign", dirs) && ok ok = gometalinter("unused", dirs) && ok + ok = gometalinter("staticcheck", dirs) && ok if !ok { os.Exit(1) } @@ -370,6 +371,7 @@ func setup() { "github.com/tsenart/deadcode", "golang.org/x/net/html", "golang.org/x/tools/cmd/cover", + "honnef.co/go/staticcheck/cmd/staticcheck", "honnef.co/go/unused/cmd/unused", } for _, pkg := range packages { diff --git a/cmd/strelaysrv/status.go b/cmd/strelaysrv/status.go index 4926b9011..a00703b1d 100644 --- a/cmd/strelaysrv/status.go +++ b/cmd/strelaysrv/status.go @@ -42,7 +42,7 @@ func getStatus(w http.ResponseWriter, r *http.Request) { status["goMaxProcs"] = runtime.GOMAXPROCS(-1) status["goNumRoutine"] = runtime.NumGoroutine() status["kbps10s1m5m15m30m60m"] = []int64{ - rc.rate(10/10) * 8 / 1000, + rc.rate(1) * 8 / 1000, // each interval is 10s rc.rate(60/10) * 8 / 1000, rc.rate(5*60/10) * 8 / 1000, rc.rate(15*60/10) * 8 / 1000, diff --git a/lib/model/rwfolder.go b/lib/model/rwfolder.go index bc69a74aa..fab982b96 100644 --- a/lib/model/rwfolder.go +++ b/lib/model/rwfolder.go @@ -494,7 +494,7 @@ nextFile: select { case <-f.stop: // Stop processing files if the puller has been told to stop. - break + break nextFile default: } diff --git a/lib/sync/sync_test.go b/lib/sync/sync_test.go index 6d53d1cad..cf7a22e69 100644 --- a/lib/sync/sync_test.go +++ b/lib/sync/sync_test.go @@ -157,6 +157,7 @@ func TestRWMutex(t *testing.T) { }() mut.Lock() + _ = 1 // skip empty critical section check mut.Unlock() if len(messages) != 2 { @@ -170,6 +171,7 @@ func TestRWMutex(t *testing.T) { mut.RLock() mut.RLock() mut.RLock() + _ = 1 // skip empty critical section check mut.RUnlock() mut.RUnlock() mut.RUnlock()