From 735a423c76aa98173c2f2664c3a3c40c9c295d5c Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 12 Jun 2017 19:37:49 +0100 Subject: [PATCH 1/3] Add misspell and ineffassign to the pre-commit hooks --- client.go | 2 +- hooks/pre-commit | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 051c1f8..65960d6 100644 --- a/client.go +++ b/client.go @@ -79,7 +79,7 @@ func (cli *Client) BuildBaseURL(urlPath ...string) string { return hsURL.String() } -// BuildURLWithQuery builds a URL with query paramters in addition to the Client's homeserver/prefix/access_token set already. +// BuildURLWithQuery builds a URL with query parameters in addition to the Client's homeserver/prefix/access_token set already. func (cli *Client) BuildURLWithQuery(urlPath []string, urlQuery map[string]string) string { u, _ := url.Parse(cli.BuildURL(urlPath...)) q := u.Query() diff --git a/hooks/pre-commit b/hooks/pre-commit index 41df674..bb0a27f 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -3,6 +3,23 @@ set -eu golint +misspell --error . + +# 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 . 2>&1 | read +then + echo "Error: not all code had been formatted with gofmt." + echo "Fixing the following files" + gofmt -s -w -l . + echo + echo "Please add them to the commit" + git status --short + exit 1 +fi + +ineffassign . + go fmt go tool vet --all --shadow . gocyclo -over 12 . From af759cbc2bb4bcbecea871c6f3e9cb8876a80370 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 12 Jun 2017 19:42:48 +0100 Subject: [PATCH 2/3] Add a .travis.yml --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..78fad1d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: go +go: + - 1.8 +install: + - go get github.com/golang/lint/golint + - go get github.com/fzipp/gocyclo + - go get golang.org/x/crypto/ed25519 + - go get github.com/matrix-org/util + - go get github.com/matrix-org/gomatrix + - go get github.com/client9/misspell/... + - go get github.com/gordonklaus/ineffassign +script: ./hooks/pre-commit From 6f5f4de2eb5431ad728f2546c0686a7d024a45b1 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 12 Jun 2017 19:44:56 +0100 Subject: [PATCH 3/3] Remove unneed dependencies from travis.yml --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78fad1d..fadc326 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,6 @@ go: install: - go get github.com/golang/lint/golint - go get github.com/fzipp/gocyclo - - go get golang.org/x/crypto/ed25519 - - go get github.com/matrix-org/util - - go get github.com/matrix-org/gomatrix - go get github.com/client9/misspell/... - go get github.com/gordonklaus/ineffassign script: ./hooks/pre-commit