forked from golangci/golangci-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrchkjson.go
33 lines (28 loc) · 918 Bytes
/
errchkjson.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
package golinters
import (
"github.com/breml/errchkjson"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
)
func NewErrChkJSONFuncName(cfg *config.ErrChkJSONSettings) *goanalysis.Linter {
a := errchkjson.NewAnalyzer()
cfgMap := map[string]map[string]interface{}{}
cfgMap[a.Name] = map[string]interface{}{
"omit-safe": true,
}
if cfg != nil {
cfgMap[a.Name] = map[string]interface{}{
"omit-safe": !cfg.CheckErrorFreeEncoding,
"report-no-exported": cfg.ReportNoExported,
}
}
return goanalysis.NewLinter(
"errchkjson",
"Checks types passed to the json encoding functions. "+
"Reports unsupported types and optionally reports occations, "+
"where the check for the returned error can be omitted.",
[]*analysis.Analyzer{a},
cfgMap,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}