fix golangci-lint warnings

This commit is contained in:
Simon THOBY
2022-09-06 21:19:56 +02:00
committed by Simon Thoby
parent 34872abd81
commit 1da787f91d
4 changed files with 13 additions and 12 deletions

View File

@@ -120,7 +120,7 @@ func (a *AppServiceNamespaces) containsRoom(roomID id.RoomID) bool {
return false
}
// nolint: wrapcheck
//nolint:wrapcheck
func (b *Bmatrix) startAppService() error {
wrapper := b.appService
// TODO: detect service completion and rerun automatically

View File

@@ -38,7 +38,7 @@ func (b *Bmatrix) ignoreBridgingEvents(ev *event.Event) bool {
return false
}
//nolint: funlen
//nolint:funlen
func (b *Bmatrix) handleEvent(origin EventOrigin, ev *event.Event) {
b.RLock()
channel, ok := b.RoomMap[ev.RoomID]
@@ -170,7 +170,7 @@ func (b *Bmatrix) handleMessage(rmsg config.Message, ev *event.Event) {
rmsg.Avatar = b.getAvatarURL(ev.RoomID, ev.Sender)
//nolint: exhaustive
//nolint:exhaustive
switch msg.MsgType {
case event.MsgEmote:
// Do we have a /me action
@@ -264,7 +264,7 @@ func (b *Bmatrix) handleUploadFiles(msg *config.Message, channel id.RoomID) (str
}
// handleUploadFile handles native upload of a file.
//nolint: funlen
//nolint:funlen
func (b *Bmatrix) handleUploadFile(msg *config.Message, channel id.RoomID, fi *config.FileInfo) {
content := bytes.NewReader(*fi.Data)
sp := strings.Split(fi.Name, ".")

View File

@@ -247,7 +247,7 @@ type SendMessageEventWrapper struct {
inner *matrix.Client
}
//nolint: wrapcheck
//nolint:wrapcheck
func (w SendMessageEventWrapper) SendMessageEvent(roomID id.RoomID, eventType event.Type, contentJSON interface{}) (*matrix.RespSendEvent, error) {
return w.inner.SendMessageEvent(roomID, eventType, contentJSON)
}
@@ -286,7 +286,7 @@ func (b *Bmatrix) uploadAvatar(channelID id.RoomID, mxid id.UserID, intent *matr
return nil
}
//nolint: exhaustruct
//nolint:exhaustruct
matrixResp, err := b.mc.UploadMedia(matrix.ReqUploadMedia{
ContentBytes: data,
ContentType: resp.Header.Get("Content-Type"),
@@ -305,7 +305,7 @@ func (b *Bmatrix) uploadAvatar(channelID id.RoomID, mxid id.UserID, intent *matr
return nil
}
//nolint: wrapcheck
//nolint:wrapcheck
func (b *Bmatrix) sendMessageEventWithRetries(channel id.RoomID, message event.MessageEventContent, username string, avatarURL string) (string, error) {
var (
resp *matrix.RespSendEvent
@@ -333,7 +333,7 @@ func (b *Bmatrix) sendMessageEventWithRetries(channel id.RoomID, message event.M
// if we can't change the display name it's not great but not the end of the world either, ignore it
// TODO: do not perform this action on every message, with an in-memory cache or something
_ = intent.SetDisplayName(username)
//nolint: errcheck
//nolint:errcheck
go b.uploadAvatar(channel, id.UserID(bridgeUserID), intent, avatarURL)
client = intent
} else {

View File

@@ -1,4 +1,4 @@
// nolint: exhaustivestruct
//nolint:exhaustivestruct
package bmatrix
import (
@@ -80,7 +80,7 @@ func (b *Bmatrix) Connect() error {
resp, err := b.mc.Login(&matrix.ReqLogin{
Type: matrix.AuthTypePassword,
Password: b.GetString("Password"),
Identifier: matrix.UserIdentifier{Type: matrix.IdentifierTypeUser, User: b.GetString("Login")}, //nolint: exhaustruct
Identifier: matrix.UserIdentifier{Type: matrix.IdentifierTypeUser, User: b.GetString("Login")}, //nolint:exhaustruct
StoreCredentials: true,
})
if err != nil {
@@ -195,7 +195,7 @@ func (b *Bmatrix) Start() error {
return nil
}
//nolint: funlen,gocognit,gocyclo
//nolint:funlen,gocognit,gocyclo
func (b *Bmatrix) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Sending %#v", msg)
@@ -334,7 +334,8 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
// DontProcessOldEvents returns true if a sync event should be considered for further processing.
// We use that function to filter out events we have already read.
//nolint: gocognit
//
//nolint:gocognit
func (b *Bmatrix) DontProcessOldEvents(resp *matrix.RespSync, since string) bool {
// we only filter old events in the initial sync(), because subsequent sync()
// (where since != "") should only return new events