Skip to content

Commit

Permalink
Introduce staticcheck static analysis
Browse files Browse the repository at this point in the history
Staticcheck is a tool that is highly recommended by the Go tools
team, so let's give it a go.
https://staticcheck.io/
  • Loading branch information
blgm committed Oct 17, 2019
1 parent d4f19a6 commit f3efa40
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ go:
env:
- GO111MODULE=on

script: go run github.com/onsi/ginkgo/ginkgo -r
script:
- go run honnef.co/go/tools/cmd/staticcheck ./...
- go run github.com/onsi/ginkgo/ginkgo -r
2 changes: 1 addition & 1 deletion catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ var _ = Describe("Catalog", func() {
Bullets: []string{"hello", "its me"},
DisplayName: "name",
AdditionalMetadata: map[string]interface{}{
"foo": make(chan int, 0),
"foo": make(chan int),
},
}
_, err := json.Marshal(metadata)
Expand Down
3 changes: 1 addition & 2 deletions domain/apiresponses/failure_responses.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package apiresponses

import (
"errors"
"fmt"
"net/http"

Expand Down Expand Up @@ -64,7 +63,7 @@ func (f *FailureResponse) LoggerAction() string {
// AppendErrorMessage returns an error with the message updated. All other properties are preserved.
func (f *FailureResponse) AppendErrorMessage(msg string) *FailureResponse {
return &FailureResponse{
error: errors.New(fmt.Sprintf("%s %s", f.Error(), msg)),
error: fmt.Errorf("%s %s", f.Error(), msg),
statusCode: f.statusCode,
loggerAction: f.loggerAction,
emptyResponse: f.emptyResponse,
Expand Down
2 changes: 1 addition & 1 deletion domain/service_plan_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var _ = Describe("ServicePlanMetadata", func() {
Bullets: []string{"hello", "its me"},
DisplayName: "name",
AdditionalMetadata: map[string]interface{}{
"foo": make(chan int, 0),
"foo": make(chan int),
},
}
_, err := json.Marshal(metadata)
Expand Down
1 change: 1 addition & 0 deletions fakes/staticcheck.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checks = []
4 changes: 4 additions & 0 deletions staticcheck.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# When adding staticcheck, we thought it was better to get it working with some checks disabled
# rather than fixing all the problems in one go. Some problems cannot be fixed without making
# breaking changes.
checks = ["all", "-SA1019", "-ST1000", "-ST1003", "-ST1005", "-ST1012", "-ST1021", "-SA1029", "-ST1020"]
1 change: 1 addition & 0 deletions tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package tools
import (
_ "github.com/maxbrunsfeld/counterfeiter/v6"
_ "github.com/onsi/ginkgo"
_ "honnef.co/go/tools/cmd/staticcheck"
)

// This file imports packages that are used when running go generate, or used
Expand Down

0 comments on commit f3efa40

Please sign in to comment.