@@ -664,13 +664,6 @@ export async function runQueries(
664
664
665
665
for ( const language of config . languages ) {
666
666
try {
667
- // If Code Scanning is enabled, then the main SARIF file is always the Code Scanning one.
668
- // Otherwise, only Code Quality is enabled, and the main SARIF file is the Code Quality one.
669
- const sarifFile = path . join (
670
- sarifFolder ,
671
- addSarifExtension ( dbAnalysisConfig , language ) ,
672
- ) ;
673
-
674
667
// This should be empty to run only the query suite that was generated when
675
668
// the database was initialised.
676
669
const queries : string [ ] = [ ] ;
@@ -705,55 +698,33 @@ export async function runQueries(
705
698
706
699
// There is always at least one analysis kind enabled. Running `interpret-results`
707
700
// produces the SARIF file for the analysis kind that the database was initialised with.
708
- logger . startGroup (
709
- `Interpreting ${ dbAnalysisConfig . name } results for ${ language } ` ,
710
- ) ;
711
-
712
- // If this is a Code Quality analysis, correct the category to one
713
- // accepted by the Code Quality backend.
714
- let category = automationDetailsId ;
715
- if ( dbAnalysisConfig . kind === analyses . AnalysisKind . CodeQuality ) {
716
- category = fixCodeQualityCategory ( logger , automationDetailsId ) ;
717
- }
718
-
719
701
const startTimeInterpretResults = new Date ( ) ;
720
- const analysisSummary = await runInterpretResults (
721
- language ,
722
- undefined ,
723
- sarifFile ,
724
- config . debugMode ,
725
- category ,
726
- ) ;
702
+ const { summary : analysisSummary , sarifFile } =
703
+ await runInterpretResultsFor (
704
+ dbAnalysisConfig ,
705
+ language ,
706
+ undefined ,
707
+ config . debugMode ,
708
+ ) ;
727
709
728
710
// This case is only needed if Code Quality is not the sole analysis kind.
729
- // In this case, we will have run queries for both analysis kinds. The previous call to
711
+ // In this case, we will have run queries for all analysis kinds. The previous call to
730
712
// `interpret-results` will have produced a SARIF file for Code Scanning and we now
731
713
// need to produce an additional SARIF file for Code Quality.
732
714
let qualityAnalysisSummary : string | undefined ;
733
715
if (
734
716
config . analysisKinds . length > 1 &&
735
717
configUtils . isCodeQualityEnabled ( config )
736
718
) {
737
- logger . info (
738
- `Interpreting ${ analyses . CodeQuality . name } results for ${ language } ` ,
739
- ) ;
740
- const qualityCategory = fixCodeQualityCategory (
741
- logger ,
742
- automationDetailsId ,
743
- ) ;
744
- const qualitySarifFile = path . join (
745
- sarifFolder ,
746
- addSarifExtension ( analyses . CodeQuality , language ) ,
747
- ) ;
748
- qualityAnalysisSummary = await runInterpretResults (
719
+ const qualityResult = await runInterpretResultsFor (
720
+ analyses . CodeQuality ,
749
721
language ,
750
722
analyses . codeQualityQueries . map ( ( i ) =>
751
723
resolveQuerySuiteAlias ( language , i ) ,
752
724
) ,
753
- qualitySarifFile ,
754
725
config . debugMode ,
755
- qualityCategory ,
756
726
) ;
727
+ qualityAnalysisSummary = qualityResult . summary ;
757
728
}
758
729
const endTimeInterpretResults = new Date ( ) ;
759
730
statusReport [ `interpret_results_${ language } _duration_ms` ] =
@@ -798,6 +769,37 @@ export async function runQueries(
798
769
799
770
return statusReport ;
800
771
772
+ async function runInterpretResultsFor (
773
+ analysis : analyses . AnalysisConfig ,
774
+ language : Language ,
775
+ queries : string [ ] | undefined ,
776
+ enableDebugLogging : boolean ,
777
+ ) : Promise < { summary : string ; sarifFile : string } > {
778
+ logger . info ( `Interpreting ${ analysis . name } results for ${ language } ` ) ;
779
+
780
+ // If this is a Code Quality analysis, correct the category to one
781
+ // accepted by the Code Quality backend.
782
+ let category = automationDetailsId ;
783
+ if ( dbAnalysisConfig . kind === analyses . AnalysisKind . CodeQuality ) {
784
+ category = fixCodeQualityCategory ( logger , automationDetailsId ) ;
785
+ }
786
+
787
+ const sarifFile = path . join (
788
+ sarifFolder ,
789
+ addSarifExtension ( analysis , language ) ,
790
+ ) ;
791
+
792
+ const summary = await runInterpretResults (
793
+ language ,
794
+ queries ,
795
+ sarifFile ,
796
+ enableDebugLogging ,
797
+ category ,
798
+ ) ;
799
+
800
+ return { summary, sarifFile } ;
801
+ }
802
+
801
803
async function runInterpretResults (
802
804
language : Language ,
803
805
queries : string [ ] | undefined ,
0 commit comments