add staticcheck make target
cleanup the old fmtcheck script while we're in here
This commit is contained in:
parent
5eb7170f70
commit
a3fb07d008
5
Makefile
5
Makefile
|
@ -20,6 +20,9 @@ protobuf:
|
||||||
fmtcheck:
|
fmtcheck:
|
||||||
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
|
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
|
||||||
|
|
||||||
|
staticcheck:
|
||||||
|
@sh -c "'$(CURDIR)/scripts/staticcheck.sh'"
|
||||||
|
|
||||||
website:
|
website:
|
||||||
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
|
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
|
||||||
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
|
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
|
||||||
|
@ -46,4 +49,4 @@ endif
|
||||||
# under parallel conditions.
|
# under parallel conditions.
|
||||||
.NOTPARALLEL:
|
.NOTPARALLEL:
|
||||||
|
|
||||||
.PHONY: fmtcheck generate protobuf website website-test
|
.PHONY: fmtcheck generate protobuf website website-test staticcheck
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Check gofmt
|
# Check go fmt
|
||||||
echo "==> Checking that code complies with gofmt requirements..."
|
echo "==> Checking that code complies with go fmt requirements..."
|
||||||
gofmt_files=$(gofmt -l `find . -name '*.go' | grep -v vendor`)
|
gofmt_files=$(go fmt ./...)
|
||||||
if [[ -n ${gofmt_files} ]]; then
|
if [[ -n ${gofmt_files} ]]; then
|
||||||
echo 'gofmt needs running on the following files:'
|
echo 'gofmt needs running on the following files:'
|
||||||
echo "${gofmt_files}"
|
echo "${gofmt_files}"
|
||||||
echo "You can use the command: \`gofmt -w .\` to reformat code."
|
echo "You can use the command: \`go fmt\` to reformat code."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "==> Checking that code complies with static analysis requirements..."
|
||||||
|
# Skip legacy code which is frozen, and can be removed once we can refactor the
|
||||||
|
# remote backends to no longer require it.
|
||||||
|
skip="internal/legacy|backend/remote-state/"
|
||||||
|
|
||||||
|
# Skip generated code for protobufs.
|
||||||
|
skip=$skip"|internal/planproto|internal/tfplugin5|internal/tfplugin6"
|
||||||
|
|
||||||
|
packages=$(go list ./... | egrep -v ${skip})
|
||||||
|
|
||||||
|
# We are skipping style-related checks, since terraform intentionally breaks
|
||||||
|
# some of these. The goal here is to find issues that reduce code clarity, or
|
||||||
|
# may result in bugs.
|
||||||
|
staticcheck -checks 'all,-ST*' ${packages}
|
Loading…
Reference in New Issue