add omit test files and only frontend
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// internal/filter/filter.go
|
||||
package filter
|
||||
|
||||
import (
|
||||
@@ -10,6 +11,7 @@ type Filter struct {
|
||||
MaxSize int64
|
||||
Extensions []string
|
||||
Ignores []string
|
||||
OmitTest bool
|
||||
}
|
||||
|
||||
func (f *Filter) ShouldSkipDir(name string) bool {
|
||||
@@ -48,6 +50,28 @@ func (f *Filter) ShouldSkipFile(path, name string, info os.FileInfo) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if f.OmitTest && isTestFile(path, name) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func isTestFile(path, name string) bool {
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
|
||||
switch ext {
|
||||
case ".go":
|
||||
return strings.HasSuffix(strings.ToLower(name), "_test.go")
|
||||
case ".java":
|
||||
base := strings.TrimSuffix(name, filepath.Ext(name))
|
||||
if strings.HasSuffix(base, "Test") || strings.HasSuffix(base, "Tests") {
|
||||
return true
|
||||
}
|
||||
slashPath := filepath.ToSlash(path)
|
||||
return strings.Contains(slashPath, "/src/test/")
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user