Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion extensions/ql-vscode/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
"indent": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-throw-literal": "error",
"no-useless-escape": 0
"no-useless-escape": 0,
"semi": 2
},
};
8 changes: 4 additions & 4 deletions extensions/ql-vscode/src/adapt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface RawResultSet {
function adaptKind(kind: ColumnKind): ColumnType {
// XXX what about 'u'?
if (kind === 'e') {
return { type: 'e', primitiveType: 's', locationStyle: LocationStyle.FivePart, hasLabel: true }
return { type: 'e', primitiveType: 's', locationStyle: LocationStyle.FivePart, hasLabel: true };
}
else {
return { type: kind };
Expand All @@ -51,7 +51,7 @@ export function adaptSchema(schema: ResultSetSchema): AdaptedSchema {
name: schema.name,
tupleCount: schema.rows,
version: 0,
}
};
}

export function adaptValue(val: ColumnValue): ResultValue {
Expand Down Expand Up @@ -87,7 +87,7 @@ export function adaptValue(val: ColumnValue): ResultValue {
// something like the code in sarif-utils.ts?
file: url.uri.replace(/file:/, ''),
}
}
};

}

Expand All @@ -99,5 +99,5 @@ export function adaptBqrs(schema: AdaptedSchema, page: DecodedBqrsChunk): RawRes
return {
schema,
rows: page.tuples.map(adaptRow),
}
};
}
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/cli-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function tryParseVersionString(versionString: string): Version | undefine
patchVersion: Number.parseInt(match[3], 10),
prereleaseVersion: match[4],
rawString: versionString,
}
};
}

/**
Expand Down
30 changes: 15 additions & 15 deletions extensions/ql-vscode/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class CodeQLCliServer implements Disposable {
// If the server is not running a command run this immediately
// otherwise add to the front of the queue (as we want to run this after the next command()).
if (this.commandInProcess) {
this.commandQueue.unshift(callback)
this.commandQueue.unshift(callback);
} else {
callback();
}
Expand All @@ -188,19 +188,19 @@ export class CodeQLCliServer implements Disposable {
*/
private async launchProcess(): Promise<child_process.ChildProcessWithoutNullStreams> {
const config = await this.getCodeQlPath();
return spawnServer(config, "CodeQL CLI Server", ["execute", "cli-server"], [], this.logger, _data => { /**/ })
return spawnServer(config, "CodeQL CLI Server", ["execute", "cli-server"], [], this.logger, _data => { /**/ });
}

private async runCodeQlCliInternal(command: string[], commandArgs: string[], description: string): Promise<string> {
const stderrBuffers: Buffer[] = [];
if (this.commandInProcess) {
throw new Error("runCodeQlCliInternal called while cli was running")
throw new Error("runCodeQlCliInternal called while cli was running");
}
this.commandInProcess = true;
try {
//Launch the process if it doesn't exist
if (!this.process) {
this.process = await this.launchProcess()
this.process = await this.launchProcess();
}
// Grab the process so that typescript know that it is always defined.
const process = this.process;
Expand Down Expand Up @@ -230,8 +230,8 @@ export class CodeQLCliServer implements Disposable {
// Listen for process exit.
process.addListener("close", (code) => reject(code));
// Write the command followed by a null terminator.
process.stdin.write(JSON.stringify(args), "utf8")
process.stdin.write(this.nullBuffer)
process.stdin.write(JSON.stringify(args), "utf8");
process.stdin.write(this.nullBuffer);
});
// Join all the data together
const fullBuffer = Buffer.concat(stdoutBuffers);
Expand All @@ -252,8 +252,8 @@ export class CodeQLCliServer implements Disposable {
} finally {
this.logger.log(Buffer.concat(stderrBuffers).toString("utf8"));
// Remove the listeners we set up.
process.stdout.removeAllListeners('data')
process.stderr.removeAllListeners('data')
process.stdout.removeAllListeners('data');
process.stderr.removeAllListeners('data');
process.removeAllListeners("close");
}
} finally {
Expand Down Expand Up @@ -349,7 +349,7 @@ export class CodeQLCliServer implements Disposable {
try {
yield JSON.parse(event) as EventType;
} catch (err) {
throw new Error(`Parsing output of ${description} failed: ${err.stderr || err}`)
throw new Error(`Parsing output of ${description} failed: ${err.stderr || err}`);
}
}
}
Expand All @@ -375,11 +375,11 @@ export class CodeQLCliServer implements Disposable {
} catch (err) {
reject(err);
}
}
};
// If the server is not running a command, then run the given command immediately,
// otherwise add to the queue
if (this.commandInProcess) {
this.commandQueue.push(callback)
this.commandQueue.push(callback);
} else {
callback();
}
Expand All @@ -401,7 +401,7 @@ export class CodeQLCliServer implements Disposable {
try {
return JSON.parse(result) as OutputType;
} catch (err) {
throw new Error(`Parsing output of ${description} failed: ${err.stderr || err}`)
throw new Error(`Parsing output of ${description} failed: ${err.stderr || err}`);
}
}

Expand Down Expand Up @@ -535,12 +535,12 @@ export class CodeQLCliServer implements Disposable {
try {
output = await fs.readFile(interpretedResultsPath, 'utf8');
} catch (err) {
throw new Error(`Reading output of interpretation failed: ${err.stderr || err}`)
throw new Error(`Reading output of interpretation failed: ${err.stderr || err}`);
}
try {
return JSON.parse(output) as sarif.Log;
} catch (err) {
throw new Error(`Parsing output of interpretation failed: ${err.stderr || err}`)
throw new Error(`Parsing output of interpretation failed: ${err.stderr || err}`);
}
}

Expand Down Expand Up @@ -714,7 +714,7 @@ export async function runCodeQlCliCommand(codeQlPath: string, command: string[],
logger.log(`CLI command succeeded.`);
return result.stdout;
} catch (err) {
throw new Error(`${description} failed: ${err.stderr || err}`)
throw new Error(`${description} failed: ${err.stderr || err}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/databaseFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function databaseFetcher(
if (!storagePath) {
throw new Error("No storage path specified.");
}
await fs.ensureDir(storagePath)
await fs.ensureDir(storagePath);
const unzipPath = await getStorageFolder(storagePath, databaseUrl);

const response = await fetch.default(databaseUrl);
Expand Down
4 changes: 2 additions & 2 deletions extensions/ql-vscode/src/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async function findSourceArchive(
databasePath: string, silent = false
): Promise<vscode.Uri | undefined> {

const relativePaths = ['src', 'output/src_archive']
const relativePaths = ['src', 'output/src_archive'];

for (const relativePath of relativePaths) {
const basePath = path.join(databasePath, relativePath);
Expand Down Expand Up @@ -569,7 +569,7 @@ export class DatabaseManager extends DisposableObject {
};
const item = new DatabaseItemImpl(vscode.Uri.parse(state.uri), undefined, fullOptions,
(item) => {
this._onDidChangeDatabaseItem.fire(item)
this._onDidChangeDatabaseItem.fire(item);
});
await this.addDatabaseItem(item);

Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async function getLinksForUriString(
if (qlpack === undefined) {
throw new Error("Can't infer qlpack from database source archive");
}
const links: FullLocationLink[] = []
const links: FullLocationLink[] = [];
for (const query of await resolveQueries(cli, qlpack, keyType)) {
const templates: messages.TemplateDefinitions = {
[TEMPLATE_NAME]: {
Expand Down
8 changes: 4 additions & 4 deletions extensions/ql-vscode/src/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const DEFAULT_DISTRIBUTION_REPOSITORY_NAME = "codeql-cli-binaries";
export const DEFAULT_DISTRIBUTION_VERSION_CONSTRAINT: VersionConstraint = {
description: "2.*.*",
isVersionCompatible: (v: Version) => {
return v.majorVersion === 2 && v.minorVersion >= 0
return v.majorVersion === 2 && v.minorVersion >= 0;
}
}
};

export interface DistributionProvider {
getCodeQlPathWithoutVersionCheck(): Promise<string | undefined>;
Expand Down Expand Up @@ -86,7 +86,7 @@ export class DistributionManager implements DistributionProvider {
return {
codeQlPath,
kind: FindDistributionResultKind.UnknownCompatibilityDistribution,
}
};
}
return {
codeQlPath,
Expand Down Expand Up @@ -480,7 +480,7 @@ export class ReleasesApiConsumer {
// mechanism is provided.
delete headers["authorization"];
}
return await this.makeRawRequest(redirectUrl, headers, redirectCount + 1)
return await this.makeRawRequest(redirectUrl, headers, redirectCount + 1);
}

return response;
Expand Down
10 changes: 5 additions & 5 deletions extensions/ql-vscode/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async function internalShowAndLog(message: string, items: string[], outputLogger
*/
export async function showBinaryChoiceDialog(message: string): Promise<boolean> {
const yesItem = { title: 'Yes', isCloseAffordance: false };
const noItem = { title: 'No', isCloseAffordance: true }
const noItem = { title: 'No', isCloseAffordance: true };
const chosenItem = await Window.showInformationMessage(message, { modal: true }, yesItem, noItem);
return chosenItem === yesItem;
}
Expand All @@ -140,7 +140,7 @@ export function getOnDiskWorkspaceFolders() {
const diskWorkspaceFolders: string[] = [];
for (const workspaceFolder of workspaceFolders) {
if (workspaceFolder.uri.scheme === "file")
diskWorkspaceFolders.push(workspaceFolder.uri.fsPath)
diskWorkspaceFolders.push(workspaceFolder.uri.fsPath);
}
return diskWorkspaceFolders;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ export async function getQlPackForDbscheme(cliServer: CodeQLCliServer, dbschemeP
return {
packName,
packDir: dirs[0]
}
};
});
for (const { packDir, packName } of packs) {
if (packDir !== undefined) {
Expand All @@ -285,7 +285,7 @@ export async function getQlPackForDbscheme(cliServer: CodeQLCliServer, dbschemeP
}

export async function resolveDatasetFolder(cliServer: CodeQLCliServer, datasetFolder: string): Promise<DatasetFolderInfo> {
const dbschemes = await glob(path.join(datasetFolder, '*.dbscheme'))
const dbschemes = await glob(path.join(datasetFolder, '*.dbscheme'));

if (dbschemes.length < 1) {
throw new Error(`Can't find dbscheme for current database in ${datasetFolder}`);
Expand Down Expand Up @@ -322,7 +322,7 @@ export class CachedOperation<U> {
const fromCache = this.cached.get(t);
if (fromCache !== undefined) {
// Move to end of lru list
this.lru.push(this.lru.splice(this.lru.findIndex(v => v === t), 1)[0])
this.lru.push(this.lru.splice(this.lru.findIndex(v => v === t), 1)[0]);
return fromCache;
}
// Otherwise check if in progress
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/query-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class QueryHistoryManager {
// displays query text in a read-only document
vscode.workspace.registerTextDocumentContentProvider('codeql', {
provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult<string> {
const params = new URLSearchParams(uri.query)
const params = new URLSearchParams(uri.query);

return (
JSON.parse(params.get('isQuickEval') || '') ? SHOW_QUERY_TEXT_QUICK_EVAL_MSG : SHOW_QUERY_TEXT_MSG
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/query-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class CompletedQuery implements QueryWithResults {
* Call cli command to interpret results.
*/
export async function interpretResults(server: cli.CodeQLCliServer, metadata: QueryMetadata | undefined, resultsPath: string, sourceInfo?: cli.SourceInfo): Promise<sarif.Log> {
const interpretedResultsPath = resultsPath + ".interpreted.sarif"
const interpretedResultsPath = resultsPath + ".interpreted.sarif";

if (await fs.pathExists(interpretedResultsPath)) {
return JSON.parse(await fs.readFile(interpretedResultsPath, 'utf8'));
Expand Down
6 changes: 3 additions & 3 deletions extensions/ql-vscode/src/queryserver-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class QueryServerClient extends DisposableObject {
if (this.serverProcess !== undefined) {
this.disposeAndStopTracking(this.serverProcess);
} else {
this.logger.log('No server process to be stopped.')
this.logger.log('No server process to be stopped.');
}
}

Expand Down Expand Up @@ -136,13 +136,13 @@ export class QueryServerClient extends DisposableObject {
this.evaluationResultCallbacks[res.runId](res);
}
return {};
})
});
connection.onNotification(progress, res => {
const callback = this.progressCallbacks[res.id];
if (callback) {
callback(res);
}
})
});
this.serverProcess = new ServerProcess(child, connection, this.opts.logger);
// Ensure the server process is disposed together with this client.
this.track(this.serverProcess);
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/quick-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function displayQuickQuery(ctx: ExtensionContext, cliServer: CodeQL
return;
}

const index = workspaceFolders.findIndex(folder => folder.name === QUICK_QUERY_WORKSPACE_FOLDER_NAME)
const index = workspaceFolders.findIndex(folder => folder.name === QUICK_QUERY_WORKSPACE_FOLDER_NAME);
if (index === -1)
updateQuickQueryDir(queriesDir, workspaceFolders.length, 0);
else
Expand Down
14 changes: 7 additions & 7 deletions extensions/ql-vscode/src/run-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class QueryInfo {
): Promise<messages.EvaluationResult> {
let result: messages.EvaluationResult | null = null;

const callbackId = qs.registerCallback(res => { result = res });
const callbackId = qs.registerCallback(res => { result = res; });

const queryToRun: messages.QueryToRun = {
resultsPath: this.resultsPaths.resultsPath,
Expand All @@ -85,25 +85,25 @@ export class QueryInfo {
templateValues: this.templates,
id: callbackId,
timeoutSecs: qs.config.timeoutSecs,
}
};
const dataset: messages.Dataset = {
dbDir: this.dataset.fsPath,
workingSet: 'default'
}
};
const params: messages.EvaluateQueriesParams = {
db: dataset,
evaluateId: callbackId,
queries: [queryToRun],
stopOnError: false,
useSequenceHint: false
}
};
try {
await helpers.withProgress({
location: vscode.ProgressLocation.Notification,
title: "Running Query",
cancellable: true,
}, (progress, token) => {
return qs.sendRequest(messages.runQueries, params, token, progress)
return qs.sendRequest(messages.runQueries, params, token, progress);
});
} finally {
qs.unRegisterCallback(callbackId);
Expand Down Expand Up @@ -263,7 +263,7 @@ async function checkDbschemeCompatibility(
const { scripts, finalDbscheme } = await cliServer.resolveUpgrades(query.dbItem.contents.dbSchemeUri.fsPath, searchPath);
const hash = async function(filename: string): Promise<string> {
return crypto.createHash('sha256').update(await fs.readFile(filename)).digest('hex');
}
};

// At this point, we have learned about three dbschemes:

Expand Down Expand Up @@ -308,7 +308,7 @@ async function promptUserToSaveChanges(document: vscode.TextDocument): Promise<b
else {
const yesItem = { title: 'Yes', isCloseAffordance: false };
const alwaysItem = { title: 'Always Save', isCloseAffordance: false };
const noItem = { title: 'No', isCloseAffordance: true }
const noItem = { title: 'No', isCloseAffordance: true };
const message = 'Query file has unsaved changes. Save now?';
const chosenItem = await vscode.window.showInformationMessage(message, { modal: true }, yesItem, alwaysItem, noItem);

Expand Down
4 changes: 2 additions & 2 deletions extensions/ql-vscode/src/sarif-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Sarif from "sarif"
import * as path from "path"
import * as Sarif from "sarif";
import * as path from "path";
import { LocationStyle, ResolvableLocationValue } from "semmle-bqrs";

export interface SarifLink {
Expand Down
Loading