linters/main.go
Alexander Chuprov a2983f6cb8 [#10] linters: Add useStrconv linter
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2023-08-17 16:24:21 +03:00

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
}