Skip to content

Commit

Permalink
Merge pull request nats-io#367 from nats-io/staticcheck
Browse files Browse the repository at this point in the history
Add staticcheck analyzer to Travis CI
  • Loading branch information
derekcollison authored Oct 27, 2016
2 parents 54b96e4 + 6281894 commit 8ffdb6b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.7.3" ]; then ./scripts/cov.sh TRAVIS; fi
- if [ "$TRAVIS_GO_VERSION" = "1.7.3" ] && [ "$TRAVIS_TAG" != "" ]; then ./scripts/cross_compile.sh $TRAVIS_TAG; ghr --username nats-io --token $GITHUB_TOKEN --replace $TRAVIS_TAG pkg/; fi
8 changes: 8 additions & 0 deletions server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()
}

Expand Down
5 changes: 3 additions & 2 deletions test/client_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 8ffdb6b

Please sign in to comment.