Skip to content

Commit eab4a1c

Browse files
committed
Fix nakedreturns
Thanks to github.com/gostaticanalysis/nakedreturn/cmd/fixnakedreturn
1 parent 65be0f6 commit eab4a1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+146
-146
lines changed

integrations/git_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func standardCommitAndPushTest(t *testing.T, dstPath string) (little, big string
150150
defer PrintCurrentTest(t)()
151151
little, big = commitAndPushTest(t, dstPath, "data-file-")
152152
})
153-
return
153+
return little, big
154154
}
155155

156156
func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) {
@@ -191,7 +191,7 @@ func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS strin
191191
lockTest(t, dstPath)
192192
})
193193
})
194-
return
194+
return littleLFS, bigLFS
195195
}
196196

197197
func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string) {
@@ -210,7 +210,7 @@ func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string
210210
big = doCommitAndPush(t, bigSize, dstPath, prefix)
211211
})
212212
})
213-
return
213+
return little, big
214214
}
215215

216216
func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS string) {

models/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func DeleteOldActions(olderThan time.Duration) (err error) {
447447
}
448448

449449
_, err = db.GetEngine(db.DefaultContext).Where("created_unix < ?", time.Now().Add(-olderThan).Unix()).Delete(&Action{})
450-
return
450+
return err
451451
}
452452

453453
func notifyWatchers(ctx context.Context, actions ...*Action) error {

models/admin/notice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ func DeleteOldSystemNotices(olderThan time.Duration) (err error) {
142142
}
143143

144144
_, err = db.GetEngine(db.DefaultContext).Where("created_unix < ?", time.Now().Add(-olderThan).Unix()).Delete(&Notice{})
145-
return
145+
return err
146146
}

models/asymkey/gpg_key_commit_verification.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,5 +520,5 @@ func CalculateTrustStatus(verification *CommitVerification, repoTrustModel repo_
520520
}
521521
}
522522

523-
return
523+
return err
524524
}

models/auth/oauth2.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func GetOAuth2ApplicationByClientID(ctx context.Context, clientID string) (app *
123123
if !has {
124124
return nil, ErrOAuthClientIDInvalid{ClientID: clientID}
125125
}
126-
return
126+
return app, err
127127
}
128128

129129
// GetOAuth2ApplicationByID returns the oauth2 application with the given id. Returns an error if not found.
@@ -143,7 +143,7 @@ func GetOAuth2ApplicationByID(ctx context.Context, id int64) (app *OAuth2Applica
143143
func GetOAuth2ApplicationsByUserID(ctx context.Context, userID int64) (apps []*OAuth2Application, err error) {
144144
apps = make([]*OAuth2Application, 0)
145145
err = db.GetEngine(ctx).Where("uid = ?", userID).Find(&apps)
146-
return
146+
return apps, err
147147
}
148148

149149
// CreateOAuth2ApplicationOptions holds options to create an oauth2 application
@@ -300,7 +300,7 @@ func (code *OAuth2AuthorizationCode) GenerateRedirectURI(state string) (redirect
300300
}
301301
q.Set("code", code.Code)
302302
redirect.RawQuery = q.Encode()
303-
return
303+
return redirect, err
304304
}
305305

306306
// Invalidate deletes the auth code from the database to invalidate this code
@@ -430,7 +430,7 @@ func GetOAuth2GrantByID(ctx context.Context, id int64) (grant *OAuth2Grant, err
430430
} else if !has {
431431
return nil, nil
432432
}
433-
return
433+
return grant, err
434434
}
435435

436436
// GetOAuth2GrantsByUserID lists all grants of a certain user

models/db/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,5 +285,5 @@ func DeleteAllRecords(tableName string) error {
285285
// GetMaxID will return max id of the table
286286
func GetMaxID(beanOrTableName interface{}) (maxID int64, err error) {
287287
_, err = x.Select("MAX(id)").Table(beanOrTableName).Get(&maxID)
288-
return
288+
return maxID, err
289289
}

models/db/index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func UpsertResourceIndex(ctx context.Context, tableName string, groupID int64) (
4444
default:
4545
return fmt.Errorf("database type not supported")
4646
}
47-
return
47+
return err
4848
}
4949

