chore: Enable filepathJoin checker for gocritic (#13758)
Co-authored-by: Pawel Zak <Pawel Zak>
This commit is contained in:
parent
0d36ce0354
commit
5661341813
|
|
@ -95,6 +95,7 @@ linters-settings:
|
|||
- evalOrder
|
||||
- exitAfterDefer
|
||||
- externalErrorReassign
|
||||
- filepathJoin
|
||||
- flagName
|
||||
- mapKey
|
||||
- nilValReturn
|
||||
|
|
|
|||
|
|
@ -907,7 +907,7 @@ func TestConfig_MultipleProcessorsOrder(t *testing.T) {
|
|||
c := config.NewConfig()
|
||||
filenames := make([]string, 0, len(test.filename))
|
||||
for _, fn := range test.filename {
|
||||
filenames = append(filenames, filepath.Join("./testdata/processor_order", fn))
|
||||
filenames = append(filenames, filepath.Join(".", "testdata", "processor_order", fn))
|
||||
}
|
||||
require.NoError(t, c.LoadAll(filenames...))
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,10 @@ func TestCompileAndMatch(t *testing.T) {
|
|||
// test exclamation mark creates non-matching list without a range
|
||||
{path: filepath.Join(testdataDir, "log[!2]*"), matches: 2},
|
||||
// test exclamation mark creates non-matching list without a range
|
||||
//nolint:gocritic // filepathJoin - '\\' used to escape in glob, not path separator
|
||||
{path: filepath.Join(testdataDir, "log\\[!*"), matches: 1},
|
||||
// test exclamation mark creates non-matching list without a range
|
||||
//nolint:gocritic // filepathJoin - '\\' used to escape in glob, not path separator
|
||||
{path: filepath.Join(testdataDir, "log\\[^*"), matches: 0},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func resolveName(name string) string {
|
|||
return name
|
||||
}
|
||||
// Try to prepend "/dev"
|
||||
resolved, err = filepath.EvalSymlinks(filepath.Join("/dev", name))
|
||||
resolved, err = filepath.EvalSymlinks("/dev/" + name)
|
||||
if err != nil {
|
||||
return name
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func TestRefreshFilePaths(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
r := File{
|
||||
Files: []string{filepath.Join(wd, "dev/testfiles/**.log")},
|
||||
Files: []string{filepath.Join(wd, "dev", "testfiles", "**.log")},
|
||||
}
|
||||
err = r.Init()
|
||||
require.NoError(t, err)
|
||||
|
|
@ -42,7 +42,7 @@ func TestFileTag(t *testing.T) {
|
|||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
r := File{
|
||||
Files: []string{filepath.Join(wd, "dev/testfiles/json_a.log")},
|
||||
Files: []string{filepath.Join(wd, "dev", "testfiles", "json_a.log")},
|
||||
FileTag: "filename",
|
||||
}
|
||||
require.NoError(t, r.Init())
|
||||
|
|
@ -67,7 +67,7 @@ func TestJSONParserCompile(t *testing.T) {
|
|||
var acc testutil.Accumulator
|
||||
wd, _ := os.Getwd()
|
||||
r := File{
|
||||
Files: []string{filepath.Join(wd, "dev/testfiles/json_a.log")},
|
||||
Files: []string{filepath.Join(wd, "dev", "testfiles", "json_a.log")},
|
||||
}
|
||||
require.NoError(t, r.Init())
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ func TestGrokParser(t *testing.T) {
|
|||
wd, _ := os.Getwd()
|
||||
var acc testutil.Accumulator
|
||||
r := File{
|
||||
Files: []string{filepath.Join(wd, "dev/testfiles/grok_a.log")},
|
||||
Files: []string{filepath.Join(wd, "dev", "testfiles", "grok_a.log")},
|
||||
}
|
||||
err := r.Init()
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ package powerdns_recursor
|
|||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ func (p *PowerdnsRecursor) Init() error {
|
|||
}
|
||||
|
||||
if p.SocketDir == "" {
|
||||
p.SocketDir = filepath.Join("/", "var", "run")
|
||||
p.SocketDir = "/var/run"
|
||||
}
|
||||
|
||||
switch p.ControlProtocolVersion {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func (p *Prometheus) startK8s(ctx context.Context) error {
|
|||
return fmt.Errorf("failed to get current user: %w", err)
|
||||
}
|
||||
|
||||
kubeconfig := filepath.Join(u.HomeDir, ".kube/config")
|
||||
kubeconfig := filepath.Join(u.HomeDir, ".kube", "config")
|
||||
|
||||
config, err = loadConfig(kubeconfig)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ partitionRange:
|
|||
continue
|
||||
}
|
||||
|
||||
du.Path = filepath.Join("/", strings.TrimPrefix(p.Mountpoint, hostMountPrefix))
|
||||
du.Path = filepath.Join(string(os.PathSeparator), strings.TrimPrefix(p.Mountpoint, hostMountPrefix))
|
||||
du.Fstype = p.Fstype
|
||||
usage = append(usage, du)
|
||||
partitions = append(partitions, &p)
|
||||
|
|
|
|||
|
|
@ -8,5 +8,5 @@ import (
|
|||
)
|
||||
|
||||
func servicesPath() string {
|
||||
return filepath.Join(os.Getenv("WINDIR"), `system32\drivers\etc\services`)
|
||||
return filepath.Join(os.Getenv("WINDIR"), "system32", "drivers", "etc", "services")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ func TempSocket(tb testing.TB) string {
|
|||
// If the name of the test is long, the path length could exceed 104
|
||||
// characters, and this would result in listen unix ...: bind: invalid argument
|
||||
if runtime.GOOS == "darwin" {
|
||||
sock := filepath.Join("/tmp", "sock")
|
||||
sock := "/tmp/sock"
|
||||
|
||||
tb.Cleanup(func() {
|
||||
require.NoError(tb, os.RemoveAll(sock))
|
||||
|
|
|
|||
Loading…
Reference in New Issue