0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-06-14 10:28:24 +02:00

Add misspell and gofmt simplify to the pre-commit hooks (#138)

This commit is contained in:
Mark Haines 2017-06-12 18:30:47 +01:00 committed by GitHub
parent 7cbdab30f4
commit 472155837b
8 changed files with 25 additions and 10 deletions

View file

@ -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:

View file

@ -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.

View file

@ -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

View file

@ -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"`

View file

@ -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),
},
}

View file

@ -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

View file

@ -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

View file

@ -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)