Add mirror linter

This flags unnecessary conversions of byte->string and vice versa

Signed-off-by: Anders Eknert <anders@eknert.com>
This commit is contained in:
Anders Eknert
2024-09-26 22:21:14 +02:00
committed by Ashutosh Narkar
parent 71ab7ba986
commit af8f915846
5 changed files with 5 additions and 4 deletions
+1
View File
@@ -11,6 +11,7 @@ linter-settings:
linters:
disable-all: true
enable:
- mirror
- errcheck
- govet
- ineffassign
+1 -1
View File
@@ -1191,7 +1191,7 @@ func TestExecWithInvalidInputOptions(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error creating temp file: %q", err.Error())
}
if _, err := tempFile.Write([]byte(tt.input)); err != nil {
if _, err := tempFile.WriteString(tt.input); err != nil {
t.Fatalf("unexpeced error when writing to temp file: %q", err.Error())
}
if _, err := tempFile.Seek(0, 0); err != nil {
+1 -1
View File
@@ -209,7 +209,7 @@ func TestExec(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error creating temp file: %q", err.Error())
}
if _, err := tempFile.Write([]byte(tt.input)); err != nil {
if _, err := tempFile.WriteString(tt.input); err != nil {
t.Fatalf("unexpeced error when writing to temp file: %q", err.Error())
}
if _, err := tempFile.Seek(0, 0); err != nil {
+1 -1
View File
@@ -1893,7 +1893,7 @@ func modulesToString(modules []bundle.ModuleFile) string {
for i, m := range modules {
buf.WriteString(strconv.Itoa(i))
buf.WriteString(":\n")
buf.WriteString(string(m.Raw))
buf.Write(m.Raw)
buf.WriteString("\n\n")
}
return buf.String()
+1 -1
View File
@@ -473,7 +473,7 @@ func createHTTPRequest(bctx BuiltinContext, obj ast.Object) (*http.Request, *htt
}
body = bytes.NewBuffer(bodyValBytes)
case "raw_body":
rawBody = bytes.NewBuffer([]byte(strVal))
rawBody = bytes.NewBufferString(strVal)
case "tls_use_system_certs":
tempTLSUseSystemCerts, err := strconv.ParseBool(obj.Get(val).String())
if err != nil {