summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2020-06-18 09:02:14 -0700
committergVisor bot <gvisor-bot@google.com>2020-06-18 09:03:39 -0700
commit3970c127434817304f67a2ad192cbe8094ad3353 (patch)
tree4552afc303c62603662edce735a3b31eae260a3d /tools
parent07ff909e76d8233827e705476ec116fc2cecec2f (diff)
Remove various uses of 'whitelist'
Updates #2972 PiperOrigin-RevId: 317113059
Diffstat (limited to 'tools')
-rw-r--r--tools/nogo/matchers.go27
1 files changed, 16 insertions, 11 deletions
diff --git a/tools/nogo/matchers.go b/tools/nogo/matchers.go
index 32f099925..57a250501 100644
--- a/tools/nogo/matchers.go
+++ b/tools/nogo/matchers.go
@@ -27,10 +27,15 @@ type matcher interface {
ShouldReport(d analysis.Diagnostic, fs *token.FileSet) bool
}
-// pathRegexps excludes explicit paths.
+// pathRegexps filters explicit paths.
type pathRegexps struct {
- expr []*regexp.Regexp
- whitelist bool
+ expr []*regexp.Regexp
+
+ // include, if true, indicates that paths matching any regexp in expr
+ // match.
+ //
+ // If false, paths matching no regexps in expr match.
+ include bool
}
// buildRegexps builds a list of regular expressions.
@@ -49,33 +54,33 @@ func (p *pathRegexps) ShouldReport(d analysis.Diagnostic, fs *token.FileSet) boo
fullPos := fs.Position(d.Pos).String()
for _, path := range p.expr {
if path.MatchString(fullPos) {
- return p.whitelist
+ return p.include
}
}
- return !p.whitelist
+ return !p.include
}
// internalExcluded excludes specific internal paths.
func internalExcluded(paths ...string) *pathRegexps {
return &pathRegexps{
- expr: buildRegexps(internalPrefix, paths...),
- whitelist: false,
+ expr: buildRegexps(internalPrefix, paths...),
+ include: false,
}
}
// excludedExcluded excludes specific external paths.
func externalExcluded(paths ...string) *pathRegexps {
return &pathRegexps{
- expr: buildRegexps(externalPrefix, paths...),
- whitelist: false,
+ expr: buildRegexps(externalPrefix, paths...),
+ include: false,
}
}
// internalMatches returns a path matcher for internal packages.
func internalMatches() *pathRegexps {
return &pathRegexps{
- expr: buildRegexps(internalPrefix, ".*"),
- whitelist: true,
+ expr: buildRegexps(internalPrefix, ".*"),
+ include: true,
}
}