Merge "Simple refactoring of prefix related functions." am: 36b6aec26a am: 9bc4a38707 am: 7f2487d5cc

Change-Id: Ia383f411632524fa2fb3fb238f754900564172c7
This commit is contained in:
Jaewoong Jung
2020-02-18 15:48:38 +00:00
12 changed files with 29 additions and 107 deletions

View File

@@ -416,8 +416,8 @@ func (r *rule) String() string {
}
func (r *rule) appliesToPath(dir string) bool {
includePath := len(r.paths) == 0 || hasAnyPrefix(dir, r.paths)
excludePath := hasAnyPrefix(dir, r.unlessPaths)
includePath := len(r.paths) == 0 || HasAnyPrefix(dir, r.paths)
excludePath := HasAnyPrefix(dir, r.unlessPaths)
return includePath && !excludePath
}
@@ -483,15 +483,6 @@ func fieldNamesForProperties(propertyNames string) []string {
return names
}
func hasAnyPrefix(s string, prefixes []string) bool {
for _, prefix := range prefixes {
if strings.HasPrefix(s, prefix) {
return true
}
}
return false
}
func hasAnyProperty(properties []interface{}, props []ruleProperty) bool {
for _, v := range props {
if hasProperty(properties, v) {