remove unused patternType return

This commit is contained in:
Alison Winters 2019-11-01 23:27:53 +08:00 committed by Frank Denis
parent a0d9412a25
commit 36808cdec7
3 changed files with 8 additions and 8 deletions

View File

@ -51,7 +51,7 @@ func isGlobCandidate(str string) bool {
return false
}
func (patternMatcher *PatternMatcher) Add(pattern string, val interface{}, position int) (PatternType, error) {
func (patternMatcher *PatternMatcher) Add(pattern string, val interface{}, position int) error {
leadingStar := strings.HasPrefix(pattern, "*")
trailingStar := strings.HasSuffix(pattern, "*")
exact := strings.HasPrefix(pattern, "=")
@ -60,24 +60,24 @@ func (patternMatcher *PatternMatcher) Add(pattern string, val interface{}, posit
patternType = PatternTypePattern
_, err := filepath.Match(pattern, "example.com")
if len(pattern) < 2 || err != nil {
return patternType, fmt.Errorf("Syntax error in block rules at pattern %d", position)
return fmt.Errorf("Syntax error in block rules at pattern %d", position)
}
} else if leadingStar && trailingStar {
patternType = PatternTypeSubstring
if len(pattern) < 3 {
return patternType, fmt.Errorf("Syntax error in block rules at pattern %d", position)
return fmt.Errorf("Syntax error in block rules at pattern %d", position)
}
pattern = pattern[1 : len(pattern)-1]
} else if trailingStar {
patternType = PatternTypePrefix
if len(pattern) < 2 {
return patternType, fmt.Errorf("Syntax error in block rules at pattern %d", position)
return fmt.Errorf("Syntax error in block rules at pattern %d", position)
}
pattern = pattern[:len(pattern)-1]
} else if exact {
patternType = PatternTypeExact
if len(pattern) < 2 {
return patternType, fmt.Errorf("Syntax error in block rules at pattern %d", position)
return fmt.Errorf("Syntax error in block rules at pattern %d", position)
}
pattern = pattern[1:]
} else {
@ -112,7 +112,7 @@ func (patternMatcher *PatternMatcher) Add(pattern string, val interface{}, posit
default:
dlog.Fatal("Unexpected block type")
}
return patternType, nil
return nil
}
func (patternMatcher *PatternMatcher) Eval(qName string) (reject bool, reason string, val interface{}) {

View File

@ -59,7 +59,7 @@ func (plugin *PluginBlockName) Init(proxy *Proxy) error {
weeklyRanges = &weeklyRangesX
}
}
if _, err := plugin.patternMatcher.Add(line, weeklyRanges, lineNo+1); err != nil {
if err := plugin.patternMatcher.Add(line, weeklyRanges, lineNo+1); err != nil {
dlog.Error(err)
continue
}

View File

@ -59,7 +59,7 @@ func (plugin *PluginWhitelistName) Init(proxy *Proxy) error {
weeklyRanges = &weeklyRangesX
}
}
if _, err := plugin.patternMatcher.Add(line, weeklyRanges, lineNo+1); err != nil {
if err := plugin.patternMatcher.Add(line, weeklyRanges, lineNo+1); err != nil {
dlog.Error(err)
continue
}