Skip to content

Commit 46a1d52

Browse files
silverwindlunny
andauthored
Fix remaining issues after gopls modernize formatting (#34771)
Followup #34751, fix all remaining marked issues. --------- Co-authored-by: Lunny Xiao <[email protected]>
1 parent a2ae7c6 commit 46a1d52

File tree

7 files changed

+10
-42
lines changed

7 files changed

+10
-42
lines changed

modules/actions/workflows.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -565,18 +565,12 @@ func matchPullRequestReviewEvent(prPayload *api.PullRequestPayload, evt *jobpars
565565
actions = append(actions, "submitted", "edited")
566566
}
567567

568-
matched := false
569568
for _, val := range vals {
570569
if slices.ContainsFunc(actions, glob.MustCompile(val, '/').Match) {
571-
matched = true
572-
}
573-
if matched {
570+
matchTimes++
574571
break
575572
}
576573
}
577-
if matched {
578-
matchTimes++
579-
}
580574
default:
581575
log.Warn("pull request review event unsupported condition %q", cond)
582576
}
@@ -611,18 +605,12 @@ func matchPullRequestReviewCommentEvent(prPayload *api.PullRequestPayload, evt *
611605
actions = append(actions, "created", "edited")
612606
}
613607

614-
matched := false
615608
for _, val := range vals {
616609
if slices.ContainsFunc(actions, glob.MustCompile(val, '/').Match) {
617-
matched = true
618-
}
619-
if matched {
610+
matchTimes++
620611
break
621612
}
622613
}
623-
if matched {
624-
matchTimes++
625-
}
626614
default:
627615
log.Warn("pull request review comment event unsupported condition %q", cond)
628616
}

modules/setting/markup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func loadMarkupFrom(rootCfg ConfigProvider) {
149149
func newMarkupSanitizer(name string, sec ConfigSection) {
150150
rule, ok := createMarkupSanitizerRule(name, sec)
151151
if ok {
152-
if after, ok0 := strings.CutPrefix(name, "sanitizer."); ok0 {
152+
if after, found := strings.CutPrefix(name, "sanitizer."); found {
153153
names := strings.SplitN(after, ".", 2)
154154
name = names[0]
155155
}

routers/install/install.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ func Install(ctx *context.Context) {
9999
form.SSLMode = setting.Database.SSLMode
100100

101101
curDBType := setting.Database.Type.String()
102-
var isCurDBTypeSupported bool
103-
if slices.Contains(setting.SupportedDatabaseTypes, curDBType) {
104-
isCurDBTypeSupported = true
105-
}
106-
if !isCurDBTypeSupported {
102+
if !slices.Contains(setting.SupportedDatabaseTypes, curDBType) {
107103
curDBType = "mysql"
108104
}
109105
ctx.Data["CurDbType"] = curDBType

routers/web/explore/code.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ func Code(ctx *context.Context) {
9494

9595
loadRepoIDs := make([]int64, 0, len(searchResults))
9696
for _, result := range searchResults {
97-
var find bool
98-
if slices.Contains(loadRepoIDs, result.RepoID) {
99-
find = true
100-
}
101-
if !find {
97+
if !slices.Contains(loadRepoIDs, result.RepoID) {
10298
loadRepoIDs = append(loadRepoIDs, result.RepoID)
10399
}
104100
}

routers/web/user/code.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ func CodeSearch(ctx *context.Context) {
8787

8888
loadRepoIDs := make([]int64, 0, len(searchResults))
8989
for _, result := range searchResults {
90-
var find bool
91-
if slices.Contains(loadRepoIDs, result.RepoID) {
92-
find = true
93-
}
94-
if !find {
90+
if !slices.Contains(loadRepoIDs, result.RepoID) {
9591
loadRepoIDs = append(loadRepoIDs, result.RepoID)
9692
}
9793
}

tests/integration/api_issue_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ func TestAPISearchIssues(t *testing.T) {
267267
defer tests.PrepareTestEnv(t)()
268268

269269
// as this API was used in the frontend, it uses UI page size
270-
expectedIssueCount := min(
271-
// from the fixtures
272-
20, setting.UI.IssuePagingNum)
270+
expectedIssueCount := min(20, setting.UI.IssuePagingNum) // 20 is from the fixtures
273271

274272
link, _ := url.Parse("/api/v1/repos/issues/search")
275273
token := getUserToken(t, "user1", auth_model.AccessTokenScopeReadIssue)
@@ -370,9 +368,7 @@ func TestAPISearchIssuesWithLabels(t *testing.T) {
370368
defer tests.PrepareTestEnv(t)()
371369

372370
// as this API was used in the frontend, it uses UI page size
373-
expectedIssueCount := min(
374-
// from the fixtures
375-
20, setting.UI.IssuePagingNum)
371+
expectedIssueCount := min(20, setting.UI.IssuePagingNum) // 20 is from the fixtures
376372

377373
link, _ := url.Parse("/api/v1/repos/issues/search")
378374
token := getUserToken(t, "user1", auth_model.AccessTokenScopeReadIssue)

tests/integration/issue_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,7 @@ func TestSearchIssues(t *testing.T) {
488488

489489
session := loginUser(t, "user2")
490490

491-
expectedIssueCount := min(
492-
// from the fixtures
493-
20, setting.UI.IssuePagingNum)
491+
expectedIssueCount := min(20, setting.UI.IssuePagingNum) // 20 is from the fixtures
494492

495493
link, _ := url.Parse("/issues/search")
496494
req := NewRequest(t, "GET", link.String())
@@ -581,9 +579,7 @@ func TestSearchIssues(t *testing.T) {
581579
func TestSearchIssuesWithLabels(t *testing.T) {
582580
defer tests.PrepareTestEnv(t)()
583581

584-
expectedIssueCount := min(
585-
// from the fixtures
586-
20, setting.UI.IssuePagingNum)
582+
expectedIssueCount := min(20, setting.UI.IssuePagingNum) // 20 is from the fixtures
587583

588584
session := loginUser(t, "user1")
589585
link, _ := url.Parse("/issues/search")

0 commit comments

Comments
 (0)