Add vet linter
MODIFY
linter-fast.json
linter-fast.json
"ineffassign",
"gas",
"misspell",
- "errcheck"
+ "errcheck",
+ "vet"
]
}

MODIFY
linter.json
linter.json
"gas",
"misspell",
"unparam",
- "errcheck"
+ "errcheck",
+ "vet"
]
}

MODIFY
src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go
src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go
@@ -163,12 +163,12 @@ func createRoom(req *http.Request, device *authtypes.Device,
{"m.room.member", userID, membershipContent},
{"m.room.power_levels", "", common.InitialPowerLevelsContent(userID)},
// TODO: m.room.canonical_alias
- {"m.room.join_rules", "", common.JoinRulesContent{"public"}}, // FIXME: Allow this to be changed
- {"m.room.history_visibility", "", common.HistoryVisibilityContent{"joined"}}, // FIXME: Allow this to be changed
- {"m.room.guest_access", "", common.GuestAccessContent{"can_join"}}, // FIXME: Allow this to be changed
+ {"m.room.join_rules", "", common.JoinRulesContent{JoinRule: "public"}}, // FIXME: Allow this to be changed
+ {"m.room.history_visibility", "", common.HistoryVisibilityContent{HistoryVisibility: "joined"}}, // FIXME: Allow this to be changed
+ {"m.room.guest_access", "", common.GuestAccessContent{GuestAccess: "can_join"}}, // FIXME: Allow this to be changed
// TODO: Other initial state items
- {"m.room.name", "", common.NameContent{r.Name}}, // FIXME: Only send the name event if a name is supplied, to avoid sending a false room name removal event
- {"m.room.topic", "", common.TopicContent{r.Topic}},
+ {"m.room.name", "", common.NameContent{Name: r.Name}}, // FIXME: Only send the name event if a name is supplied, to avoid sending a false room name removal event
+ {"m.room.topic", "", common.TopicContent{Topic: r.Topic}},
// TODO: invite events
// TODO: 3pid invite events
// TODO: m.room.aliases

MODIFY
src/github.com/matrix-org/dendrite/cmd/dendrite-federation-api-server/main.go
src/github.com/matrix-org/dendrite/cmd/dendrite-federation-api-server/main.go
@@ -67,7 +67,7 @@ func main() {
keyRing := gomatrixserverlib.KeyRing{
KeyFetchers: []gomatrixserverlib.KeyFetcher{
// TODO: Use perspective key fetchers for production.
- &gomatrixserverlib.DirectKeyFetcher{federation.Client},
+ &gomatrixserverlib.DirectKeyFetcher{Client: federation.Client},
},
KeyDatabase: keyDB,
}

MODIFY
src/github.com/matrix-org/dendrite/common/config/config.go
src/github.com/matrix-org/dendrite/common/config/config.go
@@ -413,7 +413,7 @@ func fingerprintPEM(data []byte) *gomatrixserverlib.TLSFingerprint {
}
if certDERBlock.Type == "CERTIFICATE" {
digest := sha256.Sum256(certDERBlock.Bytes)
- return &gomatrixserverlib.TLSFingerprint{digest[:]}
+ return &gomatrixserverlib.TLSFingerprint{SHA256: digest[:]}
}
}
}

MODIFY
src/github.com/matrix-org/dendrite/common/keydb/server_key_table.go
src/github.com/matrix-org/dendrite/common/keydb/server_key_table.go
@@ -97,7 +97,8 @@ func (s *serverKeyStatements) bulkSelectServerKeys(
return nil, err
}
r := gomatrixserverlib.PublicKeyRequest{
- gomatrixserverlib.ServerName(serverName), gomatrixserverlib.KeyID(keyID),
+ ServerName: gomatrixserverlib.ServerName(serverName),
+ KeyID: gomatrixserverlib.KeyID(keyID),
}
results[r] = serverKeys
}

