Enable stricter linting with golangci-lint (#316)

* update golangci-lint

* add golangci config file w/ more linters

* correct issues flagged by stricter linters

* add more generous timeout for golangci-lint

* add some style + formatting guidelines

* move timeout to config file

* go fmt
This commit is contained in:
tobi 2021-11-22 08:46:19 +01:00 committed by GitHub
commit f8630348b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 227 additions and 163 deletions

View file

@ -137,8 +137,7 @@ func (a *accountDB) GetInstanceAccount(ctx context.Context, domain string) (*gts
WhereGroup(" AND ", whereEmptyOrNull("domain"))
}
err := q.Scan(ctx)
if err != nil {
if err := q.Scan(ctx); err != nil {
return nil, a.conn.ProcessError(err)
}
return account, nil
@ -155,8 +154,7 @@ func (a *accountDB) GetAccountLastPosted(ctx context.Context, accountID string)
Where("account_id = ?", accountID).
Column("created_at")
err := q.Scan(ctx)
if err != nil {
if err := q.Scan(ctx); err != nil {
return time.Time{}, a.conn.ProcessError(err)
}
return status.CreatedAt, nil
@ -168,11 +166,12 @@ func (a *accountDB) SetAccountHeaderOrAvatar(ctx context.Context, mediaAttachmen
}
var headerOrAVI string
if mediaAttachment.Avatar {
switch {
case mediaAttachment.Avatar:
headerOrAVI = "avatar"
} else if mediaAttachment.Header {
case mediaAttachment.Header:
headerOrAVI = "header"
} else {
default:
return errors.New("given media attachment was neither a header nor an avatar")
}
@ -202,8 +201,7 @@ func (a *accountDB) GetLocalAccountByUsername(ctx context.Context, username stri
Where("username = ?", username).
WhereGroup(" AND ", whereEmptyOrNull("domain"))
err := q.Scan(ctx)
if err != nil {
if err := q.Scan(ctx); err != nil {
return nil, a.conn.ProcessError(err)
}
return account, nil
@ -308,8 +306,7 @@ func (a *accountDB) GetAccountBlocks(ctx context.Context, accountID string, maxI
fq = fq.Limit(limit)
}
err := fq.Scan(ctx)
if err != nil {
if err := fq.Scan(ctx); err != nil {
return nil, "", "", a.conn.ProcessError(err)
}