mirror of https://github.com/gogs/gogs.git
autofix: types of function parameters can be combined (#6800)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>pull/6802/head
parent
3acc13038d
commit
2d609b8b31
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue