"Replaced switch with sequential if statements"

This commit is contained in:
Seednode 2022-10-23 13:08:08 -05:00
parent ae82762745
commit 76109342ed
2 changed files with 19 additions and 48 deletions

View File

@ -95,8 +95,20 @@ func appendPaths(path string, files *Files, filters *Filters, stats *Stats) erro
filename = strings.ToLower(filename) filename = strings.ToLower(filename)
switch { if filters.HasExcludes() {
case filters.HasIncludes() && !filters.HasExcludes(): for i := 0; i < len(filters.Excludes); i++ {
if strings.Contains(
filename,
filters.Excludes[i],
) {
stats.IncrementFilesSkipped()
return nil
}
}
}
if filters.HasIncludes() {
for i := 0; i < len(filters.Includes); i++ { for i := 0; i < len(filters.Includes); i++ {
if strings.Contains( if strings.Contains(
filename, filename,
@ -110,53 +122,12 @@ func appendPaths(path string, files *Files, filters *Filters, stats *Stats) erro
stats.IncrementFilesSkipped() stats.IncrementFilesSkipped()
return nil
case !filters.HasIncludes() && filters.HasExcludes():
for i := 0; i < len(filters.Excludes); i++ {
if strings.Contains(
filename,
filters.Excludes[i],
) {
stats.IncrementFilesSkipped()
return nil
}
}
appendPath(directory, path, files, stats)
return nil
case filters.HasIncludes() && filters.HasExcludes():
for i := 0; i < len(filters.Excludes); i++ {
if strings.Contains(
filename,
filters.Excludes[i],
) {
stats.IncrementFilesSkipped()
return nil
}
}
for i := 0; i < len(filters.Includes); i++ {
if strings.Contains(
filename,
filters.Includes[i],
) {
appendPath(directory, path, files, stats)
return nil
}
}
stats.IncrementFilesSkipped()
return nil
default:
appendPath(directory, path, files, stats)
return nil return nil
} }
appendPath(directory, path, files, stats)
return nil
} }
func getFirstFile(p *Path) (string, error) { func getFirstFile(p *Path) (string, error) {

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var Version = "0.17.3" var Version = "0.17.4"
func init() { func init() {
rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(versionCmd)