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 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, "*") leadingStar := strings.HasPrefix(pattern, "*")
trailingStar := strings.HasSuffix(pattern, "*") trailingStar := strings.HasSuffix(pattern, "*")
exact := strings.HasPrefix(pattern, "=") exact := strings.HasPrefix(pattern, "=")
@ -60,24 +60,24 @@ func (patternMatcher *PatternMatcher) Add(pattern string, val interface{}, posit
patternType = PatternTypePattern patternType = PatternTypePattern
_, err := filepath.Match(pattern, "example.com") _, err := filepath.Match(pattern, "example.com")
if len(pattern) < 2 || err != nil { 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 { } else if leadingStar && trailingStar {
patternType = PatternTypeSubstring patternType = PatternTypeSubstring
if len(pattern) < 3 { 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] pattern = pattern[1 : len(pattern)-1]
} else if trailingStar { } else if trailingStar {
patternType = PatternTypePrefix patternType = PatternTypePrefix
if len(pattern) < 2 { 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] pattern = pattern[:len(pattern)-1]
} else if exact { } else if exact {
patternType = PatternTypeExact patternType = PatternTypeExact
if len(pattern) < 2 { 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:] pattern = pattern[1:]
} else { } else {
@ -112,7 +112,7 @@ func (patternMatcher *PatternMatcher) Add(pattern string, val interface{}, posit
default: default:
dlog.Fatal("Unexpected block type") dlog.Fatal("Unexpected block type")
} }
return patternType, nil return nil
} }
func (patternMatcher *PatternMatcher) Eval(qName string) (reject bool, reason string, val interface{}) { 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 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) dlog.Error(err)
continue continue
} }

View File

@ -59,7 +59,7 @@ func (plugin *PluginWhitelistName) Init(proxy *Proxy) error {
weeklyRanges = &weeklyRangesX 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) dlog.Error(err)
continue continue
} }