Skip to content

Commit

Permalink
🚨 Fix naked returns lint errors from new golangci-lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Danieloni1 committed Jun 19, 2023
1 parent 303a959 commit 206dbb3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions mediaapi/routing/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func (r *downloadRequest) addDownloadFilenameToHeaders(
}

if len(filename) == 0 {
w.Header().Set("Content-Disposition", "attachment")
return nil
}

Expand Down Expand Up @@ -377,13 +378,13 @@ func (r *downloadRequest) addDownloadFilenameToHeaders(
// that would otherwise be parsed as a control character in the
// Content-Disposition header
w.Header().Set("Content-Disposition", fmt.Sprintf(
`inline; filename=%s%s%s`,
`attachment; filename=%s%s%s`,
quote, unescaped, quote,
))
} else {
// For UTF-8 filenames, we quote always, as that's the standard
w.Header().Set("Content-Disposition", fmt.Sprintf(
`inline; filename*=utf-8''%s`,
`attachment; filename*=utf-8''%s`,
url.QueryEscape(unescaped),
))
}
Expand Down
4 changes: 2 additions & 2 deletions roomserver/internal/perform/perform_peek.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (r *Peeker) performPeekRoomByID(
content := map[string]string{}
if err = json.Unmarshal(ev.Content(), &content); err != nil {
util.GetLogger(ctx).WithError(err).Error("json.Unmarshal for history visibility failed")
return
return "", err
}
if visibility, ok := content["history_visibility"]; ok {
worldReadable = visibility == "world_readable"
Expand Down Expand Up @@ -219,7 +219,7 @@ func (r *Peeker) performPeekRoomByID(
},
})
if err != nil {
return
return "", err
}

// By this point, if req.RoomIDOrAlias contained an alias, then
Expand Down
7 changes: 4 additions & 3 deletions syncapi/routing/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,12 @@ func (r *messagesReq) retrieveEvents() (
clientEvents []synctypes.ClientEvent, start,
end types.TopologyToken, err error,
) {
emptyToken := types.TopologyToken{}
// Retrieve the events from the local database.
streamEvents, err := r.snapshot.GetEventsInTopologicalRange(r.ctx, r.from, r.to, r.roomID, r.filter, r.backwardOrdering)
if err != nil {
err = fmt.Errorf("GetEventsInRange: %w", err)
return
return []synctypes.ClientEvent{}, emptyToken, emptyToken, err
}

var events []*gomatrixserverlib.HeaderedEvent
Expand All @@ -314,11 +315,11 @@ func (r *messagesReq) retrieveEvents() (
// on the ordering), or we've reached a backward extremity.
if len(streamEvents) == 0 {
if events, err = r.handleEmptyEventsSlice(); err != nil {
return
return []synctypes.ClientEvent{}, emptyToken, emptyToken, err
}
} else {
if events, err = r.handleNonEmptyEventsSlice(streamEvents); err != nil {
return
return []synctypes.ClientEvent{}, emptyToken, emptyToken, err
}
}

Expand Down
4 changes: 2 additions & 2 deletions syncapi/streams/stream_pdu.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (p *PDUStreamProvider) getJoinResponseForCompleteSync(

stateEvents, err := snapshot.CurrentState(ctx, roomID, stateFilter, excludingEventIDs)
if err != nil {
return
return jr, err
}

jr.Summary, err = snapshot.GetRoomSummary(ctx, roomID, device.UserID)
Expand Down Expand Up @@ -534,7 +534,7 @@ func (p *PDUStreamProvider) getJoinResponseForCompleteSync(
}
backwardTopologyPos, backwardStreamPos, err = snapshot.PositionInTopology(ctx, event.EventID())
if err != nil {
return
return jr, err
}
prevBatch = &types.TopologyToken{
Depth: backwardTopologyPos,
Expand Down
4 changes: 2 additions & 2 deletions userapi/storage/shared/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func (d *Database) CreateDevice(
for i := 1; i <= 5; i++ {
newDeviceID, returnErr = generateDeviceID()
if returnErr != nil {
return
return nil, returnErr
}

returnErr = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
Expand All @@ -651,7 +651,7 @@ func (d *Database) CreateDevice(
return err
})
if returnErr == nil {
return
return dev, nil
}
}
}
Expand Down

0 comments on commit 206dbb3

Please sign in to comment.