Skip to content

Commit d814adc

Browse files
committed
Refactor
1 parent 1d30cf4 commit d814adc

File tree

2 files changed

+26
-55
lines changed

2 files changed

+26
-55
lines changed

extensions/ql-vscode/src/codeql-cli/cli.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ export class CodeQLCliServer implements Disposable {
12791279
return { uniquePath1, uniquePath2, cleanup };
12801280
}
12811281

1282-
async runInterpretCommand(
1282+
private async runInterpretCommand(
12831283
format: string,
12841284
additonalArgs: string[],
12851285
metadata: QueryMetadata,
@@ -1294,21 +1294,22 @@ export class CodeQLCliServer implements Disposable {
12941294
format,
12951295
// Forward all of the query metadata.
12961296
...Object.entries(metadata).map(([key, value]) => `-t=${key}=${value}`),
1297-
].concat(additonalArgs);
1298-
if (sourceInfo !== undefined) {
1299-
args.push(
1300-
"--source-archive",
1301-
sourceInfo.sourceArchive,
1302-
"--source-location-prefix",
1303-
sourceInfo.sourceLocationPrefix,
1304-
);
1305-
}
1306-
1307-
args.push("--threads", this.cliConfig.numberThreads.toString());
1308-
1309-
args.push("--max-paths", this.cliConfig.maxPaths.toString());
1297+
...additonalArgs,
1298+
...(sourceInfo !== undefined
1299+
? [
1300+
"--source-archive",
1301+
sourceInfo.sourceArchive,
1302+
"--source-location-prefix",
1303+
sourceInfo.sourceLocationPrefix,
1304+
]
1305+
: []),
1306+
"--threads",
1307+
this.cliConfig.numberThreads.toString(),
1308+
"--max-paths",
1309+
this.cliConfig.maxPaths.toString(),
1310+
resultsPath,
1311+
];
13101312

1311-
args.push(resultsPath);
13121313
await this.runCodeQlCliCommand(
13131314
["bqrs", "interpret"],
13141315
args,

extensions/ql-vscode/src/compare/compare-view.ts

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,23 @@ export class CompareView extends AbstractWebview<
168168
currentResultSetDisplayName,
169169
fromResultSetName,
170170
toResultSetName,
171-
} = await this.findResultSetsToCompare(
172-
this.comparePair,
171+
} = await findResultSetNames(
172+
this.comparePair.fromInfo,
173+
this.comparePair.toInfo,
174+
this.comparePair.commonResultSetNames,
173175
selectedResultSetName,
174176
);
175177
if (currentResultSetDisplayName) {
176178
let result: QueryCompareResult | undefined;
177179
let message: string | undefined;
178180
try {
179181
if (currentResultSetName === ALERTS_TABLE_NAME) {
180-
result = await this.compareInterpretedResults(this.comparePair);
182+
result = await compareInterpretedResults(
183+
this.databaseManager,
184+
this.cliServer,
185+
this.comparePair.from,
186+
this.comparePair.to,
187+
);
181188
} else {
182189
result = await this.compareResults(
183190
this.comparePair,
@@ -344,31 +351,6 @@ export class CompareView extends AbstractWebview<
344351
}
345352
}
346353

347-
private async findResultSetsToCompare(
348-
{ fromInfo, toInfo, commonResultSetNames }: ComparePair,
349-
selectedResultSetName: string | undefined,
350-
) {
351-
const {
352-
currentResultSetName,
353-
currentResultSetDisplayName,
354-
fromResultSetName,
355-
toResultSetName,
356-
} = await findResultSetNames(
357-
fromInfo,
358-
toInfo,
359-
commonResultSetNames,
360-
selectedResultSetName,
361-
);
362-
363-
return {
364-
commonResultSetNames,
365-
currentResultSetName,
366-
currentResultSetDisplayName,
367-
fromResultSetName,
368-
toResultSetName,
369-
};
370-
}
371-
372354
private async changeTable(newResultSetName: string) {
373355
await this.showResultsInternal(newResultSetName);
374356
}
@@ -450,18 +432,6 @@ export class CompareView extends AbstractWebview<
450432
}
451433
}
452434

453-
private async compareInterpretedResults({
454-
from,
455-
to,
456-
}: ComparePair): Promise<InterpretedQueryCompareResult> {
457-
return compareInterpretedResults(
458-
this.databaseManager,
459-
this.cliServer,
460-
from,
461-
to,
462-
);
463-
}
464-
465435
private async openQuery(kind: "from" | "to") {
466436
const toOpen =
467437
kind === "from" ? this.comparePair?.from : this.comparePair?.to;

0 commit comments

Comments
 (0)