-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
ginkgolinter.go
39 lines (33 loc) · 1.39 KB
/
ginkgolinter.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
39
package ginkgolinter
import (
"github.com/nunnatsa/ginkgolinter"
"github.com/nunnatsa/ginkgolinter/types"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
func New(settings *config.GinkgoLinterSettings) *goanalysis.Linter {
cfg := &types.Config{}
if settings != nil {
cfg = &types.Config{
SuppressLen: types.Boolean(settings.SuppressLenAssertion),
SuppressNil: types.Boolean(settings.SuppressNilAssertion),
SuppressErr: types.Boolean(settings.SuppressErrAssertion),
SuppressCompare: types.Boolean(settings.SuppressCompareAssertion),
SuppressAsync: types.Boolean(settings.SuppressAsyncAssertion),
ForbidFocus: types.Boolean(settings.ForbidFocusContainer),
SuppressTypeCompare: types.Boolean(settings.SuppressTypeCompareWarning),
AllowHaveLen0: types.Boolean(settings.AllowHaveLenZero),
ForceExpectTo: types.Boolean(settings.ForceExpectTo),
ValidateAsyncIntervals: types.Boolean(settings.ForbidSpecPollution),
ForbidSpecPollution: types.Boolean(settings.ValidateAsyncIntervals),
}
}
a := ginkgolinter.NewAnalyzerWithConfig(cfg)
return goanalysis.NewLinter(
a.Name,
"enforces standards of using ginkgo and gomega",
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}