partial cherry-pick from `qc-development` branch
This commit is contained in:
shati-patel 2021-06-14 11:59:27 +01:00 коммит произвёл Shati Patel
Родитель 61373209ff
Коммит 06b22511a7
26 изменённых файлов: 901 добавлений и 238 удалений

Просмотреть файл

@ -22,6 +22,7 @@ module.exports = {
},
],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-floating-promises": [ "error", { ignoreVoid: true } ],

1013
extensions/ql-vscode/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -13,7 +13,7 @@
"url": "https://github.com/github/vscode-codeql"
},
"engines": {
"vscode": "^1.43.0"
"vscode": "^1.48.0"
},
"categories": [
"Programming Languages"
@ -916,11 +916,11 @@
"@types/through2": "^2.0.36",
"@types/tmp": "^0.1.0",
"@types/unzipper": "~0.10.1",
"@types/vscode": "^1.43.0",
"@types/vscode": "^1.48.0",
"@types/webpack": "^4.32.1",
"@types/xml2js": "~0.4.4",
"@typescript-eslint/eslint-plugin": "~2.23.0",
"@typescript-eslint/parser": "~2.23.0",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"ansi-colors": "^4.1.1",
"applicationinsights": "^1.8.7",
"chai": "^4.2.0",
@ -948,7 +948,7 @@
"ts-loader": "^8.1.0",
"ts-node": "^8.3.0",
"ts-protoc-gen": "^0.9.0",
"typescript": "~3.8.3",
"typescript": "^4.3.2",
"typescript-formatter": "^7.2.2",
"vsce": "^1.65.0",
"vscode-test": "^1.4.0",

Просмотреть файл

@ -56,7 +56,7 @@ class AstViewerDataProvider extends DisposableObject implements TreeDataProvider
}
refresh(): void {
this._onDidChangeTreeData.fire();
this._onDidChangeTreeData.fire(undefined);
}
getChildren(item?: AstItem): ProviderResult<AstItem[]> {
const children = item ? item.children : this.roots;

Просмотреть файл

@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/camelcase */
import * as cpp from 'child-process-promise';
import * as child_process from 'child_process';
import * as fs from 'fs-extra';

Просмотреть файл

@ -21,7 +21,7 @@ const emptyComparison: SetComparisonsMessage = {
message: 'Empty comparison'
};
export function Compare(_: {}): JSX.Element {
export function Compare(_: Record<string, never>): JSX.Element {
const [comparison, setComparison] = useState<SetComparisonsMessage>(
emptyComparison
);
@ -66,8 +66,8 @@ export function Compare(_: {}): JSX.Element {
{hasRows ? (
<CompareTable comparison={comparison}></CompareTable>
) : (
<div className="vscode-codeql__compare-message">{message}</div>
)}
<div className="vscode-codeql__compare-message">{message}</div>
)}
</>
);
} catch (err) {

Просмотреть файл

@ -147,7 +147,7 @@ export abstract class ConfigListener extends DisposableObject {
protected abstract handleDidChangeConfiguration(e: ConfigurationChangeEvent): void;
private updateConfiguration(): void {
this._onDidChangeConfiguration.fire();
this._onDidChangeConfiguration.fire(undefined);
}
public get onDidChangeConfiguration(): Event<void> {
@ -189,7 +189,7 @@ export class QueryServerConfigListener extends ConfigListener implements QuerySe
config.push(distributionManager.onDidChangeDistribution(async () => {
const codeQlPath = await distributionManager.getCodeQlPathWithoutVersionCheck();
config._codeQlPath = codeQlPath!;
config._onDidChangeConfiguration.fire();
config._onDidChangeConfiguration.fire(undefined);
}));
}
return config;

Просмотреть файл

@ -179,7 +179,7 @@ class DatabaseTreeDataProvider extends DisposableObject
public set sortOrder(newSortOrder: SortOrder) {
this._sortOrder = newSortOrder;
this._onDidChangeTreeData.fire();
this._onDidChangeTreeData.fire(undefined);
}
}
@ -423,8 +423,7 @@ export class DatabaseUI extends DisposableObject {
if (failures.length) {
const dirname = path.dirname(failures[0]);
void showAndLogErrorMessage(
`Failed to delete unused databases (${
failures.join(', ')
`Failed to delete unused databases (${failures.join(', ')
}).\nTo delete unused databases, please remove them manually from the storage folder ${dirname}.`
);
}
@ -583,8 +582,7 @@ export class DatabaseUI extends DisposableObject {
} catch (e) {
// rethrow and let this be handled by default error handling.
throw new Error(
`Could not set database to ${path.basename(uri.fsPath)}. Reason: ${
e.message
`Could not set database to ${path.basename(uri.fsPath)}. Reason: ${e.message
}`
);
}

Просмотреть файл

@ -148,7 +148,7 @@ export interface CodeQLExtensionInterface {
*
* @returns CodeQLExtensionInterface
*/
export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionInterface | {}> {
export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionInterface | Record<string, never>> {
void logger.log(`Starting ${extensionId} extension`);
if (extension === undefined) {
throw new Error(`Can't find extension ${extensionId}`);
@ -298,13 +298,13 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
async function installOrUpdateThenTryActivate(
config: DistributionUpdateConfig
): Promise<CodeQLExtensionInterface | {}> {
): Promise<CodeQLExtensionInterface | Record<string, never>> {
await installOrUpdateDistribution(config);
// Display the warnings even if the extension has already activated.
const distributionResult = await getDistributionDisplayingDistributionWarnings();
let extensionInterface: CodeQLExtensionInterface | {} = {};
let extensionInterface: CodeQLExtensionInterface | Record<string, never> = {};
if (!beganMainExtensionActivation && distributionResult.kind !== FindDistributionResultKind.NoDistribution) {
extensionInterface = await activateWithInstalledDistribution(
ctx,
@ -498,8 +498,7 @@ async function activateWithInstalledDistribution(
void helpers.showAndLogErrorMessage(
'Jumping from a .qlref file to the .ql file it references is not '
+ 'supported with the CLI version you are running.\n'
+ `Please upgrade your CLI to version ${
CliVersionConstraint.CLI_VERSION_WITH_RESOLVE_QLREF
+ `Please upgrade your CLI to version ${CliVersionConstraint.CLI_VERSION_WITH_RESOLVE_QLREF
} or later to use this feature.`);
}
}

Просмотреть файл

@ -262,7 +262,7 @@ export interface CompilationTarget {
/**
* Compile as a normal query
*/
query?: {};
query?: Record<string, never>;
/**
* Compile as a quick evaluation
*/
@ -826,7 +826,7 @@ export interface ResultSet {
/**
* The type returned when the evaluation is complete
*/
export type EvaluationComplete = {};
export type EvaluationComplete = Record<string, never>;
/**
* The result of a single query

Просмотреть файл

@ -172,7 +172,7 @@ export class QLTestDiscovery extends Discovery<QLTestDiscoveryResults> {
this.watcher.addWatch(new RelativePattern(results.watchPath, '**/*.{ql,qlref}'));
// need to explicitly watch for changes to directories themselves.
this.watcher.addWatch(new RelativePattern(results.watchPath, '**/'));
this._onDidChangeTests.fire();
this._onDidChangeTests.fire(undefined);
}
/**

Просмотреть файл

@ -193,7 +193,7 @@ export class HistoryTreeDataProvider extends DisposableObject {
public set sortOrder(newSortOrder: SortOrder) {
this._sortOrder = newSortOrder;
this._onDidChangeTreeData.fire();
this._onDidChangeTreeData.fire(undefined);
}
}

Просмотреть файл

@ -12,7 +12,7 @@ export type RawTableProps = ResultTableProps & {
offset: number;
};
export class RawTable extends React.Component<RawTableProps, {}> {
export class RawTable extends React.Component<RawTableProps, Record<string, never>> {
constructor(props: RawTableProps) {
super(props);
}

Просмотреть файл

@ -82,7 +82,7 @@ export class ResultTables
private getResultSets(): ResultSet[] {
const resultSets: ResultSet[] =
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore 2783
this.props.rawResultSets.map((rs) => ({ t: 'RawResultSet', ...rs }));
@ -336,7 +336,7 @@ export class ResultTables
}
}
class ResultTable extends React.Component<ResultTableProps, {}> {
class ResultTable extends React.Component<ResultTableProps, Record<string, never>> {
constructor(props: ResultTableProps) {
super(props);

Просмотреть файл

@ -71,7 +71,7 @@ export const onNavigation = new EventHandlerList<NavigationEvent>();
/**
* A minimal state container for displaying results.
*/
class App extends React.Component<{}, ResultsViewState> {
class App extends React.Component<Record<string, never>, ResultsViewState> {
constructor(props: any) {
super(props);
this.state = {

Просмотреть файл

@ -1,5 +1,19 @@
module.exports = {
env: {
mocha: true
},
rules: {
"@typescript-eslint/ban-types": [
"error",
{
// For a full list of the default banned types, see:
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md
extendDefaults: true,
"types": {
// Don't complain about the `Function` type in test files. (Default is `true`.)
"Function": false,
}
}
]
}
}

Просмотреть файл

@ -25,7 +25,7 @@ describe('Databases', function() {
beforeEach(async () => {
try {
const extension = await extensions.getExtension<CodeQLExtensionInterface | {}>('GitHub.vscode-codeql')!.activate();
const extension = await extensions.getExtension<CodeQLExtensionInterface | Record<string, never>>('GitHub.vscode-codeql')!.activate();
if ('databaseManager' in extension) {
databaseManager = extension.databaseManager;
} else {

Просмотреть файл

@ -68,7 +68,7 @@ export default function(mocha: Mocha) {
// ensure etension is cleaned up.
(mocha.options as any).globalTeardown.push(
async () => {
const extension = await extensions.getExtension<CodeQLExtensionInterface | {}>('GitHub.vscode-codeql')!.activate();
const extension = await extensions.getExtension<CodeQLExtensionInterface | Record<string, never>>('GitHub.vscode-codeql')!.activate();
// This shuts down the extension and can only be run after all tests have completed.
// If this is not called, then the test process will hang.
if ('dispose' in extension) {

Просмотреть файл

@ -45,7 +45,7 @@ describe('Queries', function() {
sandbox = sinon.createSandbox();
try {
const extension = await extensions.getExtension<CodeQLExtensionInterface | {}>('GitHub.vscode-codeql')!.activate();
const extension = await extensions.getExtension<CodeQLExtensionInterface | Record<string, never>>('GitHub.vscode-codeql')!.activate();
if ('databaseManager' in extension) {
databaseManager = extension.databaseManager;
cli = extension.cliServer;

Просмотреть файл

@ -34,7 +34,7 @@ class Checkpoint<T> {
this.res = () => { /**/ };
this.rej = () => { /**/ };
this.promise = new Promise((res, rej) => {
this.res = res as () => {};
this.res = res as () => Record<string, never>;
this.rej = rej;
});
}
@ -104,7 +104,7 @@ describe('using the query server', function() {
beforeEach(async () => {
try {
const extension = await extensions.getExtension<CodeQLExtensionInterface | {}>('GitHub.vscode-codeql')!.activate();
const extension = await extensions.getExtension<CodeQLExtensionInterface | Record<string, never>>('GitHub.vscode-codeql')!.activate();
if ('cliServer' in extension && 'qs' in extension) {
cliServer = extension.cliServer;
qs = extension.qs;

Просмотреть файл

@ -16,7 +16,7 @@ describe('Use cli', function() {
let cli: CodeQLCliServer;
beforeEach(async () => {
const extension = await extensions.getExtension<CodeQLExtensionInterface | {}>('GitHub.vscode-codeql')!.activate();
const extension = await extensions.getExtension<CodeQLExtensionInterface | Record<string, never>>('GitHub.vscode-codeql')!.activate();
if ('cliServer' in extension) {
cli = extension.cliServer;
} else {

Просмотреть файл

@ -79,6 +79,7 @@ export async function runTestsInDirectory(testsRoot: string, useCli = false): Pr
.filter(f => f.endsWith('.helper.js'))
.forEach(f => {
console.log(`Executing helper ${f}`);
// eslint-disable-next-line @typescript-eslint/no-var-requires
const helper = require(path.resolve(testsRoot, f)).default;
helper(mocha);
});

Просмотреть файл

@ -29,7 +29,7 @@ describe('config listeners', function() {
});
interface TestConfig<T> {
clazz: new () => {};
clazz: new () => unknown;
settings: {
name: string;
property: string;

Просмотреть файл

@ -19,23 +19,23 @@ This test uses an AST generated from this file (already BQRS-decoded in ../data/
int interrupt_init(void)
{
return 0;
return 0;
}
void enable_interrupts(void)
{
return;
return;
}
int disable_interrupts(void)
{
return 0;
return 0;
}
*/
describe('AstBuilder', () => {
let mockCli: CodeQLCliServer;
let overrides: Record<string, object | undefined>;
let overrides: Record<string, Record<string, unknown> | undefined>;
beforeEach(() => {
mockCli = {

Просмотреть файл

@ -1,6 +1,6 @@
import { expect } from 'chai';
import 'mocha';
import { ExtensionContext, Memento, window } from 'vscode';
import { EnvironmentVariableCollection, EnvironmentVariableMutator, ExtensionContext, ExtensionMode, Memento, Uri, window } from 'vscode';
import * as yaml from 'js-yaml';
import * as tmp from 'tmp';
import * as path from 'path';
@ -146,6 +146,7 @@ describe('helpers', () => {
});
class MockExtensionContext implements ExtensionContext {
extensionMode: ExtensionMode = 3;
subscriptions: { dispose(): unknown }[] = [];
workspaceState: Memento = new MockMemento();
globalState: Memento = new MockMemento();
@ -156,6 +157,33 @@ describe('helpers', () => {
storagePath = '';
globalStoragePath = '';
logPath = '';
extensionUri = Uri.parse('');
environmentVariableCollection = new MockEnvironmentVariableCollection();
}
class MockEnvironmentVariableCollection implements EnvironmentVariableCollection {
persistent = false;
replace(_variable: string, _value: string): void {
throw new Error('Method not implemented.');
}
append(_variable: string, _value: string): void {
throw new Error('Method not implemented.');
}
prepend(_variable: string, _value: string): void {
throw new Error('Method not implemented.');
}
get(_variable: string): EnvironmentVariableMutator | undefined {
throw new Error('Method not implemented.');
}
forEach(_callback: (variable: string, mutator: EnvironmentVariableMutator, collection: EnvironmentVariableCollection) => any, _thisArg?: any): void {
throw new Error('Method not implemented.');
}
delete(_variable: string): void {
throw new Error('Method not implemented.');
}
clear(): void {
throw new Error('Method not implemented.');
}
}
class MockMemento implements Memento {

Просмотреть файл

@ -268,7 +268,7 @@ describe('query-history', () => {
});
});
function createMockQueryHistory(allHistory: {}[]) {
function createMockQueryHistory(allHistory: Record<string, unknown>[]) {
return {
assertSingleQuery: (QueryHistoryManager.prototype as any).assertSingleQuery,
findOtherQueryToCompare: (QueryHistoryManager.prototype as any).findOtherQueryToCompare,