Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yoanm committed Aug 30, 2024
1 parent ff4c110 commit 670bf20
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
6 changes: 0 additions & 6 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ var (

errInputDirectoryDoesntExist = errors.New("input directory doesn't exist")
errRepositoryAlreadyImported = errors.New("repository already imported")

errPathIsNotADirectory = errors.New("path is not a directory")
)

func workspaceLoadingError(errList []error) error {
Expand Down Expand Up @@ -52,7 +50,3 @@ func alreadyImportedRepositoryError(repoName string, filepathList []string) erro
strings.Join(filepathList, ", "),
)
}

func pathIsNotADirectoryError(path string) error {
return fmt.Errorf("%w: %s", errPathIsNotADirectory, path)
}
23 changes: 2 additions & 21 deletions fshelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,15 @@ import (
func readDirectory(rootPath string) ([]string, error) {
files, err := os.ReadDir(rootPath)
if err != nil {
//nolint:wrapcheck // Expected to return error as is
return nil, err
}

var res []string
res := make([]string, 0, len(files))

for _, file := range files {
res = append(res, file.Name())
}

return res, nil
}

func openDirectory(path string) (*os.File, error) {
directory, readErr := os.Open(path)
if readErr != nil {
//nolint:wrapcheck // Expected to return error as is
return nil, readErr
}

directoryStat, statErr := directory.Stat()
if statErr != nil {
//nolint:wrapcheck // Expected to return error as is
return nil, statErr
}

if !directoryStat.IsDir() {
return nil, pathIsNotADirectoryError(path)
}

return directory, nil
}

0 comments on commit 670bf20

Please sign in to comment.