diff --git a/pkg/healthcheck/forbidden.go b/pkg/healthcheck/forbidden.go index f700b74..2f40d4e 100644 --- a/pkg/healthcheck/forbidden.go +++ b/pkg/healthcheck/forbidden.go @@ -54,29 +54,23 @@ func getForbiddens(root string, fileList []string, localList string) ([]string, } if info.IsDir() { - switch { - case info.Name() == ".git" || info.Name() == ".gitea" || info.Name() == "ci": + if info.Name() == ".git" || info.Name() == ".gitea" || info.Name() == "ci" || (localList != "" && inString(info.Name(), dirs)) { return filepath.SkipDir - case localList != "": - if inString(info.Name(), dirs) { - return filepath.SkipDir + } + } else { + match := false + for _, regex := range regexList { + if regex.MatchString(info.Name()) { + match = true + break } - default: - return nil + } + + if !match { + matches = append(matches, path) } } - match := false - for _, regex := range regexList { - if regex.MatchString(info.Name()) { - match = true - break - } - } - - if !match { - matches = append(matches, path) - } return nil })