improvement - reducing cyclomatic complexity
@@ -125,16 +125,12 @@ func TestFileDownloadSkipCheck(t *testing.T) {
func createNewDir(srcPath string) error {
_, err := os.Stat(srcPath)
if err != nil {
- if errors.Is(err, os.ErrNotExist) {
- errMkDirAll := os.MkdirAll(srcPath, os.ModePerm)
- if errMkDirAll != nil {
- return errMkDirAll
- }
- } else {
- return err
+ return nil // path exists, nothing to do
}
+ if !errors.Is(err, os.ErrNotExist) {
+ return err // some other kind of non-recoverable error
}
- return nil
+ return os.MkdirAll(srcPath, os.ModePerm)
}
//Copies file from source path to destination path
