@@ -664,13 +664,6 @@ export async function runQueries(
664664
665665 for ( const language of config . languages ) {
666666 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-
674667 // This should be empty to run only the query suite that was generated when
675668 // the database was initialised.
676669 const queries : string [ ] = [ ] ;
@@ -705,55 +698,33 @@ export async function runQueries(
705698
706699 // There is always at least one analysis kind enabled. Running `interpret-results`
707700 // 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-
719701 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+ ) ;
727709
728710 // 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
730712 // `interpret-results` will have produced a SARIF file for Code Scanning and we now
731713 // need to produce an additional SARIF file for Code Quality.
732714 let qualityAnalysisSummary : string | undefined ;
733715 if (
734716 config . analysisKinds . length > 1 &&
735717 configUtils . isCodeQualityEnabled ( config )
736718 ) {
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 ,
749721 language ,
750722 analyses . codeQualityQueries . map ( ( i ) =>
751723 resolveQuerySuiteAlias ( language , i ) ,
752724 ) ,
753- qualitySarifFile ,
754725 config . debugMode ,
755- qualityCategory ,
756726 ) ;
727+ qualityAnalysisSummary = qualityResult . summary ;
757728 }
758729 const endTimeInterpretResults = new Date ( ) ;
759730 statusReport [ `interpret_results_${ language } _duration_ms` ] =
@@ -798,6 +769,37 @@ export async function runQueries(
798769
799770 return statusReport ;
800771
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+
801803 async function runInterpretResults (
802804 language : Language ,
803805 queries : string [ ] | undefined ,
0 commit comments