Skip to content

Commit

Permalink
Add mirror linter
Browse files Browse the repository at this point in the history
This flags unnecessary conversions of byte->string and vice versa

Signed-off-by: Anders Eknert <[email protected]>
  • Loading branch information
anderseknert authored and ashutosh-narkar committed Sep 26, 2024
1 parent 71ab7ba commit af8f915
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ linter-settings:
linters:
disable-all: true
enable:
- mirror
- errcheck
- govet
- ineffassign
Expand Down
2 changes: 1 addition & 1 deletion cmd/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion compile/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion topdown/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit af8f915

Please sign in to comment.