Skip to content

Commit 6d136d0

Browse files
Copilotpelikhan
andauthored
Fix golangci-lint failures in codemod and miner test files (#31590)
* Initial plan * Fix golangci-lint errors: intrange, perfsprint, wastedassign, testifylint Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 21926a0 commit 6d136d0

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

pkg/agentdrain/miner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func TestConcurrency(t *testing.T) {
296296
for i := range linesEach {
297297
line := fmt.Sprintf("stage=work goroutine=%d iter=%d", id, i)
298298
_, trainErr := m.Train(line)
299-
require.NoError(t, trainErr, "Train should not error during concurrent access")
299+
assert.NoError(t, trainErr, "Train should not error during concurrent access")
300300
}
301301
}(g)
302302
}

pkg/cli/codemod_checkout_persist_credentials_false.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cli
22

33
import (
4-
"fmt"
54
"strings"
65

76
"github.com/github/gh-aw/pkg/logger"
@@ -309,22 +308,20 @@ func transformCheckoutWithinSection(sectionLines []string, sectionIndent string)
309308
func ensureStepCheckoutPersistCredentials(stepLines []string, stepIndent string) ([]string, bool) {
310309
usesIdx := -1
311310
usesIndent := ""
312-
isUsesInline := false
313311
withStart := -1
314312
withEnd := -1
315313
withIndent := ""
316-
withKeyIndentLen := 0
317314
persistIdx := -1
318315

319-
for i := 0; i < len(stepLines); i++ {
316+
for i := range stepLines {
320317
line := stepLines[i]
321318
trimmed := strings.TrimSpace(line)
322319
indent := getIndentation(line)
323320

324321
usesMatch, usesValue, _ := parseStepKeyLine(trimmed, indent, stepIndent, "uses")
325322
if usesMatch && isCheckoutUsesValue(usesValue) {
326323
usesIdx = i
327-
isUsesInline = strings.HasPrefix(trimmed, "- uses:") && len(indent) == len(stepIndent)
324+
isUsesInline := strings.HasPrefix(trimmed, "- uses:") && len(indent) == len(stepIndent)
328325
if isUsesInline {
329326
usesIndent = stepIndent + " "
330327
} else {
@@ -343,7 +340,7 @@ func ensureStepCheckoutPersistCredentials(stepLines []string, stepIndent string)
343340
withStart = i
344341
withEnd = i
345342
withIndent = indent
346-
withKeyIndentLen = currentWithKeyIndentLen
343+
withKeyIndentLen := currentWithKeyIndentLen
347344
for j := i + 1; j < len(stepLines); j++ {
348345
t := strings.TrimSpace(stepLines[j])
349346
if len(t) == 0 {
@@ -375,7 +372,7 @@ func ensureStepCheckoutPersistCredentials(stepLines []string, stepIndent string)
375372

376373
if withStart != -1 {
377374
insertAt := withEnd + 1
378-
insertLine := fmt.Sprintf("%spersist-credentials: false", withIndent+" ")
375+
insertLine := withIndent + " persist-credentials: false"
379376
updated := append([]string{}, stepLines[:insertAt]...)
380377
updated = append(updated, insertLine)
381378
updated = append(updated, stepLines[insertAt:]...)

pkg/cli/codemod_checkout_persist_credentials_false_fuzz_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package cli
44

55
import (
6-
"fmt"
76
"strings"
87
"testing"
98
)
@@ -82,9 +81,9 @@ func FuzzCheckoutPersistCredentialsFalseCodemod(f *testing.F) {
8281
}
8382

8483
func buildCheckoutFuzzContent(section, uses string, hasWith, hasPersist, persistTrue, inlineUses bool) string {
85-
usesLine := fmt.Sprintf(" uses: %s", uses)
84+
usesLine := " uses: " + uses
8685
if inlineUses {
87-
usesLine = fmt.Sprintf(" - uses: %s", uses)
86+
usesLine = " - uses: " + uses
8887
}
8988

9089
lines := []string{

0 commit comments

Comments
 (0)