autofix: types of function parameters can be combined (#6800)

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
deepsource-autofix[bot]
2022-03-06 15:59:45 +08:00
committed by GitHub
parent 3acc13038d
commit 2d609b8b31
10 changed files with 19 additions and 19 deletions

View File

@@ -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 // 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. // 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 { if !db.HasEngine {
return nil, false, false return nil, false, false
} }

View File

@@ -21,9 +21,7 @@ import (
"gogs.io/gogs/internal/tool" "gogs.io/gogs/internal/tool"
) )
var ( var ErrMissingIssueNumber = errors.New("No issue number specified")
ErrMissingIssueNumber = errors.New("No issue number specified")
)
// Issue represents an issue or pull request of repository. // Issue represents an issue or pull request of repository.
type Issue struct { 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. // 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 { countSession := func(isClosed, isPull bool, repoID int64) *xorm.Session {
sess := x.Where("issue.repo_id = ?", isClosed). sess := x.Where("issue.repo_id = ?", isClosed).
And("is_pull = ?", isPull). And("is_pull = ?", isPull).

View File

@@ -216,7 +216,7 @@ func CountRepoClosedMilestones(repoID int64) int64 {
} }
// MilestoneStats returns number of open and closed milestones of given repository. // 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)) open, _ = x.Where("repo_id=? AND is_closed=?", repoID, false).Count(new(Milestone))
return open, CountRepoClosedMilestones(repoID) return open, CountRepoClosedMilestones(repoID)
} }

View File

@@ -61,11 +61,11 @@ func DiscordTextFormatter(s string) string {
return strings.Split(s, "\n")[0] 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) 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) return fmt.Sprintf("[`%s`](%s)", text, url)
} }

View File

@@ -66,7 +66,7 @@ func SlackShortTextFormatter(s string) string {
return s return s
} }
func SlackLinkFormatter(url string, text string) string { func SlackLinkFormatter(url, text string) string {
return fmt.Sprintf("<%s|%s>", url, SlackTextFormatter(text)) return fmt.Sprintf("<%s|%s>", url, SlackTextFormatter(text))
} }

View File

@@ -27,9 +27,11 @@ import (
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
) )
var defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false} var (
var defaultCookieJar http.CookieJar defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}
var settingMutex sync.Mutex defaultCookieJar http.CookieJar
settingMutex sync.Mutex
)
// createDefaultCookie creates a global cookiejar to store cookies. // createDefaultCookie creates a global cookiejar to store cookies.
func createDefaultCookie() { func createDefaultCookie() {
@@ -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. // 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) { return func(ctx context.Context, netw, addr string) (net.Conn, error) {
conn, err := net.DialTimeout(netw, addr, cTimeout) conn, err := net.DialTimeout(netw, addr, cTimeout)
if err != nil { if err != nil {

View File

@@ -43,7 +43,7 @@ func isLink(link []byte) bool {
} }
// Link defines how formal links should be processed to produce corresponding HTML elements. // 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 len(link) > 0 && !isLink(link) {
if link[0] != '#' { if link[0] != '#' {
link = []byte(path.Join(r.urlPrefix, string(link))) link = []byte(path.Join(r.urlPrefix, string(link)))

View File

@@ -32,7 +32,7 @@ const (
// getParentTreeFields returns list of parent tree names and corresponding tree paths // getParentTreeFields returns list of parent tree names and corresponding tree paths
// based on given tree path. // based on given tree path.
func getParentTreeFields(treePath string) (treeNames []string, treePaths []string) { func getParentTreeFields(treePath string) (treeNames, treePaths []string) {
if len(treePath) == 0 { if len(treePath) == 0 {
return treeNames, treePaths return treeNames, treePaths
} }

View File

@@ -135,7 +135,7 @@ func isLocalHostname(hostname string) bool {
return false 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 { if !actor.IsAdmin {
// 🚨 SECURITY: Local addresses must not be allowed by non-admins to prevent SSRF, // 🚨 SECURITY: Local addresses must not be allowed by non-admins to prevent SSRF,
// see https://github.com/gogs/gogs/issues/5366 for details. // see https://github.com/gogs/gogs/issues/5366 for details.

View File

@@ -309,10 +309,10 @@ func TimeSince(t time.Time, lang string) template.HTML {
} }
// Subtract deals with subtraction of all types of number. // 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 rleft, rright int64
var fleft, fright float64 var fleft, fright float64
var isInt = true isInt := true
switch left := left.(type) { switch left := left.(type) {
case int: case int:
rleft = int64(left) rleft = int64(left)