From aa8f8b160214d8dfccfe3e17e578dd0fcc6fede7 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Mon, 9 Feb 2015 09:17:26 +1100 Subject: [PATCH] Don't recurse into directories. --- gocyclo.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gocyclo.go b/gocyclo.go index 6ab1ef6..d22b94d 100644 --- a/gocyclo.go +++ b/gocyclo.go @@ -28,7 +28,6 @@ import ( "os" "path/filepath" "sort" - "strings" ) const usageDoc = `Calculate cyclomatic complexities of Go functions. @@ -105,12 +104,10 @@ func analyzeFile(fname string, stats []stat) []stat { } func analyzeDir(dirname string, stats []stat) []stat { - filepath.Walk(dirname, func(path string, info os.FileInfo, err error) error { - if err == nil && !info.IsDir() && strings.HasSuffix(path, ".go") { - stats = analyzeFile(path, stats) - } - return err - }) + files, _ := filepath.Glob(filepath.Join(dirname, "*.go")) + for _, file := range files { + stats = analyzeFile(file, stats) + } return stats }