0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-11-19 08:10:57 +01:00

Fix linting errors in go1.9.1 (#336)

Fix linting errors in go1.9.1
This commit is contained in:
Erik Johnston 2017-11-15 11:13:09 +00:00 committed by Richard van der Hoff
parent ff8b229192
commit 139fae988e
11 changed files with 21 additions and 65 deletions

View file

@ -96,11 +96,7 @@ func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
return err
}
if err := s.db.UpdateMemberships(context.TODO(), events, output.NewRoomEvent.RemovesStateEventIDs); err != nil {
return err
}
return nil
return s.db.UpdateMemberships(context.TODO(), events, output.NewRoomEvent.RemovesStateEventIDs)
}
// lookupStateEvents looks up the state events that are added by a new event.

View file

@ -355,9 +355,5 @@ func emit3PIDInviteEvent(
return err
}
if err := producer.SendEvents(ctx, []gomatrixserverlib.Event{*event}, cfg.Matrix.ServerName); err != nil {
return err
}
return nil
return producer.SendEvents(ctx, []gomatrixserverlib.Event{*event}, cfg.Matrix.ServerName)
}

View file

@ -113,10 +113,7 @@ func WriteConfig(cfg *config.Dendrite, configDir string) error {
if err != nil {
return err
}
if err = ioutil.WriteFile(filepath.Join(configDir, ConfigFile), data, 0666); err != nil {
return err
}
return nil
return ioutil.WriteFile(filepath.Join(configDir, ConfigFile), data, 0666)
}
// NewMatrixKey generates a new ed25519 matrix server key and writes it to a file.

View file

@ -63,11 +63,11 @@ func GetProfile(
switch field {
case "displayname":
res = common.DisplayName{
profile.DisplayName,
DisplayName: profile.DisplayName,
}
case "avatar_url":
res = common.AvatarURL{
profile.AvatarURL,
AvatarURL: profile.AvatarURL,
}
default:
code = 400
@ -75,8 +75,8 @@ func GetProfile(
}
} else {
res = common.ProfileResponse{
profile.AvatarURL,
profile.DisplayName,
AvatarURL: profile.AvatarURL,
DisplayName: profile.DisplayName,
}
}

View file

@ -170,11 +170,7 @@ func (t *txnReq) processEvent(e gomatrixserverlib.Event) error {
// TODO: Check that the event is allowed by its auth_events.
// pass the event to the roomserver
if err := t.producer.SendEvents(t.context, []gomatrixserverlib.Event{e}, api.DoNotSendToOtherServers); err != nil {
return err
}
return nil
return t.producer.SendEvents(t.context, []gomatrixserverlib.Event{e}, api.DoNotSendToOtherServers)
}
func checkAllowedByState(e gomatrixserverlib.Event, stateEvents []gomatrixserverlib.Event) error {
@ -218,8 +214,5 @@ func (t *txnReq) processEventWithMissingState(e gomatrixserverlib.Event) error {
return err
}
// pass the event along with the state to the roomserver
if err := t.producer.SendEventWithState(t.context, state, e); err != nil {
return err
}
return nil
return t.producer.SendEventWithState(t.context, state, e)
}

View file

@ -54,11 +54,7 @@ func (d *Database) prepare() error {
return err
}
if err = d.PartitionOffsetStatements.Prepare(d.db, "federationsender"); err != nil {
return err
}
return nil
return d.PartitionOffsetStatements.Prepare(d.db, "federationsender")
}
// UpdateRoom updates the joined hosts for a room and returns what the joined

View file

@ -22,7 +22,6 @@ import (
"net/url"
"path"
log "github.com/sirupsen/logrus"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/common/config"
"github.com/matrix-org/dendrite/mediaapi/fileutils"
@ -31,6 +30,7 @@ import (
"github.com/matrix-org/dendrite/mediaapi/types"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
log "github.com/sirupsen/logrus"
)
// uploadRequest metadata included in or derivable from an upload request
@ -161,14 +161,10 @@ func (r *uploadRequest) doUpload(
}
}
if resErr := r.storeFileAndMetadata(
return r.storeFileAndMetadata(
ctx, tmpDir, cfg.Media.AbsBasePath, db, cfg.Media.ThumbnailSizes,
activeThumbnailGeneration, cfg.Media.MaxThumbnailGenerators,
); resErr != nil {
return resErr
}
return nil
)
}
// Validate validates the uploadRequest fields

View file

@ -23,15 +23,13 @@ type statements struct {
thumbnail thumbnailStatements
}
func (s *statements) prepare(db *sql.DB) error {
var err error
func (s *statements) prepare(db *sql.DB) (err error) {
if err = s.media.prepare(db); err != nil {
return err
return
}
if err = s.thumbnail.prepare(db); err != nil {
return err
return
}
return nil
return
}

View file

@ -79,11 +79,7 @@ func (r *RoomserverAliasAPI) SetRoomAlias(
// At this point we've already committed the alias to the database so we
// shouldn't cancel this request.
// TODO: Ensure that we send unsent events when if server restarts.
if err := r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, request.RoomID); err != nil {
return err
}
return nil
return r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, request.RoomID)
}
// GetAliasRoomID implements api.RoomserverAliasAPI
@ -123,11 +119,7 @@ func (r *RoomserverAliasAPI) RemoveRoomAlias(
// At this point we've already committed the alias to the database so we
// shouldn't cancel this request.
// TODO: Ensure that we send unsent events when if server restarts.
if err := r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, roomID); err != nil {
return err
}
return nil
return r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, roomID)
}
type roomAliasesContent struct {

View file

@ -129,11 +129,7 @@ func processRoomEvent(
}
// Update the extremities of the event graph for the room
if err := updateLatestEvents(ctx, db, ow, roomNID, stateAtEvent, event, input.SendAsServer); err != nil {
return err
}
return nil
return updateLatestEvents(ctx, db, ow, roomNID, stateAtEvent, event, input.SendAsServer)
}
func processInviteEvent(

View file

@ -162,11 +162,7 @@ func (u *latestEventsUpdater) doUpdateLatestEvents() error {
return err
}
if err = u.updater.MarkEventAsSent(u.stateAtEvent.EventNID); err != nil {
return err
}
return nil
return u.updater.MarkEventAsSent(u.stateAtEvent.EventNID)
}
func (u *latestEventsUpdater) latestState() error {