5050
var (

models/db/list_options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (opts *ListOptions) GetSkipTake() (skip, take int) {
5858
func (opts *ListOptions) GetStartEnd() (start, end int) {
5959
start, take := opts.GetSkipTake()
6060
end = start + take
61-
return
61+
return start, end
6262
}
6363

6464
// SetDefaultValues sets default values

models/git/branches.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ func updateApprovalWhitelist(ctx context.Context, repo *repo_model.Repository, c
363363
whitelist = append(whitelist, userID)
364364
}
365365

366-
return
366+
return whitelist, err
367367
}
368368

369369
// updateUserWhitelist checks whether the user whitelist changed and returns a whitelist with
@@ -392,7 +392,7 @@ func updateUserWhitelist(ctx context.Context, repo *repo_model.Repository, curre
392392
whitelist = append(whitelist, userID)
393393
}
394394

395-
return
395+
return whitelist, err
396396
}
397397

398398
// updateTeamWhitelist checks whether the team whitelist changed and returns a whitelist with
@@ -415,7 +415,7 @@ func updateTeamWhitelist(ctx context.Context, repo *repo_model.Repository, curre
415415
}
416416
}
417417

418-
return
418+
return whitelist, err
419419
}
420420

421421
// DeleteProtectedBranch removes ProtectedBranch relation between the user and repository.
@@ -539,7 +539,7 @@ func FindRenamedBranch(repoID int64, from string) (branch *RenamedBranch, exist
539539
}
540540
exist, err = db.GetEngine(db.DefaultContext).Get(branch)
541541

542-
return
542+
return branch, exist, err
543543
}
544544

545545
// RenameBranch rename a branch

models/git/commit_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func upsertCommitStatusIndex(ctx context.Context, repoID int64, sha string) (err
7474
default:
7575
return fmt.Errorf("database type not supported")
7676
}
77-
return
77+
return err
7878
}
7979

8080
// GetNextCommitStatusIndex retried 3 times to generate a resource index

models/issues/assignees.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (issue *Issue) LoadAssignees(ctx context.Context) (err error) {
4242
if len(issue.Assignees) > 0 {
4343
issue.Assignee = issue.Assignees[0]
4444
}
45-
return
45+
return err
4646
}
4747

4848
// GetAssigneeIDsByIssue returns the IDs of users assigned to an issue
@@ -167,5 +167,5 @@ func MakeIDsFromAPIAssigneesToAdd(oneAssignee string, multipleAssignees []string
167167
// Get the IDs of all assignees
168168
assigneeIDs, err = user_model.GetUserIDsByNames(requestAssignees, false)
169169

170-
return
170+
return assigneeIDs, err
171171
}

models/issues/comment.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func (c *Comment) LoadIssueCtx(ctx context.Context) (err error) {
315315
return nil
316316
}
317317
c.Issue, err = GetIssueByID(ctx, c.IssueID)
318-
return
318+
return err
319319
}
320320

321321
// BeforeInsert will be invoked by XORM before inserting a record
@@ -627,7 +627,7 @@ func (c *Comment) LoadResolveDoer() (err error) {
627627
err = nil
628628
}
629629
}
630-
return
630+
return err
631631
}
632632

633633
// IsResolved check if an code comment is resolved
@@ -955,7 +955,7 @@ func createIssueDependencyComment(ctx context.Context, doer *user_model.User, is
955955
DependentIssueID: issue.ID,
956956
}
957957
_, err = CreateCommentCtx(ctx, opts)
958-
return
958+
return err
959959
}
960960

961961
// CreateCommentOptions defines options for creating comment
@@ -1350,7 +1350,7 @@ func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *Pul
13501350

13511351
comment, err = CreateComment(ops)
13521352

1353-
return
1353+
return comment, err
13541354
}
13551355

