Lint fixes (part 1)

Fix a few misc linter issues:

main_test.go:750:7: Error return value is not checked (errcheck)
        touch(dirPath)
             ^
main_test.go:759:7: Error return value is not checked (errcheck)
        touch(filePath)
             ^
main_test.go:768:7: Error return value is not checked (errcheck)
        touch(newfilePath)
             ^
main.go:2089:3: S1023: redundant `return` statement (gosimple)
                return
                ^
main.go:1935:13: S1039: unnecessary use of fmt.Sprintf (gosimple)
                sshCmd += fmt.Sprintf(" -o StrictHostKeyChecking=no")
                          ^
main.go:1152:33: SA1016: os.Kill cannot be trapped (did you mean syscall.SIGTERM?) (staticcheck)
        signal.Notify(c, os.Interrupt, os.Kill)
This commit is contained in:
justinsb 2023-07-29 10:44:16 -04:00
parent 71a7aca57e
commit 4aa9cd7487
2 changed files with 11 additions and 6 deletions

View File

@ -1149,7 +1149,7 @@ func setRepoReady() {
// it is deadlocked. // it is deadlocked.
func sleepForever() { func sleepForever() {
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill) signal.Notify(c, os.Interrupt)
<-c <-c
os.Exit(0) os.Exit(0)
} }
@ -1932,7 +1932,7 @@ func (git *repoSync) SetupGitSSH(setupKnownHosts bool, pathToSSHSecret, pathToSS
} }
sshCmd += fmt.Sprintf(" -o StrictHostKeyChecking=yes -o UserKnownHostsFile=%s", pathToSSHKnownHosts) sshCmd += fmt.Sprintf(" -o StrictHostKeyChecking=yes -o UserKnownHostsFile=%s", pathToSSHKnownHosts)
} else { } else {
sshCmd += fmt.Sprintf(" -o StrictHostKeyChecking=no") sshCmd += " -o StrictHostKeyChecking=no"
} }
git.log.V(9).Info("setting GIT_SSH_COMMAND", "value", sshCmd) git.log.V(9).Info("setting GIT_SSH_COMMAND", "value", sshCmd)
@ -2086,7 +2086,6 @@ func parseGitConfigs(configsFlag string) ([]keyVal, error) {
} }
} }
close(ch) close(ch)
return
}() }()
result := []keyVal{} result := []keyVal{}

View File

@ -747,7 +747,9 @@ func TestTouch(t *testing.T) {
stamp := time.Now() stamp := time.Now()
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
touch(dirPath) if err := touch(dirPath); err != nil {
t.Fatalf("touch(dir) failed: %v", err)
}
if dirInfo, err := os.Stat(dirPath.String()); err != nil { if dirInfo, err := os.Stat(dirPath.String()); err != nil {
t.Fatalf("can't stat dir: %v", err) t.Fatalf("can't stat dir: %v", err)
} else if !dirInfo.IsDir() { } else if !dirInfo.IsDir() {
@ -756,7 +758,9 @@ func TestTouch(t *testing.T) {
t.Errorf("touch(dir) mtime %v is not after %v", dirInfo.ModTime(), stamp) t.Errorf("touch(dir) mtime %v is not after %v", dirInfo.ModTime(), stamp)
} }
touch(filePath) if err := touch(filePath); err != nil {
t.Fatalf("touch(file) failed: %v", err)
}
if fileInfo, err := os.Stat(filePath.String()); err != nil { if fileInfo, err := os.Stat(filePath.String()); err != nil {
t.Fatalf("can't stat file: %v", err) t.Fatalf("can't stat file: %v", err)
} else if fileInfo.IsDir() { } else if fileInfo.IsDir() {
@ -765,7 +769,9 @@ func TestTouch(t *testing.T) {
t.Errorf("touch(file) mtime %v is not after %v", fileInfo.ModTime(), stamp) t.Errorf("touch(file) mtime %v is not after %v", fileInfo.ModTime(), stamp)
} }
touch(newfilePath) if err := touch(newfilePath); err != nil {
t.Fatalf("touch(newfile) failed: %v", err)
}
if newfileInfo, err := os.Stat(newfilePath.String()); err != nil { if newfileInfo, err := os.Stat(newfilePath.String()); err != nil {
t.Fatalf("can't stat newfile: %v", err) t.Fatalf("can't stat newfile: %v", err)
} else if newfileInfo.IsDir() { } else if newfileInfo.IsDir() {