mirror of
https://github.com/gogs/gogs.git
synced 2025-12-21 15:50:00 +01:00
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:
committed by
GitHub
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
|
// 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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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).
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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() {
|
||||||
@@ -270,7 +272,7 @@ func (r *Request) getResponse() (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
//iocopy
|
// iocopy
|
||||||
_, err = io.Copy(fileWriter, fh)
|
_, err = io.Copy(fileWriter, fh)
|
||||||
_ = fh.Close()
|
_ = fh.Close()
|
||||||
if err != nil {
|
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.
|
// 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 {
|
||||||
|
|||||||
@@ -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)))
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user