13561356
// CreateAutoMergeComment is a internal function, only use it for CommentTypePRScheduledToAutoMerge and CommentTypePRUnScheduledToAutoMerge CommentTypes
@@ -1372,7 +1372,7 @@ func CreateAutoMergeComment(ctx context.Context, typ CommentType, pr *PullReques
13721372
Repo: pr.BaseRepo,
13731373
Issue: pr.Issue,
13741374
})
1375-
return
1375+
return comment, err
13761376
}
13771377

13781378
// getCommitsFromRepo get commit IDs from repo in between oldCommitID and newCommitID
@@ -1434,7 +1434,7 @@ func getCommitIDsFromRepo(ctx context.Context, repo *repo_model.Repository, oldC
14341434
}
14351435
}
14361436

1437-
return
1437+
return commitIDs, isForcePush, err
14381438
}
14391439

14401440
type commitBranchCheckItem struct {

models/issues/issue.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) {
223223
return nil, err
224224
}
225225
pr.Issue = issue
226-
return
226+
return pr, err
227227
}
228228

229229
// LoadLabels loads labels
@@ -255,7 +255,7 @@ func (issue *Issue) loadPoster(ctx context.Context) (err error) {
255255
return
256256
}
257257
}
258-
return
258+
return err
259259
}
260260

261261
func (issue *Issue) loadPullRequest(ctx context.Context) (err error) {
@@ -2110,7 +2110,7 @@ func updateIssueClosedNum(ctx context.Context, issue *Issue) (err error) {
21102110
} else {
21112111
err = repo_model.StatsCorrectNumClosed(ctx, issue.RepoID, false, "num_closed_issues")
21122112
}
2113-
return
2113+
return err
21142114
}
21152115

21162116
// 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
21232123
if err = UpdateIssueMentions(ctx, issue.ID, mentions); err != nil {
21242124
return nil, fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
21252125
}
2126-
return
2126+
return mentions, err
21272127
}
21282128

21292129
// ResolveIssueMentionsByVisibility returns the users mentioned in an issue, removing those that
@@ -2257,7 +2257,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
22572257
users = append(users, user)
22582258
}
22592259

2260-
return
2260+
return users, err
22612261
}
22622262

22632263
// 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 []
23802380
return
23812381
}
23822382

2383-
return
2383+
return attachmentPaths, err
23842384
}
23852385

23862386
// RemapExternalUser ExternalUserRemappable interface

models/issues/issue_project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (i *Issue) loadProject(ctx context.Context) (err error) {
2929
}
3030
i.Project = &p
3131
}
32-
return
32+
return err
3333
}
3434

3535
// ProjectID return project id if issue was assigned to one

models/issues/issue_watch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func GetIssueWatch(ctx context.Context, userID, issueID int64) (iw *IssueWatch,
6565
Where("user_id = ?", userID).
6666
And("issue_id = ?", issueID).
6767
Get(iw)
68-
return
68+
return iw, exists, err
6969
}
7070

7171
// CheckIssueWatch check if an user is watching an issue

models/issues/issue_xref.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (comment *Comment) LoadRefComment() (err error) {
258258
return nil
259259
}
260260
comment.RefComment, err = GetCommentByID(db.DefaultContext, comment.RefCommentID)
261-
return
261+
return err
262262
}
263263

264264
// LoadRefIssue loads comment that created this reference from database
@@ -270,7 +270,7 @@ func (comment *Comment) LoadRefIssue() (err error) {
270270
if err == nil {
271271
err = comment.RefIssue.LoadRepo(db.DefaultContext)
272272
}
273-
return
273+
return err
274274
}
275275

276276
// CommentTypeIsRef returns true if CommentType is a reference from another issue

models/issues/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func (pr *PullRequest) LoadProtectedBranchCtx(ctx context.Context) (err error) {
323323
}
324324
pr.ProtectedBranch, err = git_model.GetProtectedBranchBy(ctx, pr.BaseRepo.ID, pr.BaseBranch)
325325
}
326-
return
326+
return err
327327
}
328328

329329
// ReviewCount represents a count of Reviews

0 commit comments

Comments
 (0)