aboutsummaryrefslogtreecommitdiff
path: root/internal/route/repo
diff options
context:
space:
mode:
authordeepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>2022-03-06 16:33:45 +0800
committerGitHub <noreply@github.com>2022-03-06 16:33:45 +0800
commitdeec3516d53e9a9679128ade0556ccc818a67be1 (patch)
treeb5c1c5d55be05a244180ece0b822e7e35dc68f42 /internal/route/repo
parent65526f84e1d382ac01b7379f40fc56b2660d1074 (diff)
autofix: fix check for empty string (#6804)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Diffstat (limited to 'internal/route/repo')
-rw-r--r--internal/route/repo/commit.go4
-rw-r--r--internal/route/repo/editor.go12
-rw-r--r--internal/route/repo/http.go2
-rw-r--r--internal/route/repo/issue.go10
-rw-r--r--internal/route/repo/release.go2
-rw-r--r--internal/route/repo/setting.go2
-rw-r--r--internal/route/repo/view.go2
-rw-r--r--internal/route/repo/wiki.go4
8 files changed, 19 insertions, 19 deletions
diff --git a/internal/route/repo/commit.go b/internal/route/repo/commit.go
index ae424d06..3e09bd06 100644
--- a/internal/route/repo/commit.go
+++ b/internal/route/repo/commit.go
@@ -25,7 +25,7 @@ const (
func RefCommits(c *context.Context) {
c.Data["PageIsViewFiles"] = true
switch {
- case len(c.Repo.TreePath) == 0:
+ case c.Repo.TreePath == "":
Commits(c)
case c.Repo.TreePath == "search":
SearchCommits(c)
@@ -85,7 +85,7 @@ func SearchCommits(c *context.Context) {
c.Data["PageIsCommits"] = true
keyword := c.Query("q")
- if len(keyword) == 0 {
+ if keyword == "" {
c.Redirect(c.Repo.RepoLink + "/commits/" + c.Repo.BranchName)
return
}
diff --git a/internal/route/repo/editor.go b/internal/route/repo/editor.go
index 6556187e..8f612a98 100644
--- a/internal/route/repo/editor.go
+++ b/internal/route/repo/editor.go
@@ -33,7 +33,7 @@ const (
// getParentTreeFields returns list of parent tree names and corresponding tree paths
// based on given tree path.
func getParentTreeFields(treePath string) (treeNames, treePaths []string) {
- if len(treePath) == 0 {
+ if treePath == "" {
return treeNames, treePaths
}
@@ -158,7 +158,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
return
}
- if len(f.TreePath) == 0 {
+ if f.TreePath == "" {
c.FormErr("TreePath")
c.RenderWithErr(c.Tr("repo.editor.filename_cannot_be_empty"), tmplEditorEdit, &f)
return
@@ -248,7 +248,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
}
message := strings.TrimSpace(f.CommitSummary)
- if len(message) == 0 {
+ if message == "" {
if isNewFile {
message = c.Tr("repo.editor.add", f.TreePath)
} else {
@@ -362,7 +362,7 @@ func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
}
message := strings.TrimSpace(f.CommitSummary)
- if len(message) == 0 {
+ if message == "" {
message = c.Tr("repo.editor.delete", c.Repo.TreePath)
}
@@ -481,7 +481,7 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
}
message := strings.TrimSpace(f.CommitSummary)
- if len(message) == 0 {
+ if message == "" {
message = c.Tr("repo.editor.upload_files_to_dir", f.TreePath)
}
@@ -555,7 +555,7 @@ func UploadFileToServer(c *context.Context) {
}
func RemoveUploadFileFromServer(c *context.Context, f form.RemoveUploadFile) {
- if len(f.File) == 0 {
+ if f.File == "" {
c.Status(http.StatusNoContent)
return
}
diff --git a/internal/route/repo/http.go b/internal/route/repo/http.go
index e14569f1..67d8edf8 100644
--- a/internal/route/repo/http.go
+++ b/internal/route/repo/http.go
@@ -106,7 +106,7 @@ func HTTPContexter() macaron.Handler {
// Handle HTTP Basic Authentication
authHead := c.Req.Header.Get("Authorization")
- if len(authHead) == 0 {
+ if authHead == "" {
askCredentials(c, http.StatusUnauthorized, "")
return
}
diff --git a/internal/route/repo/issue.go b/internal/route/repo/issue.go
index 1b64cfe2..5caa16cb 100644
--- a/internal/route/repo/issue.go
+++ b/internal/route/repo/issue.go
@@ -700,7 +700,7 @@ func UpdateIssueTitle(c *context.Context) {
}
title := c.QueryTrim("title")
- if len(title) == 0 {
+ if title == "" {
c.Status(http.StatusNoContent)
return
}
@@ -903,7 +903,7 @@ func NewComment(c *context.Context, f form.CreateComment) {
}()
// Fix #321: Allow empty comments, as long as we have attachments.
- if len(f.Content) == 0 && len(attachments) == 0 {
+ if f.Content == "" && len(attachments) == 0 {
return
}
@@ -933,7 +933,7 @@ func UpdateCommentContent(c *context.Context) {
oldContent := comment.Content
comment.Content = c.Query("content")
- if len(comment.Content) == 0 {
+ if comment.Content == "" {
c.JSONSuccess(map[string]interface{}{
"content": "",
})
@@ -1127,7 +1127,7 @@ func NewMilestonePost(c *context.Context, f form.CreateMilestone) {
return
}
- if len(f.Deadline) == 0 {
+ if f.Deadline == "" {
f.Deadline = "9999-12-31"
}
deadline, err := time.ParseInLocation("2006-01-02", f.Deadline, time.Local)
@@ -1183,7 +1183,7 @@ func EditMilestonePost(c *context.Context, f form.CreateMilestone) {
return
}
- if len(f.Deadline) == 0 {
+ if f.Deadline == "" {
f.Deadline = "9999-12-31"
}
deadline, err := time.ParseInLocation("2006-01-02", f.Deadline, time.Local)
diff --git a/internal/route/repo/release.go b/internal/route/repo/release.go
index 1b3de8a5..f8a90f42 100644
--- a/internal/route/repo/release.go
+++ b/internal/route/repo/release.go
@@ -293,7 +293,7 @@ func EditReleasePost(c *context.Context, f form.EditRelease) {
attachments = f.Files
}
- isPublish := rel.IsDraft && len(f.Draft) == 0
+ isPublish := rel.IsDraft && f.Draft == ""
rel.Title = f.Title
rel.Note = f.Content
rel.IsDraft = len(f.Draft) > 0
diff --git a/internal/route/repo/setting.go b/internal/route/repo/setting.go
index dcbf520c..3df230ea 100644
--- a/internal/route/repo/setting.go
+++ b/internal/route/repo/setting.go
@@ -378,7 +378,7 @@ func SettingsCollaboration(c *context.Context) {
func SettingsCollaborationPost(c *context.Context) {
name := strings.ToLower(c.Query("collaborator"))
- if len(name) == 0 || c.Repo.Owner.LowerName == name {
+ if name == "" || c.Repo.Owner.LowerName == name {
c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
return
}
diff --git a/internal/route/repo/view.go b/internal/route/repo/view.go
index f105ad65..e9f340cb 100644
--- a/internal/route/repo/view.go
+++ b/internal/route/repo/view.go
@@ -177,7 +177,7 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
var output bytes.Buffer
lines := strings.Split(fileContent, "\n")
// Remove blank line at the end of file
- if len(lines) > 0 && len(lines[len(lines)-1]) == 0 {
+ if len(lines) > 0 && lines[len(lines)-1] == "" {
lines = lines[:len(lines)-1]
}
for index, line := range lines {
diff --git a/internal/route/repo/wiki.go b/internal/route/repo/wiki.go
index b9f754ee..70c82626 100644
--- a/internal/route/repo/wiki.go
+++ b/internal/route/repo/wiki.go
@@ -75,7 +75,7 @@ func renderWikiPage(c *context.Context, isViewPage bool) (*git.Repository, strin
}
pageURL := c.Params(":page")
- if len(pageURL) == 0 {
+ if pageURL == "" {
pageURL = "Home"
}
c.Data["PageURL"] = pageURL
@@ -253,7 +253,7 @@ func EditWikiPost(c *context.Context, f form.NewWiki) {
func DeleteWikiPagePost(c *context.Context) {
pageURL := c.Params(":page")
- if len(pageURL) == 0 {
+ if pageURL == "" {
pageURL = "Home"
}