Skip to content

Commit ff2fd08

Browse files
author
Gusted
authored
Simplify parameter types (#18006)
Remove repeated type declarations in function definitions.
1 parent 25677cd commit ff2fd08

Some content is hidden

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

59 files changed

+115
-116
lines changed

cmd/dump.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/urfave/cli"
2626
)
2727

28-
func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) error {
28+
func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
2929
if verbose {
3030
log.Info("Adding file %s\n", filePath)
3131
}
@@ -48,7 +48,7 @@ func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) e
4848
})
4949
}
5050

51-
func isSubdir(upper string, lower string) (bool, error) {
51+
func isSubdir(upper, lower string) (bool, error) {
5252
if relPath, err := filepath.Rel(upper, lower); err != nil {
5353
return false, err
5454
} else if relPath == "." || !strings.HasPrefix(relPath, ".") {

integrations/api_repo_tags_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestAPIRepoTags(t *testing.T) {
6868
session.MakeRequest(t, req, http.StatusNotFound)
6969
}
7070

71-
func createNewTagUsingAPI(t *testing.T, session *TestSession, token string, ownerName, repoName, name, target, msg string) *api.Tag {
71+
func createNewTagUsingAPI(t *testing.T, session *TestSession, token, ownerName, repoName, name, target, msg string) *api.Tag {
7272
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/tags?token=%s", ownerName, repoName, token)
7373
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateTagOption{
7474
TagName: name,

integrations/git_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes
418418
}
419419
}
420420

421-
func doProtectBranch(ctx APITestContext, branch string, userToWhitelist string, unprotectedFilePatterns string) func(t *testing.T) {
421+
func doProtectBranch(ctx APITestContext, branch, userToWhitelist, unprotectedFilePatterns string) func(t *testing.T) {
422422
// We are going to just use the owner to set the protection.
423423
return func(t *testing.T) {
424424
csrf := GetCSRF(t, ctx.Session, fmt.Sprintf("/%s/%s/settings/branches", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame)))

integrations/issue_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func testIssueWithBean(t *testing.T, user string, repoID int64, title, content s
310310
return issueURL, issue
311311
}
312312

313-
func testIssueChangeInfo(t *testing.T, user, issueURL, info string, value string) {
313+
func testIssueChangeInfo(t *testing.T, user, issueURL, info, value string) {
314314
session := loginUser(t, user)
315315

316316
req := NewRequest(t, "GET", issueURL)

models/issue_milestone.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func GetMilestones(opts GetMilestonesOption) (MilestoneList, int64, error) {
448448
}
449449

450450
// SearchMilestones search milestones
451-
func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType string, keyword string) (MilestoneList, error) {
451+
func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType, keyword string) (MilestoneList, error) {
452452
miles := make([]*Milestone, 0, setting.UI.IssuePagingNum)
453453
sess := db.GetEngine(db.DefaultContext).Where("is_closed = ?", isClosed)
454454
if len(keyword) > 0 {

models/issues/content_history.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ type IssueContentListItem struct {
146146
}
147147

148148
// FetchIssueContentHistoryList fetch list
149-
func FetchIssueContentHistoryList(dbCtx context.Context, issueID int64, commentID int64) ([]*IssueContentListItem, error) {
149+
func FetchIssueContentHistoryList(dbCtx context.Context, issueID, commentID int64) ([]*IssueContentListItem, error) {
150150
res := make([]*IssueContentListItem, 0)
151151
err := db.GetEngine(dbCtx).Select("u.id as user_id, u.name as user_name,"+
152152
"h.id as history_id, h.edited_unix, h.is_first_created, h.is_deleted").
@@ -168,7 +168,7 @@ func FetchIssueContentHistoryList(dbCtx context.Context, issueID int64, commentI
168168
}
169169

170170
// HasIssueContentHistory check if a ContentHistory entry exists
171-
func HasIssueContentHistory(dbCtx context.Context, issueID int64, commentID int64) (bool, error) {
171+
func HasIssueContentHistory(dbCtx context.Context, issueID, commentID int64) (bool, error) {
172172
exists, err := db.GetEngine(dbCtx).Cols("id").Exist(&ContentHistory{
173173
IssueID: issueID,
174174
CommentID: commentID,

models/user.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,11 @@ func GetWatchedRepos(userID int64, private bool, listOptions db.ListOptions) ([]
316316
}
317317

318318
// IsUserVisibleToViewer check if viewer is able to see user profile
319-
func IsUserVisibleToViewer(u *user_model.User, viewer *user_model.User) bool {
319+
func IsUserVisibleToViewer(u, viewer *user_model.User) bool {
320320
return isUserVisibleToViewer(db.GetEngine(db.DefaultContext), u, viewer)
321321
}
322322

323-
func isUserVisibleToViewer(e db.Engine, u *user_model.User, viewer *user_model.User) bool {
323+
func isUserVisibleToViewer(e db.Engine, u, viewer *user_model.User) bool {
324324
if viewer != nil && viewer.IsAdmin {
325325
return true
326326
}

models/user/setting.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func SetSetting(setting *Setting) error {
7676
return upsertSettingValue(setting.UserID, setting.SettingKey, setting.SettingValue)
7777
}
7878

79-
func upsertSettingValue(userID int64, key string, value string) error {
79+
func upsertSettingValue(userID int64, key, value string) error {
8080
return db.WithTx(func(ctx context.Context) error {
8181
e := db.GetEngine(ctx)
8282

modules/avatar/identicon/block.go

+30-30
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ var (
1616
blocks = []blockFunc{b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27}
1717
)
1818

19-
type blockFunc func(img *image.Paletted, x, y, size int, angle int)
19+
type blockFunc func(img *image.Paletted, x, y, size, angle int)
2020

2121
// draw a polygon by points, and the polygon is rotated by angle.
22-
func drawBlock(img *image.Paletted, x, y, size int, angle int, points []int) {
22+
func drawBlock(img *image.Paletted, x, y, size, angle int, points []int) {
2323
if angle != 0 {
2424
m := size / 2
2525
rotate(points, m, m, angle)
@@ -41,7 +41,7 @@ func drawBlock(img *image.Paletted, x, y, size int, angle int, points []int) {
4141
// | |
4242
// | |
4343
// --------
44-
func b0(img *image.Paletted, x, y, size int, angle int) {}
44+
func b0(img *image.Paletted, x, y, size, angle int) {}
4545

4646
// full-filled
4747
//
@@ -50,7 +50,7 @@ func b0(img *image.Paletted, x, y, size int, angle int) {}
5050
// |######|
5151
// |######|
5252
// --------
53-
func b1(img *image.Paletted, x, y, size int, angle int) {
53+
func b1(img *image.Paletted, x, y, size, angle int) {
5454
for i := x; i < x+size; i++ {
5555
for j := y; j < y+size; j++ {
5656
img.SetColorIndex(i, j, 1)
@@ -65,7 +65,7 @@ func b1(img *image.Paletted, x, y, size int, angle int) {
6565
// | #### |
6666
// | |
6767
// ----------
68-
func b2(img *image.Paletted, x, y, size int, angle int) {
68+
func b2(img *image.Paletted, x, y, size, angle int) {
6969
l := size / 4
7070
x += l
7171
y += l
@@ -88,7 +88,7 @@ func b2(img *image.Paletted, x, y, size int, angle int) {
8888
// | ### |
8989
// | # |
9090
// ---------
91-
func b3(img *image.Paletted, x, y, size int, angle int) {
91+
func b3(img *image.Paletted, x, y, size, angle int) {
9292
m := size / 2
9393
drawBlock(img, x, y, size, 0, []int{
9494
m, 0,
@@ -108,7 +108,7 @@ func b3(img *image.Paletted, x, y, size int, angle int) {
108108
// |## |
109109
// |# |
110110
// |------
111-
func b4(img *image.Paletted, x, y, size int, angle int) {
111+
func b4(img *image.Paletted, x, y, size, angle int) {
112112
drawBlock(img, x, y, size, angle, []int{
113113
0, 0,
114114
size, 0,
@@ -124,7 +124,7 @@ func b4(img *image.Paletted, x, y, size int, angle int) {
124124
// | ### |
125125
// | ##### |
126126
// |#######|
127-
func b5(img *image.Paletted, x, y, size int, angle int) {
127+
func b5(img *image.Paletted, x, y, size, angle int) {
128128
m := size / 2
129129
drawBlock(img, x, y, size, angle, []int{
130130
m, 0,
@@ -141,7 +141,7 @@ func b5(img *image.Paletted, x, y, size int, angle int) {
141141
// |### |
142142
// |### |
143143
// --------
144-
func b6(img *image.Paletted, x, y, size int, angle int) {
144+
func b6(img *image.Paletted, x, y, size, angle int) {
145145
m := size / 2
146146
drawBlock(img, x, y, size, angle, []int{
147147
0, 0,
@@ -160,7 +160,7 @@ func b6(img *image.Paletted, x, y, size int, angle int) {
160160
// | #####|
161161
// | ####|
162162
// |--------
163-
func b7(img *image.Paletted, x, y, size int, angle int) {
163+
func b7(img *image.Paletted, x, y, size, angle int) {
164164
m := size / 2
165165
drawBlock(img, x, y, size, angle, []int{
166166
0, 0,
@@ -181,7 +181,7 @@ func b7(img *image.Paletted, x, y, size int, angle int) {
181181
// | ### ### |
182182
// |#########|
183183
// -----------
184-
func b8(img *image.Paletted, x, y, size int, angle int) {
184+
func b8(img *image.Paletted, x, y, size, angle int) {
185185
m := size / 2
186186
mm := m / 2
187187

@@ -219,7 +219,7 @@ func b8(img *image.Paletted, x, y, size int, angle int) {
219219
// | #### |
220220
// | # |
221221
// ---------
222-
func b9(img *image.Paletted, x, y, size int, angle int) {
222+
func b9(img *image.Paletted, x, y, size, angle int) {
223223
m := size / 2
224224
drawBlock(img, x, y, size, angle, []int{
225225
0, 0,
@@ -241,7 +241,7 @@ func b9(img *image.Paletted, x, y, size int, angle int) {
241241
// |## |
242242
// |# |
243243
// ----------
244-
func b10(img *image.Paletted, x, y, size int, angle int) {
244+
func b10(img *image.Paletted, x, y, size, angle int) {
245245
m := size / 2
246246
drawBlock(img, x, y, size, angle, []int{
247247
m, 0,
@@ -267,7 +267,7 @@ func b10(img *image.Paletted, x, y, size int, angle int) {
267267
// | |
268268
// | |
269269
// ----------
270-
func b11(img *image.Paletted, x, y, size int, angle int) {
270+
func b11(img *image.Paletted, x, y, size, angle int) {
271271
m := size / 2
272272
drawBlock(img, x, y, size, angle, []int{
273273
0, 0,
@@ -287,7 +287,7 @@ func b11(img *image.Paletted, x, y, size int, angle int) {
287287
// | ##### |
288288
// | # |
289289
// -----------
290-
func b12(img *image.Paletted, x, y, size int, angle int) {
290+
func b12(img *image.Paletted, x, y, size, angle int) {
291291
m := size / 2
292292
drawBlock(img, x, y, size, angle, []int{
293293
0, m,
@@ -306,7 +306,7 @@ func b12(img *image.Paletted, x, y, size int, angle int) {
306306
// | ##### |
307307
// |#########|
308308
// -----------
309-
func b13(img *image.Paletted, x, y, size int, angle int) {
309+
func b13(img *image.Paletted, x, y, size, angle int) {
310310
m := size / 2
311311
drawBlock(img, x, y, size, angle, []int{
312312
m, m,
@@ -325,7 +325,7 @@ func b13(img *image.Paletted, x, y, size int, angle int) {
325325
// | |
326326
// | |
327327
// ---------
328-
func b14(img *image.Paletted, x, y, size int, angle int) {
328+
func b14(img *image.Paletted, x, y, size, angle int) {
329329
m := size / 2
330330
drawBlock(img, x, y, size, angle, []int{
331331
m, 0,
@@ -344,7 +344,7 @@ func b14(img *image.Paletted, x, y, size int, angle int) {
344344
// | |
345345
// | |
346346
// ----------
347-
func b15(img *image.Paletted, x, y, size int, angle int) {
347+
func b15(img *image.Paletted, x, y, size, angle int) {
348348
m := size / 2
349349
drawBlock(img, x, y, size, angle, []int{
350350
0, 0,
@@ -364,7 +364,7 @@ func b15(img *image.Paletted, x, y, size int, angle int) {
364364
// | ##### |
365365
// |#######|
366366
// ---------
367-
func b16(img *image.Paletted, x, y, size int, angle int) {
367+
func b16(img *image.Paletted, x, y, size, angle int) {
368368
m := size / 2
369369
drawBlock(img, x, y, size, angle, []int{
370370
m, 0,
@@ -390,7 +390,7 @@ func b16(img *image.Paletted, x, y, size int, angle int) {
390390
// | ##|
391391
// | ##|
392392
// ----------
393-
func b17(img *image.Paletted, x, y, size int, angle int) {
393+
func b17(img *image.Paletted, x, y, size, angle int) {
394394
m := size / 2
395395

396396
drawBlock(img, x, y, size, angle, []int{
@@ -419,7 +419,7 @@ func b17(img *image.Paletted, x, y, size int, angle int) {
419419
// |## |
420420
// |# |
421421
// ----------
422-
func b18(img *image.Paletted, x, y, size int, angle int) {
422+
func b18(img *image.Paletted, x, y, size, angle int) {
423423
m := size / 2
424424

425425
drawBlock(img, x, y, size, angle, []int{
@@ -439,7 +439,7 @@ func b18(img *image.Paletted, x, y, size int, angle int) {
439439
// |### ###|
440440
// |########|
441441
// ----------
442-
func b19(img *image.Paletted, x, y, size int, angle int) {
442+
func b19(img *image.Paletted, x, y, size, angle int) {
443443
m := size / 2
444444

445445
drawBlock(img, x, y, size, angle, []int{
@@ -480,7 +480,7 @@ func b19(img *image.Paletted, x, y, size int, angle int) {
480480
// |## |
481481
// |# |
482482
// ----------
483-
func b20(img *image.Paletted, x, y, size int, angle int) {
483+
func b20(img *image.Paletted, x, y, size, angle int) {
484484
m := size / 2
485485
q := size / 4
486486

@@ -501,7 +501,7 @@ func b20(img *image.Paletted, x, y, size int, angle int) {
501501
// |## |
502502
// |# |
503503
// ----------
504-
func b21(img *image.Paletted, x, y, size int, angle int) {
504+
func b21(img *image.Paletted, x, y, size, angle int) {
505505
m := size / 2
506506
q := size / 4
507507

@@ -529,7 +529,7 @@ func b21(img *image.Paletted, x, y, size int, angle int) {
529529
// |## ##|
530530
// |# #|
531531
// ----------
532-
func b22(img *image.Paletted, x, y, size int, angle int) {
532+
func b22(img *image.Paletted, x, y, size, angle int) {
533533
m := size / 2
534534
q := size / 4
535535

@@ -557,7 +557,7 @@ func b22(img *image.Paletted, x, y, size int, angle int) {
557557
// |## |
558558
// |# |
559559
// ----------
560-
func b23(img *image.Paletted, x, y, size int, angle int) {
560+
func b23(img *image.Paletted, x, y, size, angle int) {
561561
m := size / 2
562562
q := size / 4
563563

@@ -585,7 +585,7 @@ func b23(img *image.Paletted, x, y, size int, angle int) {
585585
// |## ## |
586586
// |# # |
587587
// ----------
588-
func b24(img *image.Paletted, x, y, size int, angle int) {
588+
func b24(img *image.Paletted, x, y, size, angle int) {
589589
m := size / 2
590590
q := size / 4
591591

@@ -613,7 +613,7 @@ func b24(img *image.Paletted, x, y, size int, angle int) {
613613
// |###### |
614614
// |#### |
615615
// ----------
616-
func b25(img *image.Paletted, x, y, size int, angle int) {
616+
func b25(img *image.Paletted, x, y, size, angle int) {
617617
m := size / 2
618618
q := size / 4
619619

@@ -641,7 +641,7 @@ func b25(img *image.Paletted, x, y, size int, angle int) {
641641
// |### ###|
642642
// |# #|
643643
// ----------
644-
func b26(img *image.Paletted, x, y, size int, angle int) {
644+
func b26(img *image.Paletted, x, y, size, angle int) {
645645
m := size / 2
646646
q := size / 4
647647

@@ -683,7 +683,7 @@ func b26(img *image.Paletted, x, y, size int, angle int) {
683683
// |### ##|
684684
// |########|
685685
// ----------
686-
func b27(img *image.Paletted, x, y, size int, angle int) {
686+
func b27(img *image.Paletted, x, y, size, angle int) {
687687
m := size / 2
688688
q := size / 4
689689

modules/avatar/identicon/polygon.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var (
1616

1717
// rotate the points by center point (x,y)
1818
// angle: [0,1,2,3] means [0,90,180,270] degree
19-
func rotate(points []int, x, y int, angle int) {
19+
func rotate(points []int, x, y, angle int) {
2020
// the angle is only used internally, and it has been guaranteed to be 0/1/2/3, so we do not check it again
2121
for i := 0; i < len(points); i += 2 {
2222
px, py := points[i]-x, points[i+1]-y

modules/base/tool.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func PrettyNumber(v int64) string {
149149
}
150150

151151
// Subtract deals with subtraction of all types of number.
152-
func Subtract(left interface{}, right interface{}) interface{} {
152+
func Subtract(left, right interface{}) interface{} {
153153
var rleft, rright int64
154154
var fleft, fright float64
155155
var isInt = true

modules/charset/charset_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ func TestDetectEncoding(t *testing.T) {
261261
assert.Error(t, err)
262262
}
263263

264-
func stringMustStartWith(t *testing.T, expected string, value string) {
264+
func stringMustStartWith(t *testing.T, expected, value string) {
265265
assert.Equal(t, expected, string(value[:len(expected)]))
266266
}
267267

268-
func stringMustEndWith(t *testing.T, expected string, value string) {
268+
func stringMustEndWith(t *testing.T, expected, value string) {
269269
assert.Equal(t, expected, string(value[len(value)-len(expected):]))
270270
}
271271

272-
func bytesMustStartWith(t *testing.T, expected []byte, value []byte) {
272+
func bytesMustStartWith(t *testing.T, expected, value []byte) {
273273
assert.Equal(t, expected, value[:len(expected)])
274274
}

0 commit comments

Comments
 (0)