summaryrefslogtreecommitdiffhomepage
path: root/tools/nogo/matchers.go
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-10-07 18:27:00 -0700
committergVisor bot <gvisor-bot@google.com>2020-10-07 18:29:05 -0700
commita55bd73d4802112a7055de8663e947b9c0f42a2e (patch)
tree712b84a6b5a2e255fb8898611a2f2bfbee1b015e /tools/nogo/matchers.go
parentfcddfb0a715f8f738463cad137895728224668ba (diff)
Add staticcheck and staticstyle analyzers.
This change also adds support to go_stateify for detecting an appropriate receiver name, avoiding a large number of false positives. PiperOrigin-RevId: 335994587
Diffstat (limited to 'tools/nogo/matchers.go')
-rw-r--r--tools/nogo/matchers.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/tools/nogo/matchers.go b/tools/nogo/matchers.go
index 5c39be630..b7b73fa27 100644
--- a/tools/nogo/matchers.go
+++ b/tools/nogo/matchers.go
@@ -102,6 +102,14 @@ func internalMatches() *pathRegexps {
}
}
+// generatedExcluded excludes all generated code.
+func generatedExcluded() *pathRegexps {
+ return &pathRegexps{
+ expr: buildRegexps(generatedPrefix, ".*"),
+ include: false,
+ }
+}
+
// resultExcluded excludes explicit message contents.
type resultExcluded []string
@@ -117,20 +125,23 @@ func (r resultExcluded) ShouldReport(d analysis.Diagnostic, _ *token.FileSet) bo
// andMatcher is a composite matcher.
type andMatcher struct {
- first matcher
- second matcher
+ all []matcher
}
// ShouldReport implements matcher.ShouldReport.
func (a *andMatcher) ShouldReport(d analysis.Diagnostic, fs *token.FileSet) bool {
- return a.first.ShouldReport(d, fs) && a.second.ShouldReport(d, fs)
+ for _, m := range a.all {
+ if !m.ShouldReport(d, fs) {
+ return false
+ }
+ }
+ return true
}
// and is a syntactic convension for andMatcher.
-func and(first matcher, second matcher) *andMatcher {
+func and(ms ...matcher) *andMatcher {
return &andMatcher{
- first: first,
- second: second,
+ all: ms,
}
}