all: Run modernize -fix ./...

This commit is contained in:
Bjørn Erik Pedersen
2025-02-26 10:15:04 +01:00
parent b7ae24b9c2
commit 521911a576
141 changed files with 302 additions and 354 deletions

View File

@@ -77,7 +77,7 @@ func (r *htmlRenderer) renderCodeBlock(w util.BufWriter, src []byte, node ast.No
var buff bytes.Buffer
l := n.Lines().Len()
for i := 0; i < l; i++ {
for i := range l {
line := n.Lines().At(i)
buff.Write(line.Value(src))
}

View File

@@ -182,7 +182,7 @@ func (r *hugoContextRenderer) renderHTMLBlock(
if entering {
if r.Unsafe {
l := n.Lines().Len()
for i := 0; i < l; i++ {
for i := range l {
line := n.Lines().At(i)
linev := line.Value(source)
var stripped bool
@@ -226,7 +226,7 @@ func (r *hugoContextRenderer) renderRawHTML(
n := node.(*ast.RawHTML)
l := n.Segments.Len()
if r.Unsafe {
for i := 0; i < l; i++ {
for i := range l {
segment := n.Segments.At(i)
_, _ = w.Write(segment.Value(source))
}

View File

@@ -110,7 +110,7 @@ func (r *htmlRenderer) renderPassthroughBlock(w util.BufWriter, src []byte, node
case (*passthrough.PassthroughBlock):
l := nn.Lines().Len()
var buff bytes.Buffer
for i := 0; i < l; i++ {
for i := range l {
line := nn.Lines().At(i)
buff.Write(line.Value(src))
}

View File

@@ -100,10 +100,7 @@ func (c *rstConverter) getRstContent(src []byte, ctx converter.DocumentContext)
bodyEnd := bytes.Index(result, []byte("\n</body>"))
if bodyEnd < 0 || bodyEnd >= len(result) {
bodyEnd = len(result) - 1
if bodyEnd < 0 {
bodyEnd = 0
}
bodyEnd = max(len(result)-1, 0)
}
return result[bodyStart+7 : bodyEnd], err

View File

@@ -250,7 +250,7 @@ func (b *tocBuilder) writeHeading(level, indent int, h *Heading) {
}
func (b *tocBuilder) indent(n int) {
for i := 0; i < n; i++ {
for range n {
b.s.WriteString(" ")
}
}

View File

@@ -196,7 +196,7 @@ func TestTocMisc(t *testing.T) {
func BenchmarkToc(b *testing.B) {
newTocs := func(n int) []*Fragments {
var tocs []*Fragments
for i := 0; i < n; i++ {
for range n {
tocs = append(tocs, newTestToc())
}
return tocs