🛠 golangci-lint

This commit is contained in:
Dan Jones 2025-04-24 14:27:19 -05:00
commit 7aae44048a
9 changed files with 144 additions and 85 deletions

View file

@ -84,6 +84,35 @@ func processFile(input processInput) (processed bool, processError, cbError erro
return
}
func processSource(allFiles ezcache.Cache[string, []os.DirEntry], d *Data, s *Show, source string, stopOnError bool, cb ShowWalker) (count int, err error) {
files, filesErr := allFiles.Get(source)
if filesErr != nil {
return 0, filesErr
}
for _, file := range files {
pIn := processInput{file, source, s, d.Config.extRe, d.Config.Skip, cb}
processed, processErr, cbErr := processFile(pIn)
if processErr != nil {
return 0, processErr
}
if cbErr != nil && stopOnError {
return 0, cbErr
}
if errors.Is(processErr, ErrSkipped) || (!processed && processErr == nil && cbErr == nil) {
continue
}
if cbErr == nil && processed {
count++
}
if cbErr != nil {
err = cbErr
}
return
}
return
}
func WalkFiles(d *Data, stopOnError bool, gp GroupPrinter, cb ShowWalker) (err error) {
err = ensureExtRe(d.Config)
if err != nil {
@ -98,9 +127,6 @@ func WalkFiles(d *Data, stopOnError bool, gp GroupPrinter, cb ShowWalker) (err e
return err
}
var files []os.DirEntry
var filesErr error
if err != nil {
return
}
@ -108,35 +134,13 @@ func WalkFiles(d *Data, stopOnError bool, gp GroupPrinter, cb ShowWalker) (err e
if len(s.Sources) == 0 {
s.Sources = []string{d.Config.Source}
}
showstart:
for _, source := range s.Sources {
files, filesErr = allFiles.Get(source)
if filesErr != nil {
return filesErr
}
for _, file := range files {
pIn := processInput{file, source, s, d.Config.extRe, d.Config.Skip, cb}
processed, processErr, cbErr := processFile(pIn)
if !processed && processErr == nil && cbErr == nil {
continue
}
if errors.Is(processErr, ErrSkipped) {
continue
}
if processErr != nil {
return processErr
}
if cbErr != nil && stopOnError {
return cbErr
}
if cbErr == nil && processed {
count++
}
if cbErr != nil {
err = cbErr
}
break showstart
var c int
c, err = processSource(allFiles, d, s, source, stopOnError, cb)
if err != nil {
break
}
count += c
}
}
if err == nil && count < 1 {
@ -157,8 +161,9 @@ func GetShow(ctx context.Context) ShowWalker {
return GetShowWithIO(ctx, os.Stdin, os.Stdout, os.Stderr)
}
func GetShowWithIO(ctx context.Context, stdin io.Reader, stdout io.Writer, stderr io.Writer) ShowWalker {
func GetShowWithIO(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) ShowWalker {
return func(s *Show, path string) error {
//nolint:gosec // I don't care if this is using user input
cmd := exec.CommandContext(ctx, "get-shows", s.Folder, path)
cmd.Stdin = stdin
cmd.Stdout = stdout