diff options
author | deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> | 2022-03-06 15:59:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-06 15:59:45 +0800 |
commit | 2d609b8b31ab3dea7e9ae3f315e945082b23e8ad (patch) | |
tree | 6b42670f567bdbc598abe5ca9f619dc608b49f36 /internal | |
parent | 3acc13038dfe5e0643112140d329c6eb0ed4cd6a (diff) |
autofix: types of function parameters can be combined (#6800)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Diffstat (limited to 'internal')
-rw-r--r-- | internal/context/auth.go | 2 | ||||
-rw-r--r-- | internal/db/issue.go | 6 | ||||
-rw-r--r-- | internal/db/milestone.go | 2 | ||||
-rw-r--r-- | internal/db/webhook_discord.go | 4 | ||||
-rw-r--r-- | internal/db/webhook_slack.go | 2 | ||||
-rw-r--r-- | internal/httplib/httplib.go | 12 | ||||
-rw-r--r-- | internal/markup/markdown.go | 2 | ||||
-rw-r--r-- | internal/route/repo/editor.go | 2 | ||||
-rw-r--r-- | internal/route/repo/webhook.go | 2 | ||||
-rw-r--r-- | internal/tool/tool.go | 4 |
10 files changed, 19 insertions, 19 deletions
diff --git a/internal/context/auth.go b/internal/context/auth.go index cbbe525a..6e67d8ef 100644 --- a/internal/context/auth.go +++ b/internal/context/auth.go @@ -162,7 +162,7 @@ func authenticatedUserID(c *macaron.Context, sess session.Store) (_ int64, isTok // authenticatedUser returns the user object of the authenticated user, along with two bool values // which indicate whether the user uses HTTP Basic Authentication or token authentication respectively. -func authenticatedUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasicAuth bool, isTokenAuth bool) { +func authenticatedUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasicAuth, isTokenAuth bool) { if !db.HasEngine { return nil, false, false } diff --git a/internal/db/issue.go b/internal/db/issue.go index d7726beb..fdcabf9b 100644 --- a/internal/db/issue.go +++ b/internal/db/issue.go @@ -21,9 +21,7 @@ import ( "gogs.io/gogs/internal/tool" ) -var ( - ErrMissingIssueNumber = errors.New("No issue number specified") -) +var ErrMissingIssueNumber = errors.New("No issue number specified") // Issue represents an issue or pull request of repository. type Issue struct { @@ -1346,7 +1344,7 @@ func GetUserIssueStats(repoID, userID int64, repoIDs []int64, filterMode FilterM } // GetRepoIssueStats returns number of open and closed repository issues by given filter mode. -func GetRepoIssueStats(repoID, userID int64, filterMode FilterMode, isPull bool) (numOpen int64, numClosed int64) { +func GetRepoIssueStats(repoID, userID int64, filterMode FilterMode, isPull bool) (numOpen, numClosed int64) { countSession := func(isClosed, isPull bool, repoID int64) *xorm.Session { sess := x.Where("issue.repo_id = ?", isClosed). And("is_pull = ?", isPull). diff --git a/internal/db/milestone.go b/internal/db/milestone.go index df059b30..035be6bf 100644 --- a/internal/db/milestone.go +++ b/internal/db/milestone.go @@ -216,7 +216,7 @@ func CountRepoClosedMilestones(repoID int64) int64 { } // MilestoneStats returns number of open and closed milestones of given repository. -func MilestoneStats(repoID int64) (open int64, closed int64) { +func MilestoneStats(repoID int64) (open, closed int64) { open, _ = x.Where("repo_id=? AND is_closed=?", repoID, false).Count(new(Milestone)) return open, CountRepoClosedMilestones(repoID) } diff --git a/internal/db/webhook_discord.go b/internal/db/webhook_discord.go index f149b11e..cde19707 100644 --- a/internal/db/webhook_discord.go +++ b/internal/db/webhook_discord.go @@ -61,11 +61,11 @@ func DiscordTextFormatter(s string) string { return strings.Split(s, "\n")[0] } -func DiscordLinkFormatter(url string, text string) string { +func DiscordLinkFormatter(url, text string) string { return fmt.Sprintf("[%s](%s)", text, url) } -func DiscordSHALinkFormatter(url string, text string) string { +func DiscordSHALinkFormatter(url, text string) string { return fmt.Sprintf("[`%s`](%s)", text, url) } diff --git a/internal/db/webhook_slack.go b/internal/db/webhook_slack.go index a42fb8d8..289bcb28 100644 --- a/internal/db/webhook_slack.go +++ b/internal/db/webhook_slack.go @@ -66,7 +66,7 @@ func SlackShortTextFormatter(s string) string { return s } -func SlackLinkFormatter(url string, text string) string { +func SlackLinkFormatter(url, text string) string { return fmt.Sprintf("<%s|%s>", url, SlackTextFormatter(text)) } diff --git a/internal/httplib/httplib.go b/internal/httplib/httplib.go index 1062d220..142eb7c5 100644 --- a/internal/httplib/httplib.go +++ b/internal/httplib/httplib.go @@ -27,9 +27,11 @@ import ( jsoniter "github.com/json-iterator/go" ) -var defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false} -var defaultCookieJar http.CookieJar -var settingMutex sync.Mutex +var ( + defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false} + defaultCookieJar http.CookieJar + settingMutex sync.Mutex +) // createDefaultCookie creates a global cookiejar to store cookies. func createDefaultCookie() { @@ -270,7 +272,7 @@ func (r *Request) getResponse() (*http.Response, error) { if err != nil { log.Fatal(err) } - //iocopy + // iocopy _, err = io.Copy(fileWriter, fh) _ = fh.Close() if err != nil { @@ -437,7 +439,7 @@ func (r *Request) Response() (*http.Response, error) { } // TimeoutDialer returns functions of connection dialer with timeout settings for http.Transport Dial field. -func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(ctx context.Context, net, addr string) (c net.Conn, err error) { +func TimeoutDialer(cTimeout, rwTimeout time.Duration) func(ctx context.Context, net, addr string) (c net.Conn, err error) { return func(ctx context.Context, netw, addr string) (net.Conn, error) { conn, err := net.DialTimeout(netw, addr, cTimeout) if err != nil { diff --git a/internal/markup/markdown.go b/internal/markup/markdown.go index ab0b9cd2..f8078b38 100644 --- a/internal/markup/markdown.go +++ b/internal/markup/markdown.go @@ -43,7 +43,7 @@ func isLink(link []byte) bool { } // Link defines how formal links should be processed to produce corresponding HTML elements. -func (r *MarkdownRenderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) { +func (r *MarkdownRenderer) Link(out *bytes.Buffer, link, title, content []byte) { if len(link) > 0 && !isLink(link) { if link[0] != '#' { link = []byte(path.Join(r.urlPrefix, string(link))) diff --git a/internal/route/repo/editor.go b/internal/route/repo/editor.go index ee004803..6556187e 100644 --- a/internal/route/repo/editor.go +++ b/internal/route/repo/editor.go @@ -32,7 +32,7 @@ const ( // getParentTreeFields returns list of parent tree names and corresponding tree paths // based on given tree path. -func getParentTreeFields(treePath string) (treeNames []string, treePaths []string) { +func getParentTreeFields(treePath string) (treeNames, treePaths []string) { if len(treePath) == 0 { return treeNames, treePaths } diff --git a/internal/route/repo/webhook.go b/internal/route/repo/webhook.go index 8e4b3a11..43148822 100644 --- a/internal/route/repo/webhook.go +++ b/internal/route/repo/webhook.go @@ -135,7 +135,7 @@ func isLocalHostname(hostname string) bool { return false } -func validateWebhook(actor *db.User, l macaron.Locale, w *db.Webhook) (field string, msg string, ok bool) { +func validateWebhook(actor *db.User, l macaron.Locale, w *db.Webhook) (field, msg string, ok bool) { if !actor.IsAdmin { // 🚨 SECURITY: Local addresses must not be allowed by non-admins to prevent SSRF, // see https://github.com/gogs/gogs/issues/5366 for details. diff --git a/internal/tool/tool.go b/internal/tool/tool.go index 6f86f6bb..d2110919 100644 --- a/internal/tool/tool.go +++ b/internal/tool/tool.go @@ -309,10 +309,10 @@ func TimeSince(t time.Time, lang string) template.HTML { } // 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 + isInt := true switch left := left.(type) { case int: rleft = int64(left) |