@@ -659,7 +659,11 @@ export async function runQueries(
659659
660660 for ( const language of config . languages ) {
661661 try {
662- const sarifFile = path . join ( sarifFolder , `${ language } .sarif` ) ;
662+ // If Code Scanning is enabled, then the main SARIF file is always the Code Scanning one.
663+ // Otherwise, only Code Quality is enabled, and the main SARIF file is the Code Quality one.
664+ const sarifFile = configUtils . isCodeScanningEnabled ( config )
665+ ? path . join ( sarifFolder , `${ language } .sarif` )
666+ : path . join ( sarifFolder , `${ language } .quality.sarif` ) ;
663667
664668 // This should be empty to run only the query suite that was generated when
665669 // the database was initialised.
@@ -695,18 +699,43 @@ export async function runQueries(
695699 statusReport [ `analyze_builtin_queries_${ language } _duration_ms` ] =
696700 new Date ( ) . getTime ( ) - startTimeRunQueries ;
697701
698- logger . startGroup ( `Interpreting results for ${ language } ` ) ;
699702 const startTimeInterpretResults = new Date ( ) ;
700- const analysisSummary = await runInterpretResults (
701- language ,
702- undefined ,
703- sarifFile ,
704- config . debugMode ,
705- automationDetailsId ,
706- ) ;
707703
704+ // If only one analysis kind is enabled, then the database is initialised for the
705+ // respective set of queries. Therefore, running `interpret-results` produces the
706+ // SARIF file we want for the one enabled analysis kind.
707+ let analysisSummary : string | undefined ;
708+ if (
709+ configUtils . isCodeScanningEnabled ( config ) ||
710+ configUtils . isCodeQualityEnabled ( config )
711+ ) {
712+ logger . startGroup ( `Interpreting results for ${ language } ` ) ;
713+
714+ // If this is a Code Quality analysis, correct the category to one
715+ // accepted by the Code Quality backend.
716+ let category = automationDetailsId ;
717+ if ( configUtils . isCodeQualityEnabled ( config ) ) {
718+ category = fixCodeQualityCategory ( logger , automationDetailsId ) ;
719+ }
720+
721+ analysisSummary = await runInterpretResults (
722+ language ,
723+ undefined ,
724+ sarifFile ,
725+ config . debugMode ,
726+ category ,
727+ ) ;
728+ }
729+
730+ // This case is only needed if Code Quality is enabled in addition to Code Scanning.
731+ // In this case, we will have run queries for both analysis kinds. The previous call to
732+ // `interpret-results` will have produced a SARIF file for Code Scanning and we now
733+ // need to produce an additional SARIF file for Code Quality.
708734 let qualityAnalysisSummary : string | undefined ;
709- if ( configUtils . isCodeQualityEnabled ( config ) ) {
735+ if (
736+ configUtils . isCodeQualityEnabled ( config ) &&
737+ configUtils . isCodeScanningEnabled ( config )
738+ ) {
710739 logger . info ( `Interpreting quality results for ${ language } ` ) ;
711740 const qualityCategory = fixCodeQualityCategory (
712741 logger ,
@@ -730,8 +759,10 @@ export async function runQueries(
730759 statusReport [ `interpret_results_${ language } _duration_ms` ] =
731760 endTimeInterpretResults . getTime ( ) - startTimeInterpretResults . getTime ( ) ;
732761 logger . endGroup ( ) ;
733- logger . info ( analysisSummary ) ;
734762
763+ if ( analysisSummary ) {
764+ logger . info ( analysisSummary ) ;
765+ }
735766 if ( qualityAnalysisSummary ) {
736767 logger . info ( qualityAnalysisSummary ) ;
737768 }
0 commit comments