@@ -808,15 +808,31 @@ func ApplyRulesToRuleSet(execution *RuleSetExecution) *RuleSetExecutionResult {
808808
809809 timeoutCtx , ruleCancel := context .WithTimeout (context .Background (), execution .Timeout )
810810 defer ruleCancel ()
811- doneChan := make (chan bool )
811+ doneChan := make (chan struct {} )
812812
813- go runRule (ctx , doneChan )
813+ localResults := []model.RuleFunctionResult {}
814+ localIgnored := []model.RuleFunctionResult {}
815+ localFixed := []model.RuleFunctionResult {}
816+ localErrs := []error {}
817+ localCtx := ctx
818+ localCtx .ruleResults = & localResults
819+ localCtx .ignoredResults = & localIgnored
820+ localCtx .fixedResults = & localFixed
821+ localCtx .errors = & localErrs
822+
823+ go runRule (localCtx , doneChan )
814824
815825 select {
816826 case <- timeoutCtx .Done ():
817827 ctx .logger .Error ("Rule timed out, skipping" , "rule" , rule .Id , "timeout" , execution .Timeout )
818828 break
819829 case <- doneChan :
830+ lock .Lock ()
831+ ruleResults = append (ruleResults , localResults ... )
832+ ignoredResults = append (ignoredResults , localIgnored ... )
833+ fixedResults = append (fixedResults , localFixed ... )
834+ errs = append (errs , localErrs ... )
835+ lock .Unlock ()
820836 break
821837 }
822838 done <- true
@@ -872,7 +888,8 @@ func ApplyRulesToRuleSet(execution *RuleSetExecution) *RuleSetExecutionResult {
872888 }
873889}
874890
875- func runRule (ctx ruleContext , doneChan chan bool ) {
891+ func runRule (ctx ruleContext , doneChan chan struct {}) {
892+ defer close (doneChan )
876893
877894 // Check for missing auto-fix functions when --fix is enabled
878895 if ctx .applyAutoFixes && ctx .rule .AutoFixFunction != "" {
@@ -971,7 +988,6 @@ func runRule(ctx ruleContext, doneChan chan bool) {
971988 lock .Lock ()
972989 * ctx .errors = append (* ctx .errors , err )
973990 lock .Unlock ()
974- doneChan <- true
975991 return
976992 }
977993 if len (nodes ) <= 0 {
@@ -999,7 +1015,6 @@ func runRule(ctx ruleContext, doneChan chan bool) {
9991015 }
10001016 }
10011017 }
1002- doneChan <- true
10031018}
10041019
10051020var lock sync.Mutex
0 commit comments