chore: Updating linter, fixing some new warnings (#88863)

This commit is contained in:
Dave Henderson
2024-06-06 13:01:27 -04:00
committed by GitHub
parent c9778c3332
commit e21d357d67
13 changed files with 106 additions and 923 deletions

View File

@@ -51,7 +51,7 @@ func validateInput(c utils.CommandLine) error {
fileInfo, err := os.Stat(pluginsDir)
if err != nil {
if err = os.MkdirAll(pluginsDir, os.ModePerm); err != nil {
if err = os.MkdirAll(pluginsDir, 0o750); err != nil {
return fmt.Errorf("pluginsDir (%s) is not a writable directory", pluginsDir)
}
return nil

View File

@@ -113,7 +113,7 @@ func runTests(createCases func() []fsTestCase, t *testing.T) {
}
nestedPath := path.Join("a", "b")
err = os.MkdirAll(path.Join(tmpDir, nestedPath), os.ModePerm)
err = os.MkdirAll(path.Join(tmpDir, nestedPath), 0o750)
if err != nil {
t.Fatal(err)
}

View File

@@ -467,7 +467,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) error {
case "file":
fileName := sec.Key("file_name").MustString(filepath.Join(logsPath, "grafana.log"))
dpath := filepath.Dir(fileName)
if err := os.MkdirAll(dpath, os.ModePerm); err != nil {
if err := os.MkdirAll(dpath, 0o750); err != nil {
_ = level.Error(root).Log("Failed to create directory", "dpath", dpath, "err", err)
continue
}

View File

@@ -33,7 +33,7 @@ func TestLocalFS_Remove(t *testing.T) {
t.Run("Uninstall will search in nested dist folder for plugin.json", func(t *testing.T) {
pluginDistDir := filepath.Join(t.TempDir(), "dist")
err = os.Mkdir(pluginDistDir, os.ModePerm)
err = os.Mkdir(pluginDistDir, 0o750)
require.NoError(t, err)
pluginJSON = filepath.Join(pluginDistDir, "plugin.json")
//nolint:gosec
@@ -59,7 +59,7 @@ func TestLocalFS_Remove(t *testing.T) {
t.Run("Uninstall will not delete folder if cannot recognize plugin structure", func(t *testing.T) {
pluginDir = filepath.Join(t.TempDir(), "system32")
err = os.Mkdir(pluginDir, os.ModePerm)
err = os.Mkdir(pluginDir, 0o750)
require.NoError(t, err)
testFile := filepath.Join(pluginDir, "important.exe")
//nolint:gosec

View File

@@ -16,7 +16,7 @@ import (
func TestAdd(t *testing.T) {
testDir := "./testdata/tmpInstallPluginDir"
err := os.MkdirAll(testDir, os.ModePerm)
err := os.MkdirAll(testDir, 0o750)
require.NoError(t, err)
t.Cleanup(func() {

View File

@@ -192,7 +192,7 @@ func (dbCfg *DatabaseConfig) buildConnectionString(cfg *setting.Cfg, features fe
if !filepath.IsAbs(dbCfg.Path) {
dbCfg.Path = filepath.Join(cfg.DataPath, dbCfg.Path)
}
if err := os.MkdirAll(path.Dir(dbCfg.Path), os.ModePerm); err != nil {
if err := os.MkdirAll(path.Dir(dbCfg.Path), 0o750); err != nil {
return err
}

View File

@@ -1245,7 +1245,7 @@ func (nc *mockNotificationChannel) ServeHTTP(res http.ResponseWriter, req *http.
nc.receivedNotifications[key] = append(nc.receivedNotifications[key], body)
res.Header().Set("Content-Type", "application/json")
res.WriteHeader(http.StatusOK)
fmt.Fprint(res, nc.responses[paths[0]])
_, _ = fmt.Fprint(res, nc.responses[paths[0]])
}
func (nc *mockNotificationChannel) totalNotifications() int {