diff --git a/.travis.yml b/.travis.yml index 2b5e09477..932a5a608 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ install: - go get github.com/constabulary/gb/... - go get github.com/golang/lint/golint - go get github.com/fzipp/gocyclo + - go get github.com/client9/misspell/... # Generate a self-signed X.509 certificate for TLS. before_script: diff --git a/WIRING.md b/WIRING.md index caa0df078..f55475fea 100644 --- a/WIRING.md +++ b/WIRING.md @@ -163,7 +163,7 @@ choke-point to implement ratelimiting and backoff correctly. * Reads the current state of the rooms from the logs to track the intersection of room membership between users. - * Reads updates to presence from the logs writen by the FS and the CPS. + * Reads updates to presence from the logs written by the FS and the CPS. * Reads when clients sync from the logs from the Client Sync. * Tracks any timers for users. * Writes the changes to presence state to the logs. diff --git a/hooks/pre-commit b/hooks/pre-commit index 2853d60a1..523ce0af2 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -3,7 +3,21 @@ set -eu golint src/... -go fmt ./src/... +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 + go tool vet --all --shadow ./src gocyclo -over 12 src/ gb test diff --git a/src/github.com/matrix-org/dendrite/clientapi/writers/register.go b/src/github.com/matrix-org/dendrite/clientapi/writers/register.go index da03126b3..d09b371d0 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/writers/register.go +++ b/src/github.com/matrix-org/dendrite/clientapi/writers/register.go @@ -26,7 +26,7 @@ const ( // Registration parameters vary depending on the request, and will need to remembered across // sessions. If no parameters are supplied, the server should use the parameters previously // remembered. If ANY parameters are supplied, the server should REPLACE all knowledge of -// previous paramters with the ones supplied. This mean you cannot "build up" request params. +// previous parameters with the ones supplied. This mean you cannot "build up" request params. type registerRequest struct { // registration parameters. Password string `json:"password"` diff --git a/src/github.com/matrix-org/dendrite/federationapi/readers/keys.go b/src/github.com/matrix-org/dendrite/federationapi/readers/keys.go index edae0c989..572cfb52b 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/readers/keys.go +++ b/src/github.com/matrix-org/dendrite/federationapi/readers/keys.go @@ -43,7 +43,7 @@ func localKeys(cfg config.FederationAPI, validUntil time.Time) (*gomatrixserverl publicKey := cfg.PrivateKey.Public().(ed25519.PublicKey) keys.VerifyKeys = map[gomatrixserverlib.KeyID]gomatrixserverlib.VerifyKey{ - cfg.KeyID: gomatrixserverlib.VerifyKey{ + cfg.KeyID: { gomatrixserverlib.Base64String(publicKey), }, } diff --git a/src/github.com/matrix-org/dendrite/federationapi/writers/send.go b/src/github.com/matrix-org/dendrite/federationapi/writers/send.go index 14e1fae6c..d799c94c9 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/writers/send.go +++ b/src/github.com/matrix-org/dendrite/federationapi/writers/send.go @@ -184,7 +184,7 @@ func (t *txnReq) processEventWithMissingState(e gomatrixserverlib.Event) error { // or /state. // Synapse will attempt to do 1 and if that fails or if the gap is // too large then it will attempt 2. - // Synapse will use /state_ids if possible since ususally the state + // Synapse will use /state_ids if possible since usually the state // is largely unchanged and it is more efficient to fetch a list of // event ids and then use /event to fetch the individual events. // However not all version of synapse support /state_ids so you may diff --git a/src/github.com/matrix-org/dendrite/syncapi/sync/notifier_test.go b/src/github.com/matrix-org/dendrite/syncapi/sync/notifier_test.go index 784faf578..03e39da07 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/sync/notifier_test.go +++ b/src/github.com/matrix-org/dendrite/syncapi/sync/notifier_test.go @@ -104,7 +104,7 @@ func TestImmediateNotification(t *testing.T) { func TestNewEventAndJoinedToRoom(t *testing.T) { n := NewNotifier(streamPositionBefore) n.setUsersJoinedToRooms(map[string][]string{ - roomID: []string{alice, bob}, + roomID: {alice, bob}, }) var wg sync.WaitGroup @@ -132,7 +132,7 @@ func TestNewEventAndJoinedToRoom(t *testing.T) { func TestNewInviteEventForUser(t *testing.T) { n := NewNotifier(streamPositionBefore) n.setUsersJoinedToRooms(map[string][]string{ - roomID: []string{alice, bob}, + roomID: {alice, bob}, }) var wg sync.WaitGroup @@ -160,7 +160,7 @@ func TestNewInviteEventForUser(t *testing.T) { func TestMultipleRequestWakeup(t *testing.T) { n := NewNotifier(streamPositionBefore) n.setUsersJoinedToRooms(map[string][]string{ - roomID: []string{alice, bob}, + roomID: {alice, bob}, }) var wg sync.WaitGroup @@ -198,7 +198,7 @@ func TestNewEventAndWasPreviouslyJoinedToRoom(t *testing.T) { // Make sure alice gets woken up only and not bob as well. n := NewNotifier(streamPositionBefore) n.setUsersJoinedToRooms(map[string][]string{ - roomID: []string{alice, bob}, + roomID: {alice, bob}, }) var leaveWG sync.WaitGroup diff --git a/src/github.com/matrix-org/dendrite/syncapi/types/types.go b/src/github.com/matrix-org/dendrite/syncapi/types/types.go index a1c3e3c76..adc764c32 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/types/types.go +++ b/src/github.com/matrix-org/dendrite/syncapi/types/types.go @@ -50,7 +50,7 @@ func NewResponse(pos StreamPosition) *Response { // Make sure we send the next_batch as a string. We don't want to confuse clients by sending this // as an integer even though (at the moment) it is. res.NextBatch = pos.String() - // Pre-initalise the maps. Synapse will return {} even if there are no rooms under a specific section, + // Pre-initialise the maps. Synapse will return {} even if there are no rooms under a specific section, // so let's do the same thing. Bonus: this means we can't get dreaded 'assignment to entry in nil map' errors. res.Rooms.Join = make(map[string]JoinResponse) res.Rooms.Invite = make(map[string]InviteResponse)