@@ -12,6 +12,15 @@ export enum AnalysisKind {
1212 CSRA = "csra" ,
1313}
1414
15+ export type CompatibilityMatrix = Record < AnalysisKind , Set < AnalysisKind > > ;
16+
17+ /** A mapping from analysis kinds to other analysis kinds which can be enabled concurrently. */
18+ export const compatibilityMatrix : CompatibilityMatrix = {
19+ [ AnalysisKind . CodeScanning ] : new Set ( [ AnalysisKind . CodeQuality ] ) ,
20+ [ AnalysisKind . CodeQuality ] : new Set ( [ AnalysisKind . CodeScanning ] ) ,
21+ [ AnalysisKind . CSRA ] : new Set ( ) ,
22+ } ;
23+
1524// Exported for testing. A set of all known analysis kinds.
1625export const supportedAnalysisKinds = new Set ( Object . values ( AnalysisKind ) ) ;
1726
@@ -68,7 +77,7 @@ export async function getAnalysisKinds(
6877 return cachedAnalysisKinds ;
6978 }
7079
71- cachedAnalysisKinds = await parseAnalysisKinds (
80+ const analysisKinds = await parseAnalysisKinds (
7281 getRequiredInput ( "analysis-kinds" ) ,
7382 ) ;
7483
@@ -86,12 +95,27 @@ export async function getAnalysisKinds(
8695 // if an input to `quality-queries` was specified. We should remove this once
8796 // `quality-queries` is no longer used.
8897 if (
89- ! cachedAnalysisKinds . includes ( AnalysisKind . CodeQuality ) &&
98+ ! analysisKinds . includes ( AnalysisKind . CodeQuality ) &&
9099 qualityQueriesInput !== undefined
91100 ) {
92- cachedAnalysisKinds . push ( AnalysisKind . CodeQuality ) ;
101+ analysisKinds . push ( AnalysisKind . CodeQuality ) ;
102+ }
103+
104+ // Check that all enabled analysis kinds are compatible with each other.
105+ for ( const analysisKind of analysisKinds ) {
106+ for ( const otherAnalysisKind of analysisKinds ) {
107+ if ( analysisKind === otherAnalysisKind ) continue ;
108+
109+ if ( ! compatibilityMatrix [ analysisKind ] . has ( otherAnalysisKind ) ) {
110+ throw new ConfigurationError (
111+ `${ otherAnalysisKind } cannot be enabled at the same time as ${ analysisKind } ` ,
112+ ) ;
113+ }
114+ }
93115 }
94116
117+ // Cache the analysis kinds and return them.
118+ cachedAnalysisKinds = analysisKinds ;
95119 return cachedAnalysisKinds ;
96120}
97121
0 commit comments