aboutsummaryrefslogtreecommitdiff
path: root/internal/route/repo/editor.go
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/editor.go
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/editor.go')
-rw-r--r--internal/route/repo/editor.go12
1 files changed, 6 insertions, 6 deletions
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
}