Skip to content

Commit 71d0a56

Browse files
authored
Merge pull request #3278 from github/henrymercer/type-fun
Use generic types for durations in status report
2 parents 320a6b6 + 04285cb commit 71d0a56

File tree

1 file changed

+14
-77
lines changed

1 file changed

+14
-77
lines changed

src/analyze.ts

Lines changed: 14 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -38,89 +38,26 @@ export class CodeQLAnalysisError extends Error {
3838
}
3939
}
4040

41-
export interface QueriesStatusReport {
42-
/**
43-
* Time taken in ms to run queries for actions (or undefined if this language was not analyzed).
44-
*
45-
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
46-
* taken to run _all_ the queries.
47-
*/
48-
analyze_builtin_queries_actions_duration_ms?: number;
49-
/**
50-
* Time taken in ms to run queries for cpp (or undefined if this language was not analyzed).
51-
*
52-
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
53-
* taken to run _all_ the queries.
54-
*/
55-
analyze_builtin_queries_cpp_duration_ms?: number;
56-
/**
57-
* Time taken in ms to run queries for csharp (or undefined if this language was not analyzed).
58-
*
59-
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
60-
* taken to run _all_ the queries.
61-
*/
62-
analyze_builtin_queries_csharp_duration_ms?: number;
63-
/**
64-
* Time taken in ms to run queries for go (or undefined if this language was not analyzed).
65-
*
66-
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
67-
* taken to run _all_ the queries.
68-
*/
69-
analyze_builtin_queries_go_duration_ms?: number;
70-
/**
71-
* Time taken in ms to run queries for java (or undefined if this language was not analyzed).
72-
*
73-
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
74-
* taken to run _all_ the queries.
75-
*/
76-
analyze_builtin_queries_java_duration_ms?: number;
77-
/**
78-
* Time taken in ms to run queries for javascript (or undefined if this language was not analyzed).
79-
*
80-
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
81-
* taken to run _all_ the queries.
82-
*/
83-
analyze_builtin_queries_javascript_duration_ms?: number;
84-
/**
85-
* Time taken in ms to run queries for python (or undefined if this language was not analyzed).
86-
*
87-
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
88-
* taken to run _all_ the queries.
89-
*/
90-
analyze_builtin_queries_python_duration_ms?: number;
41+
type KnownLanguageKey = keyof typeof KnownLanguage;
42+
43+
type RunQueriesDurationStatusReport = {
9144
/**
92-
* Time taken in ms to run queries for ruby (or undefined if this language was not analyzed).
45+
* Time taken in ms to run queries for the language (or undefined if this language was not analyzed).
9346
*
9447
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
9548
* taken to run _all_ the queries.
9649
*/
97-
analyze_builtin_queries_ruby_duration_ms?: number;
98-
/** Time taken in ms to run queries for swift (or undefined if this language was not analyzed).
99-
*
100-
* The "builtin" designation is now outdated with the move to CLI config parsing: this is the time
101-
* taken to run _all_ the queries.
102-
*/
103-
analyze_builtin_queries_swift_duration_ms?: number;
104-
105-
/** Time taken in ms to interpret results for actions (or undefined if this language was not analyzed). */
106-
interpret_results_actions_duration_ms?: number;
107-
/** Time taken in ms to interpret results for cpp (or undefined if this language was not analyzed). */
108-
interpret_results_cpp_duration_ms?: number;
109-
/** Time taken in ms to interpret results for csharp (or undefined if this language was not analyzed). */
110-
interpret_results_csharp_duration_ms?: number;
111-
/** Time taken in ms to interpret results for go (or undefined if this language was not analyzed). */
112-
interpret_results_go_duration_ms?: number;
113-
/** Time taken in ms to interpret results for java (or undefined if this language was not analyzed). */
114-
interpret_results_java_duration_ms?: number;
115-
/** Time taken in ms to interpret results for javascript (or undefined if this language was not analyzed). */
116-
interpret_results_javascript_duration_ms?: number;
117-
/** Time taken in ms to interpret results for python (or undefined if this language was not analyzed). */
118-
interpret_results_python_duration_ms?: number;
119-
/** Time taken in ms to interpret results for ruby (or undefined if this language was not analyzed). */
120-
interpret_results_ruby_duration_ms?: number;
121-
/** Time taken in ms to interpret results for swift (or undefined if this language was not analyzed). */
122-
interpret_results_swift_duration_ms?: number;
50+
[L in KnownLanguageKey as `analyze_builtin_queries_${L}_duration_ms`]?: number;
51+
};
52+
53+
type InterpretResultsDurationStatusReport = {
54+
/** Time taken in ms to interpret results for the language (or undefined if this language was not analyzed). */
55+
[L in KnownLanguageKey as `interpret_results_${L}_duration_ms`]?: number;
56+
};
12357

58+
export interface QueriesStatusReport
59+
extends RunQueriesDurationStatusReport,
60+
InterpretResultsDurationStatusReport {
12461
/**
12562
* Whether the analysis is diff-informed (in the sense that the action generates a diff-range data
12663
* extension for the analysis, regardless of whether the data extension is actually used by queries).

0 commit comments

Comments
 (0)