Skip to content

Commit f741deb

Browse files
committed
Forward scored query metadata property for canary users
1 parent ae6be79 commit f741deb

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

extensions/ql-vscode/src/cli.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { promisify } from 'util';
1212
import { CancellationToken, Disposable } from 'vscode';
1313

1414
import { BQRSInfo, DecodedBqrsChunk } from './pure/bqrs-cli-types';
15+
import * as config from './config';
1516
import { CliConfig } from './config';
1617
import { DistributionProvider, FindDistributionResultKind } from './distribution';
1718
import { assertNever } from './pure/helpers-pure';
@@ -573,7 +574,7 @@ export class CodeQLCliServer implements Disposable {
573574
return await this.runJsonCodeQlCliCommand<DecodedBqrsChunk>(['bqrs', 'decode'], subcommandArgs, 'Reading bqrs data');
574575
}
575576

576-
async interpretBqrs(metadata: { kind: string; id: string }, resultsPath: string, interpretedResultsPath: string, sourceInfo?: SourceInfo): Promise<sarif.Log> {
577+
async interpretBqrs(metadata: { kind: string; id: string; scored?: string }, resultsPath: string, interpretedResultsPath: string, sourceInfo?: SourceInfo): Promise<sarif.Log> {
577578
const args = [
578579
`-t=kind=${metadata.kind}`,
579580
`-t=id=${metadata.id}`,
@@ -585,6 +586,9 @@ export class CodeQLCliServer implements Disposable {
585586
// grouping client-side.
586587
'--no-group-results',
587588
];
589+
if (config.isCanary() && metadata.scored !== undefined) {
590+
args.push(`-t=scored=${metadata.scored}`);
591+
}
588592
if (sourceInfo !== undefined) {
589593
args.push(
590594
'--source-archive', sourceInfo.sourceArchive,

extensions/ql-vscode/src/pure/interface-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface QueryMetadata {
3434
description?: string;
3535
id?: string;
3636
kind?: string;
37+
scored?: string;
3738
}
3839

3940
export interface PreviousExecution {

extensions/ql-vscode/src/query-results.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export async function interpretResults(
173173
if (metadata === undefined) {
174174
throw new Error('Can\'t interpret results without query metadata');
175175
}
176-
let { kind, id } = metadata;
176+
let { kind, id, scored } = metadata;
177177
if (kind === undefined) {
178178
throw new Error('Can\'t interpret results without query metadata including kind');
179179
}
@@ -182,5 +182,5 @@ export async function interpretResults(
182182
// SARIF format does, so in the absence of one, we use a dummy id.
183183
id = 'dummy-id';
184184
}
185-
return await server.interpretBqrs({ kind, id }, resultsPath, interpretedResultsPath, sourceInfo);
185+
return await server.interpretBqrs({ kind, id, scored }, resultsPath, interpretedResultsPath, sourceInfo);
186186
}

extensions/ql-vscode/src/vscode-tests/no-workspace/query-results.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ describe('CompletedQuery', () => {
152152
const sourceInfo = {};
153153
const metadata = {
154154
kind: 'my-kind',
155-
id: 'my-id' as string | undefined
155+
id: 'my-id' as string | undefined,
156+
scored: undefined
156157
};
157158
const results1 = await interpretResults(
158159
mockServer,
@@ -183,7 +184,7 @@ describe('CompletedQuery', () => {
183184
);
184185
expect(results2).to.eq('1234');
185186
expect(spy).to.have.been.calledWith(
186-
{ kind: 'my-kind', id: 'dummy-id' },
187+
{ kind: 'my-kind', id: 'dummy-id', scored: undefined },
187188
resultsPath, interpretedResultsPath, sourceInfo
188189
);
189190

0 commit comments

Comments
 (0)