-
Notifications
You must be signed in to change notification settings - Fork 0
/
nolint_test.go
38 lines (34 loc) · 879 Bytes
/
nolint_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package nolint_test
import (
"testing"
"github.com/gqlgo/gqlanalysis"
"github.com/gqlgo/gqlanalysis/analysistest"
"github.com/gqlgo/nolint"
"github.com/vektah/gqlparser/v2/ast"
)
// TestAnalyzer is a test for Analyzer.
func TestAnalyzer(t *testing.T) {
testdata := analysistest.TestData(t)
a := &gqlanalysis.Analyzer{
Name: "nolint-test",
Doc: "nolint-test",
Requires: []*gqlanalysis.Analyzer{
nolint.Analyzer,
},
Run: func(pass *gqlanalysis.Pass) (interface{}, error) {
pass.Report = pass.ResultOf[nolint.Analyzer].(*nolint.Reporters).New(pass)
for _, q := range pass.Queries {
for _, f := range q.Fragments {
for _, s := range f.SelectionSet {
field, _ := s.(*ast.Field)
if field != nil {
pass.Reportf(field.Position, "NG")
}
}
}
}
return nil, nil
},
}
analysistest.Run(t, testdata, a, "a")
}