linters/main.go

40 lines
922 B
Go
Raw Normal View History

2023-07-18 08:16:27 +00:00
package main
import (
"git.frostfs.info/TrueCloudLab/linters/internal/analyzers/noliteral"
useStrconv "git.frostfs.info/TrueCloudLab/linters/internal/analyzers/use-strconv"
2023-07-18 08:16:27 +00:00
"golang.org/x/tools/go/analysis"
)
var AnalyzerPlugin analyzerPlugin
type analyzerPlugin struct{}
// for version ci-lint < '1.5.4'.
2023-07-18 08:16:27 +00:00
func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {
analyzer, _ := New(nil)
return analyzer
2023-07-18 08:16:27 +00:00
}
// for version ci-lint >= '1.5.4'.
func New(conf any) ([]*analysis.Analyzer, error) {
confMap, ok := conf.(map[string]any)
var noliteralConfig, useStrconvConfig any
if ok {
noliteralConfig = confMap["noliteral"]
useStrconvConfig = confMap["useStrconv"]
}
noliteral, err := noliteral.New(noliteralConfig)
if err != nil {
return nil, err
}
useStrconv, err := useStrconv.New(useStrconvConfig)
if err != nil {
return nil, err
}
return []*analysis.Analyzer{noliteral, useStrconv}, nil
}