Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidaguerre committed Feb 6, 2025
1 parent 62bcd23 commit d8d7159
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions files/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ var testCasesListFiles = map[string]listFilesTest{
},
preRun: func() {
// create an empty directory
os.Mkdir(filepath.Join(wd, "test_data/list_test3/a/empty"), 0644)
_ = os.Mkdir(filepath.Join(wd, "test_data/list_test3/a/empty"), 0644)
},
postRun: func() {
// remove empty directory
os.RemoveAll(filepath.Join(wd, "test_data/list_test3/a/empty"))
_ = os.RemoveAll(filepath.Join(wd, "test_data/list_test3/a/empty"))
},
expected: []string{
"test_data/list_test3/.steampipe",
Expand All @@ -286,7 +286,7 @@ var testCasesListFiles = map[string]listFilesTest{
},
preRun: func() {
// create an empty directory
os.Mkdir(filepath.Join(wd, "test_data/list_test3/a/empty"), 0644)
_ = os.Mkdir(filepath.Join(wd, "test_data/list_test3/a/empty"), 0644)
},
postRun: func() {
// remove empty directory
Expand Down
4 changes: 2 additions & 2 deletions files/match_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package files

import (
"github.com/turbot/go-kit/helpers"
"slices"
"testing"
)

Expand Down Expand Up @@ -125,7 +125,7 @@ var matchTests = map[string]matchTestCase{
func TestMatch(t *testing.T) {
var testNames = []string{}
for name, test := range matchTests {
if len(testNames) > 0 && !helpers.StringSliceContains(testNames, name) {
if len(testNames) > 0 && !slices.Contains(testNames, name) {
continue
}
actual := Match(test.pattern, test.file)
Expand Down
15 changes: 8 additions & 7 deletions helpers/errors.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package helpers

import (
"errors"
"fmt"
"strings"
)

func CombineErrorsWithPrefix(prefix string, errors ...error) error {
if len(errors) == 0 {
func CombineErrorsWithPrefix(prefix string, errorList ...error) error {
if len(errorList) == 0 {
return nil
}

if len(errors) == 1 {
if len(errorList) == 1 {
if len(prefix) == 0 {
return errors[0]
return errorList[0]
} else {
return fmt.Errorf("%s - %s", prefix, errors[0].Error())
return fmt.Errorf("%s - %s", prefix, errorList[0].Error())
}
}

combinedErrorString := []string{prefix}
for _, e := range errors {
for _, e := range errorList {
combinedErrorString = append(combinedErrorString, e.Error())
}
return fmt.Errorf(strings.Join(combinedErrorString, "\n\t"))
return errors.New(strings.Join(combinedErrorString, "\n\t"))
}

func CombineErrors(errors ...error) error {
Expand Down
1 change: 1 addition & 0 deletions logging/rotatinglogwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (w *RotatingLogWriter) Write(p []byte) (n int, err error) {
w.currentWriter, err = os.OpenFile(w.currentPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
err = fmt.Errorf("failed to open steampipe log file: %s", err.Error())
return 0, err
}
}

Expand Down
1 change: 0 additions & 1 deletion types/type_checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type typeCheckInput struct {
_uint64 uint64
_float32 float32
_float64 float64
_byte byte // is this required as it's an alias for uint8?
_bool bool
_slice []string
_array [3]string
Expand Down

0 comments on commit d8d7159

Please sign in to comment.