1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-05 18:17:19 +00:00

enable staticcheck QFxxxx rules (#34064)

This commit is contained in:
TheFox0x7
2025-03-29 22:32:28 +01:00
committed by GitHub
parent 5564c39105
commit 2a59dfbd47
47 changed files with 179 additions and 143 deletions

View File

@ -85,9 +85,10 @@ func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Cont
} else if lastChar == ')' {
closing := 0
for i := m[1] - 1; i >= m[0]; i-- {
if line[i] == ')' {
switch line[i] {
case ')':
closing++
} else if line[i] == '(' {
case '(':
closing--
}
}

View File

@ -80,9 +80,10 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
// many places render non-comment contents with no mode=document, then these contents also use comment's hard line break setting
// especially in many tests.
markdownLineBreakStyle := ctx.RenderOptions.Metas["markdownLineBreakStyle"]
if markdownLineBreakStyle == "comment" {
switch markdownLineBreakStyle {
case "comment":
v.SetHardLineBreak(setting.Markdown.EnableHardLineBreakInComments)
} else if markdownLineBreakStyle == "document" {
case "document":
v.SetHardLineBreak(setting.Markdown.EnableHardLineBreakInDocuments)
}
}
@ -155,7 +156,7 @@ func (r *HTMLRenderer) renderDocument(w util.BufWriter, source []byte, node ast.
if entering {
_, err = w.WriteString("<div")
if err == nil {
_, err = w.WriteString(fmt.Sprintf(` lang=%q`, val))
_, err = fmt.Fprintf(w, ` lang=%q`, val)
}
if err == nil {
_, err = w.WriteRune('>')

View File

@ -70,10 +70,11 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser.
startMarkLen = 1
stopMark = parser.endBytesSingleDollar
if len(line) > 1 {
if line[1] == '$' {
switch line[1] {
case '$':
startMarkLen = 2
stopMark = parser.endBytesDoubleDollar
} else if line[1] == '`' {
case '`':
pos := 1
for ; pos < len(line) && line[pos] == '`'; pos++ {
}
@ -121,9 +122,10 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser.
i++
continue
}
if line[i] == '{' {
switch line[i] {
case '{':
depth++
} else if line[i] == '}' {
case '}':
depth--
}
}

View File

@ -107,11 +107,12 @@ func (r *stripRenderer) processAutoLink(w io.Writer, link []byte) {
}
var sep string
if parts[3] == "issues" {
switch parts[3] {
case "issues":
sep = "#"
} else if parts[3] == "pulls" {
case "pulls":
sep = "!"
} else {
default:
// Process out of band
r.links = append(r.links, linkStr)
return