From c53fea9e9c3ea5f88ebbf8e3d2e516a3d72d422b Mon Sep 17 00:00:00 2001 From: songy23 Date: Wed, 31 Jul 2019 15:25:34 -0700 Subject: [PATCH] Add static check Fixes #155. --- Makefile | 16 +++++++++++----- go.mod | 1 + go.sum | 1 + internal/tools.go | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 38291aadaf2..f84e6bae5d2 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ GOOS=$(shell go env GOOS) ADDLICENCESE= addlicense MISSPELL=misspell -error MISSPELL_CORRECTION=misspell -w +STATICCHECK=staticcheck GIT_SHA=$(shell git rev-parse --short HEAD) BUILD_INFO_IMPORT_PATH=github.com/open-telemetry/opentelemetry-service/internal/version @@ -38,10 +39,10 @@ all-pkgs: all-srcs: @echo $(ALL_SRC) | tr ' ' '\n' | sort -.DEFAULT_GOAL := addlicense-fmt-vet-lint-goimports-misspell-test +.DEFAULT_GOAL := addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test -.PHONY: addlicense-fmt-vet-lint-goimports-misspell-test -addlicense-fmt-vet-lint-goimports-misspell-test: addlicense fmt vet lint goimports misspell test +.PHONY: addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test +addlicense-fmt-vet-lint-goimports-misspell-test: addlicense fmt vet lint goimports misspell staticcheck test .PHONY: e2e-test e2e-test: otelsvc @@ -52,7 +53,7 @@ test: $(GOTEST) $(GOTEST_OPT) $(ALL_PKGS) .PHONY: travis-ci -travis-ci: fmt vet lint goimports misspell test-with-cover otelsvc +travis-ci: fmt vet lint goimports misspell staticcheck test-with-cover otelsvc $(MAKE) -C testbed install-tools $(MAKE) -C testbed runtests @@ -117,6 +118,10 @@ misspell: misspell-correction: $(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC) +.PHONY: staticcheck +staticcheck: + $(STATICCHECK) ./... + .PHONY: vet vet: @$(GOVET) ./... @@ -128,7 +133,8 @@ install-tools: github.com/google/addlicense \ golang.org/x/lint/golint \ golang.org/x/tools/cmd/goimports \ - github.com/client9/misspell/cmd/misspell + github.com/client9/misspell/cmd/misspell \ + honnef.co/go/tools/cmd/staticcheck .PHONY: otelsvc otelsvc: diff --git a/go.mod b/go.mod index cb2fe6cdbe7..12aa57c8806 100644 --- a/go.mod +++ b/go.mod @@ -52,4 +52,5 @@ require ( google.golang.org/api v0.5.0 google.golang.org/grpc v1.21.0 gopkg.in/yaml.v2 v2.2.2 + honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a ) diff --git a/go.sum b/go.sum index 7c40ea2de36..95717b27514 100644 --- a/go.sum +++ b/go.sum @@ -516,6 +516,7 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a h1:/8zB6iBfHCl1qAnEAWwGPNrUvapuy6CPla1VM0k8hQw= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.0.0-20181213150558-05914d821849 h1:WZFcFPXmLR7g5CxQNmjWv0mg8qulJLxDghbzS4pQtzY= k8s.io/api v0.0.0-20181213150558-05914d821849/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= diff --git a/internal/tools.go b/internal/tools.go index e4138a6335f..4b1106988a7 100644 --- a/internal/tools.go +++ b/internal/tools.go @@ -28,4 +28,5 @@ import ( _ "github.com/jstemmer/go-junit-report" _ "golang.org/x/lint/golint" _ "golang.org/x/tools/cmd/goimports" + _ "honnef.co/go/tools/cmd/staticcheck" )