forked from forgejo/forgejo
Add more linters to improve code readability (#19989)
Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability - nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length. - unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions - wastedassign - https://github.com/sanposhiho/wastedassign - wastedassign finds wasted assignment statements. - notlintlint - Reports ill-formed or insufficient nolint directives - stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005)
This commit is contained in:
parent
3289abcefc
commit
cb50375e2b
147 changed files with 402 additions and 397 deletions
|
@ -131,7 +131,7 @@ func (opts *FindNotificationOptions) ToSession(ctx context.Context) *xorm.Sessio
|
|||
// GetNotifications returns all notifications that fit to the given options.
|
||||
func GetNotifications(ctx context.Context, options *FindNotificationOptions) (nl NotificationList, err error) {
|
||||
err = options.ToSession(ctx).OrderBy("notification.updated_unix DESC").Find(&nl)
|
||||
return
|
||||
return nl, err
|
||||
}
|
||||
|
||||
// CountNotifications count all notifications that fit to the given options and ignore pagination.
|
||||
|
@ -291,7 +291,7 @@ func getNotificationsByIssueID(ctx context.Context, issueID int64) (notification
|
|||
err = db.GetEngine(ctx).
|
||||
Where("issue_id = ?", issueID).
|
||||
Find(¬ifications)
|
||||
return
|
||||
return notifications, err
|
||||
}
|
||||
|
||||
func notificationExists(notifications []*Notification, issueID, userID int64) bool {
|
||||
|
@ -370,7 +370,7 @@ func NotificationsForUser(ctx context.Context, user *user_model.User, statuses [
|
|||
}
|
||||
|
||||
err = sess.Find(¬ifications)
|
||||
return
|
||||
return notifications, err
|
||||
}
|
||||
|
||||
// CountUnread count unread notifications for a user
|
||||
|
@ -401,7 +401,7 @@ func (n *Notification) loadAttributes(ctx context.Context) (err error) {
|
|||
if err = n.loadComment(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
func (n *Notification) loadRepo(ctx context.Context) (err error) {
|
||||
|
@ -730,7 +730,7 @@ func GetNotificationCount(ctx context.Context, user *user_model.User, status Not
|
|||
Where("user_id = ?", user.ID).
|
||||
And("status = ?", status).
|
||||
Count(&Notification{})
|
||||
return
|
||||
return count, err
|
||||
}
|
||||
|
||||
// UserIDCount is a simple coalition of UserID and Count
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue