Skip to content

Commit e6645f3

Browse files
committed
Fix staticcheck QF1012 lint warnings in diff package
1 parent 70dd557 commit e6645f3

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

internal/diff/diff.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ func generateSimpleDiff(path string, oldContent, newContent []byte) (string, int
195195

196196
// Simple line-by-line comparison (can be improved with Myers algorithm)
197197
var buf strings.Builder
198-
buf.WriteString(fmt.Sprintf("--- a/%s\n", path))
199-
buf.WriteString(fmt.Sprintf("+++ b/%s\n", path))
198+
fmt.Fprintf(&buf, "--- a/%s\n", path)
199+
fmt.Fprintf(&buf, "+++ b/%s\n", path)
200200

201201
linesAdded := 0
202202
linesDeleted := 0
@@ -277,7 +277,7 @@ func generateSimpleDiff(path string, oldContent, newContent []byte) (string, int
277277
hunkNewCount := (newStart - hunkNewStart) + newCount + contextAfter
278278

279279
// Write hunk header
280-
buf.WriteString(fmt.Sprintf("@@ -%d,%d +%d,%d @@\n", hunkOldStart+1, hunkOldCount, hunkNewStart+1, hunkNewCount))
280+
fmt.Fprintf(&buf, "@@ -%d,%d +%d,%d @@\n", hunkOldStart+1, hunkOldCount, hunkNewStart+1, hunkNewCount)
281281
buf.WriteString(hunk.String())
282282

283283
return buf.String(), linesAdded, linesDeleted
@@ -287,10 +287,10 @@ func generateSimpleDiff(path string, oldContent, newContent []byte) (string, int
287287
func generateAddedDiff(path string, content []byte) string {
288288
var buf strings.Builder
289289
buf.WriteString("--- /dev/null\n")
290-
buf.WriteString(fmt.Sprintf("+++ b/%s\n", path))
290+
fmt.Fprintf(&buf, "+++ b/%s\n", path)
291291

292292
lines := bytes.Split(content, []byte("\n"))
293-
buf.WriteString(fmt.Sprintf("@@ -0,0 +1,%d @@\n", len(lines)))
293+
fmt.Fprintf(&buf, "@@ -0,0 +1,%d @@\n", len(lines))
294294

295295
for _, line := range lines {
296296
buf.WriteString("+" + string(line) + "\n")

0 commit comments

Comments
 (0)