Skip to content

Commit

Permalink
fix: use coreAnalyzer if there are no filters selected and no active_…
Browse files Browse the repository at this point in the history
…filters (#432)

Signed-off-by: Matthis Holleville <matthish29@gmail.com>
  • Loading branch information
matthisholleville committed May 17, 2023
1 parent 940a50e commit f0d3f36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/analysis/analysis.go
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
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
}

0 comments on commit f0d3f36

Please sign in to comment.