1
0
Fork 0
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:
Wim 2022-06-20 12:02:49 +02:00 committed by GitHub
parent 3289abcefc
commit cb50375e2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
147 changed files with 402 additions and 397 deletions

View file

@ -223,7 +223,7 @@ func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) {
return nil, err
}
pr.Issue = issue
return
return pr, err
}
// LoadLabels loads labels
@ -255,7 +255,7 @@ func (issue *Issue) loadPoster(ctx context.Context) (err error) {
return
}
}
return
return err
}
func (issue *Issue) loadPullRequest(ctx context.Context) (err error) {
@ -311,7 +311,7 @@ func (issue *Issue) loadReactions(ctx context.Context) (err error) {
return err
}
// Load reaction user data
if _, err := ReactionList(reactions).LoadUsers(ctx, issue.Repo); err != nil {
if _, err := reactions.LoadUsers(ctx, issue.Repo); err != nil {
return err
}
@ -2110,7 +2110,7 @@ func updateIssueClosedNum(ctx context.Context, issue *Issue) (err error) {
} else {
err = repo_model.StatsCorrectNumClosed(ctx, issue.RepoID, false, "num_closed_issues")
}
return
return err
}
// FindAndUpdateIssueMentions finds users mentioned in the given content string, and saves them in the database.
@ -2123,7 +2123,7 @@ func FindAndUpdateIssueMentions(ctx context.Context, issue *Issue, doer *user_mo
if err = UpdateIssueMentions(ctx, issue.ID, mentions); err != nil {
return nil, fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
}
return
return mentions, err
}
// ResolveIssueMentionsByVisibility returns the users mentioned in an issue, removing those that
@ -2257,7 +2257,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
users = append(users, user)
}
return
return users, err
}
// UpdateIssuesMigrationsByType updates all migrated repositories' issues from gitServiceType to replace originalAuthorID to posterID
@ -2380,7 +2380,7 @@ func DeleteIssuesByRepoID(ctx context.Context, repoID int64) (attachmentPaths []
return
}
return
return attachmentPaths, err
}
// RemapExternalUser ExternalUserRemappable interface