caddyfile: modernize remaining index loops (rangeint)

Convert the remaining for-i index loops to range-over-int per golangci-lint
modernize. No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Francis Lavoie
2026-07-14 13:39:37 -04:00
parent c79ff6e1d3
commit d397ff52c0
2 changed files with 4 additions and 4 deletions

View File

@@ -386,7 +386,7 @@ func hasUnformattableToken(tokens []Token) bool {
// anyNonCommentBefore reports whether any token before index i is not a comment.
func anyNonCommentBefore(tokens []Token, i int) bool {
for j := 0; j < i; j++ {
for j := range i {
if !tokens[j].isComment {
return true
}
@@ -478,7 +478,7 @@ func formatTokens(tokens []Token) []byte {
prevTopClose := false
writeIndent := func() {
for i := 0; i < nesting; i++ {
for range nesting {
out.WriteByte('\t')
}
}
@@ -646,7 +646,7 @@ func formatTokens(tokens []Token) []byte {
body := tk.Raw()
if tk.continuation && !atLineStart {
out.WriteString(" \\\n")
for j := 0; j < nesting+1; j++ {
for range nesting + 1 {
out.WriteByte('\t')
}
body = strings.TrimLeft(strings.TrimPrefix(body, "\\"), " \t\r\n")

View File

@@ -532,7 +532,7 @@ func TestFormatImportStandaloneBrace(t *testing.T) {
func TestFormatDeepNestingNoCap(t *testing.T) {
// 12 levels deep; every level indents (no 10-level clamp)
var b strings.Builder
for i := 0; i < 12; i++ {
for i := range 12 {
b.WriteString(strings.Repeat("\t", i) + "l" + strconv.Itoa(i) + " {\n")
}
b.WriteString(strings.Repeat("\t", 12) + "x\n")