Skip to content

Simplify parameter types #18006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/urfave/cli"
)

func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) error {
func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
if verbose {
log.Info("Adding file %s\n", filePath)
}
Expand All @@ -48,7 +48,7 @@ func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) e
})
}

func isSubdir(upper string, lower string) (bool, error) {
func isSubdir(upper, lower string) (bool, error) {
if relPath, err := filepath.Rel(upper, lower); err != nil {
return false, err
} else if relPath == "." || !strings.HasPrefix(relPath, ".") {
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_repo_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestAPIRepoTags(t *testing.T) {
session.MakeRequest(t, req, http.StatusNotFound)
}

func createNewTagUsingAPI(t *testing.T, session *TestSession, token string, ownerName, repoName, name, target, msg string) *api.Tag {
func createNewTagUsingAPI(t *testing.T, session *TestSession, token, ownerName, repoName, name, target, msg string) *api.Tag {
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/tags?token=%s", ownerName, repoName, token)
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateTagOption{
TagName: name,
Expand Down
2 changes: 1 addition & 1 deletion integrations/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes
}
}

func doProtectBranch(ctx APITestContext, branch string, userToWhitelist string, unprotectedFilePatterns string) func(t *testing.T) {
func doProtectBranch(ctx APITestContext, branch, userToWhitelist, unprotectedFilePatterns string) func(t *testing.T) {
// We are going to just use the owner to set the protection.
return func(t *testing.T) {
csrf := GetCSRF(t, ctx.Session, fmt.Sprintf("/%s/%s/settings/branches", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame)))
Expand Down
2 changes: 1 addition & 1 deletion integrations/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func testIssueWithBean(t *testing.T, user string, repoID int64, title, content s
return issueURL, issue
}

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

req := NewRequest(t, "GET", issueURL)
Expand Down
2 changes: 1 addition & 1 deletion models/issue_milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func GetMilestones(opts GetMilestonesOption) (MilestoneList, int64, error) {
}

// SearchMilestones search milestones
func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType string, keyword string) (MilestoneList, error) {
func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType, keyword string) (MilestoneList, error) {
miles := make([]*Milestone, 0, setting.UI.IssuePagingNum)
sess := db.GetEngine(db.DefaultContext).Where("is_closed = ?", isClosed)
if len(keyword) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions models/issues/content_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ type IssueContentListItem struct {
}

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

// HasIssueContentHistory check if a ContentHistory entry exists
func HasIssueContentHistory(dbCtx context.Context, issueID int64, commentID int64) (bool, error) {
func HasIssueContentHistory(dbCtx context.Context, issueID, commentID int64) (bool, error) {
exists, err := db.GetEngine(dbCtx).Cols("id").Exist(&ContentHistory{
IssueID: issueID,
CommentID: commentID,
Expand Down
4 changes: 2 additions & 2 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ func GetWatchedRepos(userID int64, private bool, listOptions db.ListOptions) ([]
}

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

func isUserVisibleToViewer(e db.Engine, u *user_model.User, viewer *user_model.User) bool {
func isUserVisibleToViewer(e db.Engine, u, viewer *user_model.User) bool {
if viewer != nil && viewer.IsAdmin {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion models/user/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func SetSetting(setting *Setting) error {
return upsertSettingValue(setting.UserID, setting.SettingKey, setting.SettingValue)
}

func upsertSettingValue(userID int64, key string, value string) error {
func upsertSettingValue(userID int64, key, value string) error {
return db.WithTx(func(ctx context.Context) error {
e := db.GetEngine(ctx)

Expand Down
60 changes: 30 additions & 30 deletions modules/avatar/identicon/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ var (
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}
)

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

// draw a polygon by points, and the polygon is rotated by angle.
func drawBlock(img *image.Paletted, x, y, size int, angle int, points []int) {
func drawBlock(img *image.Paletted, x, y, size, angle int, points []int) {
if angle != 0 {
m := size / 2
rotate(points, m, m, angle)
Expand All @@ -41,7 +41,7 @@ func drawBlock(img *image.Paletted, x, y, size int, angle int, points []int) {
// | |
// | |
// --------
func b0(img *image.Paletted, x, y, size int, angle int) {}
func b0(img *image.Paletted, x, y, size, angle int) {}

// full-filled
//
Expand All @@ -50,7 +50,7 @@ func b0(img *image.Paletted, x, y, size int, angle int) {}
// |######|
// |######|
// --------
func b1(img *image.Paletted, x, y, size int, angle int) {
func b1(img *image.Paletted, x, y, size, angle int) {
for i := x; i < x+size; i++ {
for j := y; j < y+size; j++ {
img.SetColorIndex(i, j, 1)
Expand All @@ -65,7 +65,7 @@ func b1(img *image.Paletted, x, y, size int, angle int) {
// | #### |
// | |
// ----------
func b2(img *image.Paletted, x, y, size int, angle int) {
func b2(img *image.Paletted, x, y, size, angle int) {
l := size / 4
x += l
y += l
Expand All @@ -88,7 +88,7 @@ func b2(img *image.Paletted, x, y, size int, angle int) {
// | ### |
// | # |
// ---------
func b3(img *image.Paletted, x, y, size int, angle int) {
func b3(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, 0, []int{
m, 0,
Expand All @@ -108,7 +108,7 @@ func b3(img *image.Paletted, x, y, size int, angle int) {
// |## |
// |# |
// |------
func b4(img *image.Paletted, x, y, size int, angle int) {
func b4(img *image.Paletted, x, y, size, angle int) {
drawBlock(img, x, y, size, angle, []int{
0, 0,
size, 0,
Expand All @@ -124,7 +124,7 @@ func b4(img *image.Paletted, x, y, size int, angle int) {
// | ### |
// | ##### |
// |#######|
func b5(img *image.Paletted, x, y, size int, angle int) {
func b5(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
m, 0,
Expand All @@ -141,7 +141,7 @@ func b5(img *image.Paletted, x, y, size int, angle int) {
// |### |
// |### |
// --------
func b6(img *image.Paletted, x, y, size int, angle int) {
func b6(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
0, 0,
Expand All @@ -160,7 +160,7 @@ func b6(img *image.Paletted, x, y, size int, angle int) {
// | #####|
// | ####|
// |--------
func b7(img *image.Paletted, x, y, size int, angle int) {
func b7(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
0, 0,
Expand All @@ -181,7 +181,7 @@ func b7(img *image.Paletted, x, y, size int, angle int) {
// | ### ### |
// |#########|
// -----------
func b8(img *image.Paletted, x, y, size int, angle int) {
func b8(img *image.Paletted, x, y, size, angle int) {
m := size / 2
mm := m / 2

Expand Down Expand Up @@ -219,7 +219,7 @@ func b8(img *image.Paletted, x, y, size int, angle int) {
// | #### |
// | # |
// ---------
func b9(img *image.Paletted, x, y, size int, angle int) {
func b9(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
0, 0,
Expand All @@ -241,7 +241,7 @@ func b9(img *image.Paletted, x, y, size int, angle int) {
// |## |
// |# |
// ----------
func b10(img *image.Paletted, x, y, size int, angle int) {
func b10(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
m, 0,
Expand All @@ -267,7 +267,7 @@ func b10(img *image.Paletted, x, y, size int, angle int) {
// | |
// | |
// ----------
func b11(img *image.Paletted, x, y, size int, angle int) {
func b11(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
0, 0,
Expand All @@ -287,7 +287,7 @@ func b11(img *image.Paletted, x, y, size int, angle int) {
// | ##### |
// | # |
// -----------
func b12(img *image.Paletted, x, y, size int, angle int) {
func b12(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
0, m,
Expand All @@ -306,7 +306,7 @@ func b12(img *image.Paletted, x, y, size int, angle int) {
// | ##### |
// |#########|
// -----------
func b13(img *image.Paletted, x, y, size int, angle int) {
func b13(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
m, m,
Expand All @@ -325,7 +325,7 @@ func b13(img *image.Paletted, x, y, size int, angle int) {
// | |
// | |
// ---------
func b14(img *image.Paletted, x, y, size int, angle int) {
func b14(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
m, 0,
Expand All @@ -344,7 +344,7 @@ func b14(img *image.Paletted, x, y, size int, angle int) {
// | |
// | |
// ----------
func b15(img *image.Paletted, x, y, size int, angle int) {
func b15(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
0, 0,
Expand All @@ -364,7 +364,7 @@ func b15(img *image.Paletted, x, y, size int, angle int) {
// | ##### |
// |#######|
// ---------
func b16(img *image.Paletted, x, y, size int, angle int) {
func b16(img *image.Paletted, x, y, size, angle int) {
m := size / 2
drawBlock(img, x, y, size, angle, []int{
m, 0,
Expand All @@ -390,7 +390,7 @@ func b16(img *image.Paletted, x, y, size int, angle int) {
// | ##|
// | ##|
// ----------
func b17(img *image.Paletted, x, y, size int, angle int) {
func b17(img *image.Paletted, x, y, size, angle int) {
m := size / 2

drawBlock(img, x, y, size, angle, []int{
Expand Down Expand Up @@ -419,7 +419,7 @@ func b17(img *image.Paletted, x, y, size int, angle int) {
// |## |
// |# |
// ----------
func b18(img *image.Paletted, x, y, size int, angle int) {
func b18(img *image.Paletted, x, y, size, angle int) {
m := size / 2

drawBlock(img, x, y, size, angle, []int{
Expand All @@ -439,7 +439,7 @@ func b18(img *image.Paletted, x, y, size int, angle int) {
// |### ###|
// |########|
// ----------
func b19(img *image.Paletted, x, y, size int, angle int) {
func b19(img *image.Paletted, x, y, size, angle int) {
m := size / 2

drawBlock(img, x, y, size, angle, []int{
Expand Down Expand Up @@ -480,7 +480,7 @@ func b19(img *image.Paletted, x, y, size int, angle int) {
// |## |
// |# |
// ----------
func b20(img *image.Paletted, x, y, size int, angle int) {
func b20(img *image.Paletted, x, y, size, angle int) {
m := size / 2
q := size / 4

Expand All @@ -501,7 +501,7 @@ func b20(img *image.Paletted, x, y, size int, angle int) {
// |## |
// |# |
// ----------
func b21(img *image.Paletted, x, y, size int, angle int) {
func b21(img *image.Paletted, x, y, size, angle int) {
m := size / 2
q := size / 4

Expand Down Expand Up @@ -529,7 +529,7 @@ func b21(img *image.Paletted, x, y, size int, angle int) {
// |## ##|
// |# #|
// ----------
func b22(img *image.Paletted, x, y, size int, angle int) {
func b22(img *image.Paletted, x, y, size, angle int) {
m := size / 2
q := size / 4

Expand Down Expand Up @@ -557,7 +557,7 @@ func b22(img *image.Paletted, x, y, size int, angle int) {
// |## |
// |# |
// ----------
func b23(img *image.Paletted, x, y, size int, angle int) {
func b23(img *image.Paletted, x, y, size, angle int) {
m := size / 2
q := size / 4

Expand Down Expand Up @@ -585,7 +585,7 @@ func b23(img *image.Paletted, x, y, size int, angle int) {
// |## ## |
// |# # |
// ----------
func b24(img *image.Paletted, x, y, size int, angle int) {
func b24(img *image.Paletted, x, y, size, angle int) {
m := size / 2
q := size / 4

Expand Down Expand Up @@ -613,7 +613,7 @@ func b24(img *image.Paletted, x, y, size int, angle int) {
// |###### |
// |#### |
// ----------
func b25(img *image.Paletted, x, y, size int, angle int) {
func b25(img *image.Paletted, x, y, size, angle int) {
m := size / 2
q := size / 4

Expand Down Expand Up @@ -641,7 +641,7 @@ func b25(img *image.Paletted, x, y, size int, angle int) {
// |### ###|
// |# #|
// ----------
func b26(img *image.Paletted, x, y, size int, angle int) {
func b26(img *image.Paletted, x, y, size, angle int) {
m := size / 2
q := size / 4

Expand Down Expand Up @@ -683,7 +683,7 @@ func b26(img *image.Paletted, x, y, size int, angle int) {
// |### ##|
// |########|
// ----------
func b27(img *image.Paletted, x, y, size int, angle int) {
func b27(img *image.Paletted, x, y, size, angle int) {
m := size / 2
q := size / 4

Expand Down
2 changes: 1 addition & 1 deletion modules/avatar/identicon/polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (

// rotate the points by center point (x,y)
// angle: [0,1,2,3] means [0,90,180,270] degree
func rotate(points []int, x, y int, angle int) {
func rotate(points []int, x, y, angle int) {
// the angle is only used internally, and it has been guaranteed to be 0/1/2/3, so we do not check it again
for i := 0; i < len(points); i += 2 {
px, py := points[i]-x, points[i+1]-y
Expand Down
2 changes: 1 addition & 1 deletion modules/base/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func PrettyNumber(v int64) string {
}

// Subtract deals with subtraction of all types of number.
func Subtract(left interface{}, right interface{}) interface{} {
func Subtract(left, right interface{}) interface{} {
var rleft, rright int64
var fleft, fright float64
var isInt = true
Expand Down
6 changes: 3 additions & 3 deletions modules/charset/charset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ func TestDetectEncoding(t *testing.T) {
assert.Error(t, err)
}

func stringMustStartWith(t *testing.T, expected string, value string) {
func stringMustStartWith(t *testing.T, expected, value string) {
assert.Equal(t, expected, string(value[:len(expected)]))
}

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

func bytesMustStartWith(t *testing.T, expected []byte, value []byte) {
func bytesMustStartWith(t *testing.T, expected, value []byte) {
assert.Equal(t, expected, value[:len(expected)])
}
Loading