mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 01:21:18 +02:00
Enable addtional linters (#34085)
enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
@@ -31,17 +32,17 @@ func Validate(template *api.IssueTemplate) error {
|
||||
|
||||
func validateMetadata(template *api.IssueTemplate) error {
|
||||
if strings.TrimSpace(template.Name) == "" {
|
||||
return fmt.Errorf("'name' is required")
|
||||
return errors.New("'name' is required")
|
||||
}
|
||||
if strings.TrimSpace(template.About) == "" {
|
||||
return fmt.Errorf("'about' is required")
|
||||
return errors.New("'about' is required")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateYaml(template *api.IssueTemplate) error {
|
||||
if len(template.Fields) == 0 {
|
||||
return fmt.Errorf("'body' is required")
|
||||
return errors.New("'body' is required")
|
||||
}
|
||||
ids := make(container.Set[string])
|
||||
for idx, field := range template.Fields {
|
||||
@@ -401,7 +402,7 @@ func (f *valuedField) Render() string {
|
||||
}
|
||||
|
||||
func (f *valuedField) Value() string {
|
||||
return strings.TrimSpace(f.Get(fmt.Sprintf("form-field-%s", f.ID)))
|
||||
return strings.TrimSpace(f.Get("form-field-" + f.ID))
|
||||
}
|
||||
|
||||
func (f *valuedField) Options() []*valuedOption {
|
||||
@@ -444,7 +445,7 @@ func (o *valuedOption) Label() string {
|
||||
func (o *valuedOption) IsChecked() bool {
|
||||
switch o.field.Type {
|
||||
case api.IssueFormFieldTypeDropdown:
|
||||
checks := strings.Split(o.field.Get(fmt.Sprintf("form-field-%s", o.field.ID)), ",")
|
||||
checks := strings.Split(o.field.Get("form-field-"+o.field.ID), ",")
|
||||
idx := strconv.Itoa(o.index)
|
||||
for _, v := range checks {
|
||||
if v == idx {
|
||||
|
Reference in New Issue
Block a user