Analyze: Log analysis summaries for custom queries
This commit is contained in:
parent
2ccefaccfe
commit
2338fe5db5
3 changed files with 49 additions and 15 deletions
29
lib/analyze.js
generated
29
lib/analyze.js
generated
|
|
@ -92,21 +92,23 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||
throw new Error(`Unable to analyse ${language} as no queries were selected for this language`);
|
||||
}
|
||||
try {
|
||||
let analysisSummary = "";
|
||||
let analysisSummaryBuiltIn = "";
|
||||
const customAnalysisSummaries = [];
|
||||
if (queries["builtin"].length > 0) {
|
||||
const startTimeBuliltIn = new Date().getTime();
|
||||
const startTimeBuiltIn = new Date().getTime();
|
||||
const { sarifFile, stdout } = await runQueryGroup(language, "builtin", queries["builtin"], sarifFolder, undefined);
|
||||
analysisSummary = stdout;
|
||||
analysisSummaryBuiltIn = stdout;
|
||||
await injectLinesOfCode(sarifFile, language, locPromise);
|
||||
statusReport[`analyze_builtin_queries_${language}_duration_ms`] =
|
||||
new Date().getTime() - startTimeBuliltIn;
|
||||
new Date().getTime() - startTimeBuiltIn;
|
||||
}
|
||||
const startTimeCustom = new Date().getTime();
|
||||
const temporarySarifDir = config.tempDir;
|
||||
const temporarySarifFiles = [];
|
||||
for (let i = 0; i < queries["custom"].length; ++i) {
|
||||
if (queries["custom"][i].queries.length > 0) {
|
||||
const { sarifFile } = await runQueryGroup(language, `custom-${i}`, queries["custom"][i].queries, temporarySarifDir, queries["custom"][i].searchPath);
|
||||
const { sarifFile, stdout } = await runQueryGroup(language, `custom-${i}`, queries["custom"][i].queries, temporarySarifDir, queries["custom"][i].searchPath);
|
||||
customAnalysisSummaries.push(stdout);
|
||||
temporarySarifFiles.push(sarifFile);
|
||||
}
|
||||
}
|
||||
|
|
@ -118,10 +120,23 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||
new Date().getTime() - startTimeCustom;
|
||||
}
|
||||
logger.endGroup();
|
||||
// Print the LoC baseline and the summary results from database analyze.
|
||||
// Print the LoC baseline and the summary results from database analyze for the standard
|
||||
// query suite and (if appropriate) each custom query suite.
|
||||
logger.startGroup(`Analysis summary for ${language}`);
|
||||
printLinesOfCodeSummary(logger, language, await locPromise);
|
||||
logger.info(analysisSummary);
|
||||
logger.info(analysisSummaryBuiltIn);
|
||||
for (const [i, customSummary] of customAnalysisSummaries.entries()) {
|
||||
if (customSummary.trim() === "") {
|
||||
continue;
|
||||
}
|
||||
const description = customAnalysisSummaries.length === 1
|
||||
? "custom queries"
|
||||
: `custom query suite ${i + 1}/${customAnalysisSummaries.length}`;
|
||||
logger.info(`Analysis summary for ${description}:`);
|
||||
logger.info("");
|
||||
logger.info(customSummary);
|
||||
logger.info("");
|
||||
}
|
||||
logger.endGroup();
|
||||
}
|
||||
catch (e) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -176,9 +176,10 @@ export async function runQueries(
|
|||
}
|
||||
|
||||
try {
|
||||
let analysisSummary = "";
|
||||
let analysisSummaryBuiltIn = "";
|
||||
const customAnalysisSummaries: string[] = [];
|
||||
if (queries["builtin"].length > 0) {
|
||||
const startTimeBuliltIn = new Date().getTime();
|
||||
const startTimeBuiltIn = new Date().getTime();
|
||||
const { sarifFile, stdout } = await runQueryGroup(
|
||||
language,
|
||||
"builtin",
|
||||
|
|
@ -186,24 +187,25 @@ export async function runQueries(
|
|||
sarifFolder,
|
||||
undefined
|
||||
);
|
||||
analysisSummary = stdout;
|
||||
analysisSummaryBuiltIn = stdout;
|
||||
await injectLinesOfCode(sarifFile, language, locPromise);
|
||||
|
||||
statusReport[`analyze_builtin_queries_${language}_duration_ms`] =
|
||||
new Date().getTime() - startTimeBuliltIn;
|
||||
new Date().getTime() - startTimeBuiltIn;
|
||||
}
|
||||
const startTimeCustom = new Date().getTime();
|
||||
const temporarySarifDir = config.tempDir;
|
||||
const temporarySarifFiles: string[] = [];
|
||||
for (let i = 0; i < queries["custom"].length; ++i) {
|
||||
if (queries["custom"][i].queries.length > 0) {
|
||||
const { sarifFile } = await runQueryGroup(
|
||||
const { sarifFile, stdout } = await runQueryGroup(
|
||||
language,
|
||||
`custom-${i}`,
|
||||
queries["custom"][i].queries,
|
||||
temporarySarifDir,
|
||||
queries["custom"][i].searchPath
|
||||
);
|
||||
customAnalysisSummaries.push(stdout);
|
||||
temporarySarifFiles.push(sarifFile);
|
||||
}
|
||||
}
|
||||
|
|
@ -217,10 +219,27 @@ export async function runQueries(
|
|||
}
|
||||
logger.endGroup();
|
||||
|
||||
// Print the LoC baseline and the summary results from database analyze.
|
||||
// Print the LoC baseline and the summary results from database analyze for the standard
|
||||
// query suite and (if appropriate) each custom query suite.
|
||||
logger.startGroup(`Analysis summary for ${language}`);
|
||||
|
||||
printLinesOfCodeSummary(logger, language, await locPromise);
|
||||
logger.info(analysisSummary);
|
||||
logger.info(analysisSummaryBuiltIn);
|
||||
|
||||
for (const [i, customSummary] of customAnalysisSummaries.entries()) {
|
||||
if (customSummary.trim() === "") {
|
||||
continue;
|
||||
}
|
||||
const description =
|
||||
customAnalysisSummaries.length === 1
|
||||
? "custom queries"
|
||||
: `custom query suite ${i + 1}/${customAnalysisSummaries.length}`;
|
||||
logger.info(`Analysis summary for ${description}:`);
|
||||
logger.info("");
|
||||
logger.info(customSummary);
|
||||
logger.info("");
|
||||
}
|
||||
|
||||
logger.endGroup();
|
||||
} catch (e) {
|
||||
logger.info(e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue