mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
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:
committed by
Ashutosh Narkar
parent
71ab7ba986
commit
af8f915846
@@ -11,6 +11,7 @@ linter-settings:
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- mirror
|
||||
- errcheck
|
||||
- govet
|
||||
- ineffassign
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user