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