1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-25 11:48:37 +00:00

enforce explanation for necessary nolints and fix bugs (#34883)

Follows up https://github.com/go-gitea/gitea/pull/34851

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TheFox0x7
2025-06-27 15:48:03 +02:00
committed by GitHub
parent 9854df3e87
commit aa9d86745a
48 changed files with 83 additions and 159 deletions

View File

@@ -42,7 +42,7 @@ var (
var ErrTemplateNotInitialized = errors.New("template system is not initialized, check your log for errors")
func (h *HTMLRender) HTML(w io.Writer, status int, tplName TplName, data any, ctx context.Context) error { //nolint:revive
func (h *HTMLRender) HTML(w io.Writer, status int, tplName TplName, data any, ctx context.Context) error { //nolint:revive // we don't use ctx, only pass it to the template executor
name := string(tplName)
if respWriter, ok := w.(http.ResponseWriter); ok {
if respWriter.Header().Get("Content-Type") == "" {
@@ -57,7 +57,7 @@ func (h *HTMLRender) HTML(w io.Writer, status int, tplName TplName, data any, ct
return t.Execute(w, data)
}
func (h *HTMLRender) TemplateLookup(name string, ctx context.Context) (TemplateExecutor, error) { //nolint:revive
func (h *HTMLRender) TemplateLookup(name string, ctx context.Context) (TemplateExecutor, error) { //nolint:revive // we don't use ctx, only pass it to the template executor
tmpls := h.templates.Load()
if tmpls == nil {
return nil, ErrTemplateNotInitialized

View File

@@ -102,31 +102,28 @@ func escapeTemplate(t *template.Template) error {
return nil
}
//nolint:unused
type htmlTemplate struct {
escapeErr error
text *texttemplate.Template
_/*escapeErr*/ error
text *texttemplate.Template
}
//nolint:unused
type textTemplateCommon struct {
tmpl map[string]*template.Template // Map from name to defined templates.
muTmpl sync.RWMutex // protects tmpl
option struct {
_/*tmpl*/ map[string]*template.Template
_/*muTmpl*/ sync.RWMutex
_/*option*/ struct {
missingKey int
}
muFuncs sync.RWMutex // protects parseFuncs and execFuncs
parseFuncs texttemplate.FuncMap
execFuncs map[string]reflect.Value
muFuncs sync.RWMutex
_/*parseFuncs*/ texttemplate.FuncMap
execFuncs map[string]reflect.Value
}
//nolint:unused
type textTemplate struct {
name string
_/*name*/ string
*parse.Tree
*textTemplateCommon
leftDelim string
rightDelim string
_/*leftDelim*/ string
_/*rightDelim*/ string
}
func ptr[T, P any](ptr *P) *T {