diff --git a/.travis.yml b/.travis.yml index cef0231d8f1..504373ef20d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,14 @@ install: - go get github.com/nats-io/nats - go get github.com/mattn/goveralls - go get github.com/wadey/gocovmerge +- go get honnef.co/go/staticcheck/cmd/staticcheck script: - go build - go fmt ./... - go vet ./... - go test -i -race ./... - go test -v -race ./... +- staticcheck ./... after_script: - if [ "$TRAVIS_GO_VERSION" = "1.6.3" ]; then ./scripts/cov.sh TRAVIS; fi - if [ "$TRAVIS_GO_VERSION" = "1.6.3" ] && [ "$TRAVIS_TAG" != "" ]; then ./scripts/cross_compile.sh $TRAVIS_TAG; ghr --username nats-io --token $GITHUB_TOKEN --replace $TRAVIS_TAG pkg/; fi diff --git a/server/util_test.go b/server/util_test.go index 3bee592fd4d..24ba9611318 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -49,6 +49,10 @@ func BenchmarkParseSize(b *testing.B) { func deferUnlock(mu *sync.Mutex) { mu.Lock() defer mu.Unlock() + // see noDeferUnlock + if false { + return + } } func BenchmarkDeferMutex(b *testing.B) { @@ -61,6 +65,10 @@ func BenchmarkDeferMutex(b *testing.B) { func noDeferUnlock(mu *sync.Mutex) { mu.Lock() + // prevent staticcheck warning about empty critical section + if false { + return + } mu.Unlock() } diff --git a/test/client_cluster_test.go b/test/client_cluster_test.go index 04f0c7d28d4..0f6ced71ab9 100644 --- a/test/client_cluster_test.go +++ b/test/client_cluster_test.go @@ -83,10 +83,11 @@ func TestServerRestartReSliceIssue(t *testing.T) { defer srvB.Shutdown() // Check that all expected clients have reconnected - for i := 0; i < numClients/2; i++ { + done := false + for i := 0; i < numClients/2 && !done; i++ { select { case <-reconnectsDone: - break + done = true case <-time.After(3 * time.Second): t.Fatalf("Expected %d reconnects, got %d\n", numClients/2, reconnects) }