Fix S1030 violations and drop suppression

This commit is contained in:
Tamir Duberstein
2026-02-10 11:56:15 -08:00
parent 034a884aeb
commit 6b04a93c2b
8 changed files with 7 additions and 11 deletions
-4
View File
@@ -239,10 +239,6 @@ analyzers:
# See above.
- "symbol \"runtime_pollWaitCanceled\".*"
- "symbol \"runtime_procPin\".*"
S1030: # Use `bytes.Buffer.String` or `bytes.Buffer.Bytes`
# disabled for now due to existing violations.
internal:
exclude: [".*"]
S1033: # Remove unnecessary guard around delete
# disabled for now due to existing violations.
internal:
+1 -1
View File
@@ -193,7 +193,7 @@ func TestBlockSeqIterBytes(t *testing.T) {
}
srcs = nextSrcs
}
if got := string(dst.Bytes()); got != test.want {
if got := dst.String(); got != test.want {
t.Errorf("Copied string: got %q, wanted %q", got, test.want)
}
})
+1 -1
View File
@@ -109,5 +109,5 @@ func (c *Agent) String() string {
// c.buf.Bytes(), which may be modified after c.mu.Unlock(). If you change
// this function to return []byte for some reason, c.buf.Bytes() needs to
// be cloned instead.
return string(c.buf.Bytes())
return c.buf.String()
}
+1 -1
View File
@@ -56,7 +56,7 @@ func (mm *MemoryManager) DebugString(ctx context.Context) string {
b.Write(pseg.debugStringEntryLocked())
}
return string(b.Bytes())
return b.String()
}
// Preconditions: mm.activeMu must be locked.
@@ -37,7 +37,7 @@ func TestCreateTaskRequest(t *testing.T) {
if err := proto.MarshalText(&textBuffer, got); err != nil {
t.Errorf("unable to marshal text: %v", err)
}
t.Logf("got: %s", string(textBuffer.Bytes()))
t.Logf("got: %s", textBuffer.String())
// Check the options.
wantOptions := &Options{}
+1 -1
View File
@@ -715,7 +715,7 @@ func (ds *decodeState) Load(obj reflect.Value) {
fmt.Fprintf(&buf, "%q", cycleOS.obj.Type())
}
buf.WriteString("}")
Failf("incomplete graph: %s", string(buf.Bytes()))
Failf("incomplete graph: %s", buf.String())
}
}
+1 -1
View File
@@ -141,5 +141,5 @@ func (s *Stats) String() string {
buf.WriteString("-----------------+----------+------------------+----------------\n")
buf.WriteString(fmt.Sprintf("% 16s | % 8d | % 16s | [all]",
total, count, total/time.Duration(count)))
return string(buf.Bytes())
return buf.String()
}
+1 -1
View File
@@ -100,7 +100,7 @@ func convertExpression(s string, imports mapValue, used map[string]*importedPack
return "", err
}
return string(buf.Bytes()), nil
return buf.String(), nil
}
// updateImports replaces all maps in the input slice with copies where the