Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use coreAnalyzer if there are no filters selected and no active #432

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/analysis/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func NewAnalysis(backend string, language string, filters []string, namespace st
func (a *Analysis) RunAnalysis() {
activeFilters := viper.GetStringSlice("active_filters")

analyzerMap := analyzer.GetAnalyzerMap()
coreAnalyzerMap, analyzerMap := analyzer.GetAnalyzerMap()

analyzerConfig := common.Analyzer{
Client: a.Client,
Expand All @@ -138,11 +138,11 @@ func (a *Analysis) RunAnalysis() {
}

semaphore := make(chan struct{}, a.MaxConcurrency)
// if there are no filters selected and no active_filters then run all of them
// if there are no filters selected and no active_filters then run coreAnalyzer
if len(a.Filters) == 0 && len(activeFilters) == 0 {
var wg sync.WaitGroup
var mutex sync.Mutex
for _, analyzer := range analyzerMap {
for _, analyzer := range coreAnalyzerMap {
wg.Add(1)
semaphore <- struct{}{}
go func(analyzer common.IAnalyzer, wg *sync.WaitGroup, semaphore chan struct{}) {
Expand Down
14 changes: 8 additions & 6 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,20 @@ func ListFilters() ([]string, []string, []string) {
return coreKeys, additionalKeys, integrationAnalyzers
}

func GetAnalyzerMap() map[string]common.IAnalyzer {
func GetAnalyzerMap() (map[string]common.IAnalyzer, map[string]common.IAnalyzer) {

mergedMap := make(map[string]common.IAnalyzer)
coreAnalyzer := make(map[string]common.IAnalyzer)
mergedAnalyzerMap := make(map[string]common.IAnalyzer)

// add core analyzer
for key, value := range coreAnalyzerMap {
mergedMap[key] = value
coreAnalyzer[key] = value
mergedAnalyzerMap[key] = value
}

// add additional analyzer
for key, value := range additionalAnalyzerMap {
mergedMap[key] = value
mergedAnalyzerMap[key] = value
}

integrationProvider := integration.NewIntegration()
Expand All @@ -106,9 +108,9 @@ func GetAnalyzerMap() map[string]common.IAnalyzer {
fmt.Println(color.RedString(err.Error()))
os.Exit(1)
}
in.AddAnalyzer(&mergedMap)
in.AddAnalyzer(&mergedAnalyzerMap)
}
}

return mergedMap
return coreAnalyzer, mergedAnalyzerMap
}