fix new lint warnings

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2024-08-14 08:46:18 +02:00
parent 62426d25da
commit d783ffc13f
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF
9 changed files with 25 additions and 26 deletions

View file

@ -269,7 +269,7 @@ func (c *RetentionCheck) cleanupFolder(folderPath string, recursion int) error {
return nil
}
result.Error = fmt.Sprintf("unable to get lister for directory %q", folderPath)
c.conn.Log(logger.LevelError, result.Error)
c.conn.Log(logger.LevelError, "%s", result.Error)
return err
}
defer lister.Close()

View file

@ -9346,7 +9346,7 @@ func printLatestLogs(maxNumberOfLines int) {
return
}
for _, line := range lines {
logger.DebugToConsole(line)
logger.DebugToConsole("%s", line)
}
}

View file

@ -2590,9 +2590,8 @@ func createProvider(basePath string) error {
return initializeBoltProvider(basePath)
case MemoryDataProviderName:
if err := initializeMemoryProvider(basePath); err != nil {
msg := fmt.Sprintf("provider initialized but data loading failed: %v", err)
logger.Warn(logSender, "", msg)
logger.WarnToConsole(msg)
logger.Warn(logSender, "", "provider initialized but data loading failed: %v", err)
logger.WarnToConsole("provider initialized but data loading failed: %v", err)
}
return nil
default:

View file

@ -2544,14 +2544,14 @@ func TestRename(t *testing.T) {
assert.NoError(t, err)
err = client.MakeDir(path.Join(otherDir, testDir))
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("SITE CHMOD 0001 %v", otherDir))
code, response, err := client.SendCommand("SITE CHMOD 0001 %v", otherDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
err = client.Rename(testDir, path.Join(otherDir, testDir))
assert.Error(t, err)
code, response, err = client.SendCommand(fmt.Sprintf("SITE CHMOD 755 %v", otherDir))
code, response, err = client.SendCommand("SITE CHMOD 755 %v", otherDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
@ -2611,7 +2611,7 @@ func TestSymlink(t *testing.T) {
assert.NoError(t, err)
err = ftpUploadFile(testFilePath, testFileName, testFileSize, client, 0)
assert.NoError(t, err)
code, _, err := client.SendCommand(fmt.Sprintf("SITE SYMLINK %v %v", testFileName, testFileName+".link"))
code, _, err := client.SendCommand("SITE SYMLINK %v %v", testFileName, testFileName+".link")
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
@ -2622,15 +2622,15 @@ func TestSymlink(t *testing.T) {
assert.NoError(t, err)
err = client.MakeDir(path.Join(otherDir, testDir))
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("SITE CHMOD 0001 %v", otherDir))
code, response, err := client.SendCommand("SITE CHMOD 0001 %v", otherDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
code, _, err = client.SendCommand(fmt.Sprintf("SITE SYMLINK %v %v", testDir, path.Join(otherDir, testDir)))
code, _, err = client.SendCommand("SITE SYMLINK %v %v", testDir, path.Join(otherDir, testDir))
assert.NoError(t, err)
assert.Equal(t, ftp.StatusFileUnavailable, code)
code, response, err = client.SendCommand(fmt.Sprintf("SITE CHMOD 755 %v", otherDir))
code, response, err = client.SendCommand("SITE CHMOD 755 %v", otherDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
@ -3062,7 +3062,7 @@ func TestChtimes(t *testing.T) {
assert.NoError(t, err)
mtime := time.Now().Format("20060102150405")
code, response, err := client.SendCommand(fmt.Sprintf("MFMT %v %v", mtime, testFileName))
code, response, err := client.SendCommand("MFMT %v %v", mtime, testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusFile, code)
assert.Equal(t, fmt.Sprintf("Modify=%v; %v", mtime, testFileName), response)
@ -3139,7 +3139,7 @@ func TestSTAT(t *testing.T) {
assert.NoError(t, err)
err = ftpUploadFile(testFilePath, path.Join(testDir, testFileName+"_1"), testFileSize, client, 0)
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("STAT %s", testDir))
code, response, err := client.SendCommand("STAT %s", testDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusDirectory, code)
assert.Contains(t, response, fmt.Sprintf("STAT %s", testDir))
@ -3173,7 +3173,7 @@ func TestChown(t *testing.T) {
assert.NoError(t, err)
err = ftpUploadFile(testFilePath, testFileName, testFileSize, client, 0)
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("SITE CHOWN 1000:1000 %v", testFileName))
code, response, err := client.SendCommand("SITE CHOWN 1000:1000 %v", testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusFileUnavailable, code)
assert.Equal(t, "Couldn't chown: operation unsupported", response)
@ -3211,7 +3211,7 @@ func TestChmod(t *testing.T) {
err = ftpUploadFile(testFilePath, testFileName, testFileSize, client, 0)
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("SITE CHMOD 600 %v", testFileName))
code, response, err := client.SendCommand("SITE CHMOD 600 %v", testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
@ -3374,12 +3374,12 @@ func TestHASH(t *testing.T) {
err = f.Close()
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("XSHA256 %v", testFileName))
code, response, err := client.SendCommand("XSHA256 %v", testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusRequestedFileActionOK, code)
assert.Contains(t, response, hash)
code, response, err = client.SendCommand(fmt.Sprintf("HASH %v", testFileName))
code, response, err = client.SendCommand("HASH %v", testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusFile, code)
assert.Contains(t, response, hash)
@ -3435,7 +3435,7 @@ func TestCombine(t *testing.T) {
err = ftpUploadFile(testFilePath, testFileName+".2", testFileSize, client, 0)
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("COMB %v %v %v", testFileName, testFileName+".1", testFileName+".2"))
code, response, err := client.SendCommand("COMB %v %v %v", testFileName, testFileName+".1", testFileName+".2")
assert.NoError(t, err)
if user.Username == defaultUsername {
assert.Equal(t, ftp.StatusRequestedFileActionOK, code)

View file

@ -28,10 +28,10 @@ type LegoAdapter struct {
// Fatal emits a log at Error level
func (l *LegoAdapter) Fatal(args ...any) {
if l.LogToConsole {
ErrorToConsole(fmt.Sprint(args...))
ErrorToConsole("%s", fmt.Sprint(args...))
return
}
Log(LevelError, legoLogSender, "", fmt.Sprint(args...))
Log(LevelError, legoLogSender, "", "%s", fmt.Sprint(args...))
}
// Fatalln is the same as Fatal
@ -51,10 +51,10 @@ func (l *LegoAdapter) Fatalf(format string, args ...any) {
// Print emits a log at Info level
func (l *LegoAdapter) Print(args ...any) {
if l.LogToConsole {
InfoToConsole(fmt.Sprint(args...))
InfoToConsole("%s", fmt.Sprint(args...))
return
}
Log(LevelInfo, legoLogSender, "", fmt.Sprint(args...))
Log(LevelInfo, legoLogSender, "", "%s", fmt.Sprint(args...))
}
// Println is the same as Print

View file

@ -284,7 +284,7 @@ func (l *StdLoggerWrapper) Write(p []byte) (n int, err error) {
p = p[0 : n-1]
}
Log(LevelError, l.Sender, "", bytesToString(p))
Log(LevelError, l.Sender, "", "%s", bytesToString(p))
return
}

View file

@ -104,7 +104,7 @@ func (s *Service) Start(disableAWSInstallationCode bool) error {
}
}
if !config.HasServicesToStart() {
infoString := "no service configured, nothing to do"
const infoString = "no service configured, nothing to do"
logger.Info(logSender, "", infoString)
logger.InfoToConsole(infoString)
return errors.New(infoString)

View file

@ -11815,7 +11815,7 @@ func printLatestLogs(maxNumberOfLines int) {
return
}
for _, line := range lines {
logger.DebugToConsole(line)
logger.DebugToConsole("%s", line)
}
}

View file

@ -3558,6 +3558,6 @@ func printLatestLogs(maxNumberOfLines int) {
return
}
for _, line := range lines {
logger.DebugToConsole(line)
logger.DebugToConsole("%s", line)
}
}