From 27990f8d784af22bc92cbb13afa59da8246451ec Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 5 Sep 2017 16:34:30 +0100 Subject: [PATCH] Convert to using gometalinter --- hooks/pre-commit | 25 ++++++++----------------- linter.json | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 linter.json diff --git a/hooks/pre-commit b/hooks/pre-commit index abce0f598..56a864161 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -2,29 +2,20 @@ set -eu -golint src/... +echo "Looking for lint..." +GOPATH="$(pwd):$(pwd)/vendor" gometalinter --config=linter.json ./... + +echo "Double checking spelling..." misspell -error src *.md -# gofmt doesn't exit with an error code if the files don't match the expected -# format. So we have to run it and see if it outputs anything. -if gofmt -l -s ./src/ 2>&1 | read -then - echo "Error: not all code had been formatted with gofmt." - echo "Fixing the following files" - gofmt -s -w -l ./src/ - echo - echo "Please add them to the commit" - git status --short - exit 1 -fi - -ineffassign ./src/ -go tool vet --all --shadow ./src -gocyclo -over 12 src/ +echo "Testing..." gb test # Check that all the packages can build. # When `go build` is given multiple packages it won't output anything, and just # checks that everything builds. This seems to do a better job of handling # missing imports than `gb build` does. +echo "Double checking it builds..." GOPATH=$(pwd):$(pwd)/vendor go build github.com/matrix-org/dendrite/cmd/... + +echo "Done!" diff --git a/linter.json b/linter.json new file mode 100644 index 000000000..c2a3d80e0 --- /dev/null +++ b/linter.json @@ -0,0 +1,17 @@ +{ + "Vendor": true, + "Cyclo": 12, + "Enable": [ + "vetshadow", + "gotype", + "deadcode", + "gocyclo", + "golint", + "varcheck", + "structcheck", + "aligncheck", + "ineffassign", + "gas", + "misspell" + ] +}