mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-23 07:33:32 -06:00
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:
|
||||
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
|
||||
|
||||
staticcheck:
|
||||
@sh -c "'$(CURDIR)/scripts/staticcheck.sh'"
|
||||
|
||||
website:
|
||||
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
|
||||
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
|
||||
@ -46,4 +49,4 @@ endif
|
||||
# under parallel conditions.
|
||||
.NOTPARALLEL:
|
||||
|
||||
.PHONY: fmtcheck generate protobuf website website-test
|
||||
.PHONY: fmtcheck generate protobuf website website-test staticcheck
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Check gofmt
|
||||
echo "==> Checking that code complies with gofmt requirements..."
|
||||
gofmt_files=$(gofmt -l `find . -name '*.go' | grep -v vendor`)
|
||||
# Check go fmt
|
||||
echo "==> Checking that code complies with go fmt requirements..."
|
||||
gofmt_files=$(go fmt ./...)
|
||||
if [[ -n ${gofmt_files} ]]; then
|
||||
echo 'gofmt needs running on the following 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
|
||||
fi
|
||||
|
||||
|
16
scripts/staticcheck.sh
Executable file
16
scripts/staticcheck.sh
Executable file
@ -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
Block a user