MODIFY
src/github.com/matrix-org/dendrite/federationapi/readers/keys.go
src/github.com/matrix-org/dendrite/federationapi/readers/keys.go
@@ -44,7 +44,7 @@ func localKeys(cfg config.Dendrite, validUntil time.Time) (*gomatrixserverlib.Se
keys.VerifyKeys = map[gomatrixserverlib.KeyID]gomatrixserverlib.VerifyKey{
cfg.Matrix.KeyID: {
- gomatrixserverlib.Base64String(publicKey),
+ Key: gomatrixserverlib.Base64String(publicKey),
},
}

MODIFY
src/github.com/matrix-org/dendrite/roomserver/input/authevents_test.go
src/github.com/matrix-org/dendrite/roomserver/input/authevents_test.go
package input
import (
- "github.com/matrix-org/dendrite/roomserver/types"
"testing"
+
+ "github.com/matrix-org/dendrite/roomserver/types"
)
func benchmarkStateEntryMapLookup(entries, lookups int64, b *testing.B) {
var list []types.StateEntry
for i := int64(0); i < entries; i++ {
- list = append(list, types.StateEntry{types.StateKeyTuple{
- types.EventTypeNID(i),
- types.EventStateKeyNID(i),
- }, types.EventNID(i)})
+ list = append(list, types.StateEntry{
+ StateKeyTuple: types.StateKeyTuple{
+ EventTypeNID: types.EventTypeNID(i),
+ EventStateKeyNID: types.EventStateKeyNID(i),
+ },
+ EventNID: types.EventNID(i),
+ })
}
for i := 0; i < b.N; i++ {
entryMap := stateEntryMap(list)
for j := int64(0); j < lookups; j++ {
entryMap.lookup(types.StateKeyTuple{
- types.EventTypeNID(j), types.EventStateKeyNID(j),
+ EventTypeNID: types.EventTypeNID(j),
+ EventStateKeyNID: types.EventStateKeyNID(j),
})
}
}
@@ -56,9 +61,9 @@ func BenchmarkStateEntryMap1000Lookup10000(b *testing.B) {
func TestStateEntryMap(t *testing.T) {
entryMap := stateEntryMap([]types.StateEntry{
- {types.StateKeyTuple{1, 1}, 1},
- {types.StateKeyTuple{1, 3}, 2},
- {types.StateKeyTuple{2, 1}, 3},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 3}, EventNID: 2},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 2, EventStateKeyNID: 1}, EventNID: 3},
})
testCases := []struct {
@@ -78,7 +83,7 @@ func TestStateEntryMap(t *testing.T) {
}
for _, testCase := range testCases {
- keyTuple := types.StateKeyTuple{testCase.inputTypeNID, testCase.inputStateKey}
+ keyTuple := types.StateKeyTuple{EventTypeNID: testCase.inputTypeNID, EventStateKeyNID: testCase.inputStateKey}
gotEventNID, gotOK := entryMap.lookup(keyTuple)
if testCase.wantOK != gotOK {
t.Fatalf("stateEntryMap lookup(%v): want ok to be %v, got %v", keyTuple, testCase.wantOK, gotOK)

MODIFY
src/github.com/matrix-org/dendrite/roomserver/state/state_test.go
src/github.com/matrix-org/dendrite/roomserver/state/state_test.go
package state
import (
- "github.com/matrix-org/dendrite/roomserver/types"
"testing"
+
+ "github.com/matrix-org/dendrite/roomserver/types"
)
func TestFindDuplicateStateKeys(t *testing.T) {
@@ -25,18 +26,18 @@ func TestFindDuplicateStateKeys(t *testing.T) {
Want []types.StateEntry
}{{
Input: []types.StateEntry{
- {types.StateKeyTuple{1, 1}, 1},
- {types.StateKeyTuple{1, 1}, 2},
- {types.StateKeyTuple{2, 2}, 3},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 2},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 2, EventStateKeyNID: 2}, EventNID: 3},
},
Want: []types.StateEntry{
- {types.StateKeyTuple{1, 1}, 1},
- {types.StateKeyTuple{1, 1}, 2},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 2},
},
}, {
Input: []types.StateEntry{
- {types.StateKeyTuple{1, 1}, 1},
- {types.StateKeyTuple{1, 2}, 2},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1},
+ {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 2}, EventNID: 2},
},
Want: nil,
}}

Add vet linter (#240)