2023-07-18 08:16:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-07-31 09:59:51 +00:00
|
|
|
noliteral "git.frostfs.info/TrueCloudLab/linters/internal/analyzers/noliteral"
|
2023-08-01 11:39:49 +00:00
|
|
|
"github.com/mitchellh/mapstructure"
|
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 {
|
|
|
|
return []*analysis.Analyzer{noliteral.LogsAnalyzer}
|
|
|
|
}
|
2023-08-01 11:39:49 +00:00
|
|
|
|
|
|
|
// for version ci-lint >= '1.5.4'.
|
|
|
|
func New(conf any) ([]*analysis.Analyzer, error) {
|
|
|
|
var config noliteral.Configuration
|
|
|
|
|
|
|
|
if confMap, ok := conf.(map[string]any); ok {
|
|
|
|
err := mapstructure.Decode(confMap, &config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
noliteral.Config.TargetMethods = append(noliteral.Config.TargetMethods, config.TargetMethods...)
|
|
|
|
}
|
|
|
|
|
|
|
|
return []*analysis.Analyzer{noliteral.LogsAnalyzer}, nil
|
|
|
|
}
|