forked from TrueCloudLab/linters
39 lines
922 B
Go
39 lines
922 B
Go
package main
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/linters/internal/analyzers/noliteral"
|
|
useStrconv "git.frostfs.info/TrueCloudLab/linters/internal/analyzers/use-strconv"
|
|
"golang.org/x/tools/go/analysis"
|
|
)
|
|
|
|
var AnalyzerPlugin analyzerPlugin
|
|
|
|
type analyzerPlugin struct{}
|
|
|
|
// for version ci-lint < '1.5.4'.
|
|
func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {
|
|
analyzer, _ := New(nil)
|
|
return analyzer
|
|
}
|
|
|
|
// 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
|
|
}
|