Enable unused value compiler checks

Specifically, enable the noUnusedLocals and noUnusedParameters options.
This commit is contained in:
Henry Mercer
2019-12-09 17:43:20 +00:00
parent 7c183d0f1c
commit 8190e7c642
14 changed files with 36 additions and 36 deletions

View File

@@ -15,7 +15,9 @@
"preserveWatchOutput": true, "preserveWatchOutput": true,
"newLine": "lf", "newLine": "lf",
"noImplicitReturns": true, "noImplicitReturns": true,
"experimentalDecorators": true "experimentalDecorators": true,
"noUnusedLocals": true,
"noUnusedParameters": true
}, },
"include": [ "include": [
"../../src/**/*.ts" "../../src/**/*.ts"

View File

@@ -163,7 +163,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
// metadata // metadata
async stat(uri: vscode.Uri): Promise<vscode.FileStat> { async stat(uri: vscode.Uri): Promise<vscode.FileStat> {
return await this._lookup(uri, false); return await this._lookup(uri);
} }
async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> { async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> {
@@ -180,7 +180,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
// file contents // file contents
async readFile(uri: vscode.Uri): Promise<Uint8Array> { async readFile(uri: vscode.Uri): Promise<Uint8Array> {
const data = (await this._lookupAsFile(uri, false)).data; const data = (await this._lookupAsFile(uri)).data;
if (data) { if (data) {
return data; return data;
} }
@@ -189,25 +189,25 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
// write operations, all disabled // write operations, all disabled
writeFile(uri: vscode.Uri, content: Uint8Array, options: { create: boolean, overwrite: boolean }): void { writeFile(_uri: vscode.Uri, _content: Uint8Array, _options: { create: boolean, overwrite: boolean }): void {
throw this.readOnlyError; throw this.readOnlyError;
} }
rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean }): void { rename(_oldUri: vscode.Uri, _newUri: vscode.Uri, _options: { overwrite: boolean }): void {
throw this.readOnlyError; throw this.readOnlyError;
} }
delete(uri: vscode.Uri): void { delete(_uri: vscode.Uri): void {
throw this.readOnlyError; throw this.readOnlyError;
} }
createDirectory(uri: vscode.Uri): void { createDirectory(_uri: vscode.Uri): void {
throw this.readOnlyError; throw this.readOnlyError;
} }
// content lookup // content lookup
private async _lookup(uri: vscode.Uri, silent: boolean): Promise<Entry> { private async _lookup(uri: vscode.Uri): Promise<Entry> {
const ref = decodeSourceArchiveUri(uri); const ref = decodeSourceArchiveUri(uri);
const archive = await this.getArchive(ref.sourceArchiveZipPath); const archive = await this.getArchive(ref.sourceArchiveZipPath);
@@ -238,8 +238,8 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
throw vscode.FileSystemError.FileNotFound(uri); throw vscode.FileSystemError.FileNotFound(uri);
} }
private async _lookupAsFile(uri: vscode.Uri, silent: boolean): Promise<File> { private async _lookupAsFile(uri: vscode.Uri): Promise<File> {
let entry = await this._lookup(uri, silent); let entry = await this._lookup(uri);
if (entry instanceof File) { if (entry instanceof File) {
return entry; return entry;
} }

View File

@@ -154,7 +154,7 @@ export class CodeQLCliServer implements Disposable {
if (!config) { if (!config) {
throw new Error("Failed to find codeql distribution") throw new Error("Failed to find codeql distribution")
} }
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> { private async runCodeQlCliInternal(command: string[], commandArgs: string[], description: string): Promise<string> {

View File

@@ -90,7 +90,7 @@ class DatabaseTreeDataProvider extends DisposableObject
} }
} }
public getParent(element: DatabaseItem): ProviderResult<DatabaseItem> { public getParent(_element: DatabaseItem): ProviderResult<DatabaseItem> {
return null; return null;
} }
@@ -128,7 +128,7 @@ async function chooseDatabaseDir(): Promise<Uri | undefined> {
} }
export class DatabaseUI extends DisposableObject { export class DatabaseUI extends DisposableObject {
public constructor(private ctx: ExtensionContext, private cliserver: cli.CodeQLCliServer, private databaseManager: DatabaseManager, public constructor(ctx: ExtensionContext, private cliserver: cli.CodeQLCliServer, private databaseManager: DatabaseManager,
private readonly queryServer: qsClient.QueryServerClient | undefined) { private readonly queryServer: qsClient.QueryServerClient | undefined) {
super(); super();

View File

@@ -413,7 +413,7 @@ class DatabaseItemImpl implements DatabaseItem {
* >1000ms) log a warning, and resolve to undefined. * >1000ms) log a warning, and resolve to undefined.
*/ */
function eventFired<T>(event: vscode.Event<T>, timeoutMs: number = 1000): Promise<T | undefined> { function eventFired<T>(event: vscode.Event<T>, timeoutMs: number = 1000): Promise<T | undefined> {
return new Promise((res, rej) => { return new Promise((res, _rej) => {
let timeout: NodeJS.Timeout | undefined; let timeout: NodeJS.Timeout | undefined;
let disposable: vscode.Disposable | undefined; let disposable: vscode.Disposable | undefined;
function dispose() { function dispose() {

View File

@@ -49,7 +49,7 @@ let isInstallingOrUpdatingDistribution = false;
* *
* @param excludedCommands List of commands for which we should not register error stubs. * @param excludedCommands List of commands for which we should not register error stubs.
*/ */
function registerErrorStubs(ctx: ExtensionContext, excludedCommands: string[], stubGenerator: (command: string) => () => void) { function registerErrorStubs(excludedCommands: string[], stubGenerator: (command: string) => () => void) {
// Remove existing stubs // Remove existing stubs
errorStubs.forEach(stub => stub.dispose()); errorStubs.forEach(stub => stub.dispose());
@@ -79,7 +79,7 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
const shouldUpdateOnNextActivationKey = "shouldUpdateOnNextActivation"; const shouldUpdateOnNextActivationKey = "shouldUpdateOnNextActivation";
registerErrorStubs(ctx, [checkForUpdatesCommand], command => () => { registerErrorStubs([checkForUpdatesCommand], command => () => {
helpers.showAndLogErrorMessage(`Can't execute ${command}: waiting to finish loading CodeQL CLI.`); helpers.showAndLogErrorMessage(`Can't execute ${command}: waiting to finish loading CodeQL CLI.`);
}); });
@@ -189,7 +189,7 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
if (!beganMainExtensionActivation && distributionResult.kind !== FindDistributionResultKind.NoDistribution) { if (!beganMainExtensionActivation && distributionResult.kind !== FindDistributionResultKind.NoDistribution) {
await activateWithInstalledDistribution(ctx, distributionManager); await activateWithInstalledDistribution(ctx, distributionManager);
} else if (distributionResult.kind === FindDistributionResultKind.NoDistribution) { } else if (distributionResult.kind === FindDistributionResultKind.NoDistribution) {
registerErrorStubs(ctx, [checkForUpdatesCommand], command => async () => { registerErrorStubs([checkForUpdatesCommand], command => async () => {
const installActionName = "Install CodeQL CLI"; const installActionName = "Install CodeQL CLI";
const chosenAction = await helpers.showAndLogErrorMessage(`Can't execute ${command}: missing CodeQL CLI.`, installActionName); const chosenAction = await helpers.showAndLogErrorMessage(`Can't execute ${command}: missing CodeQL CLI.`, installActionName);
if (chosenAction === installActionName) { if (chosenAction === installActionName) {

View File

@@ -199,7 +199,7 @@ export class InterfaceManager extends DisposableObject {
} }
private waitForPanelLoaded(): Promise<void> { private waitForPanelLoaded(): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, _reject) => {
if (this._panelLoaded) { if (this._panelLoaded) {
resolve(); resolve();
} else { } else {

View File

@@ -89,7 +89,6 @@ class HistoryTreeDataProvider implements vscode.TreeDataProvider<QueryHistoryIte
private _onDidChangeTreeData: vscode.EventEmitter<QueryHistoryItem | undefined> = new vscode.EventEmitter<QueryHistoryItem | undefined>(); private _onDidChangeTreeData: vscode.EventEmitter<QueryHistoryItem | undefined> = new vscode.EventEmitter<QueryHistoryItem | undefined>();
readonly onDidChangeTreeData: vscode.Event<QueryHistoryItem | undefined> = this._onDidChangeTreeData.event; readonly onDidChangeTreeData: vscode.Event<QueryHistoryItem | undefined> = this._onDidChangeTreeData.event;
private ctx: ExtensionContext;
private history: QueryHistoryItem[] = []; private history: QueryHistoryItem[] = [];
/** /**
@@ -97,8 +96,7 @@ class HistoryTreeDataProvider implements vscode.TreeDataProvider<QueryHistoryIte
*/ */
private current: QueryHistoryItem | undefined; private current: QueryHistoryItem | undefined;
constructor(ctx: ExtensionContext) { constructor() {
this.ctx = ctx;
this.history = []; this.history = [];
} }
@@ -123,7 +121,7 @@ class HistoryTreeDataProvider implements vscode.TreeDataProvider<QueryHistoryIte
} }
} }
getParent(element: QueryHistoryItem): vscode.ProviderResult<QueryHistoryItem> { getParent(_element: QueryHistoryItem): vscode.ProviderResult<QueryHistoryItem> {
return null; return null;
} }
@@ -238,7 +236,7 @@ export class QueryHistoryManager {
) { ) {
this.ctx = ctx; this.ctx = ctx;
this.selectedCallback = selectedCallback; this.selectedCallback = selectedCallback;
const treeDataProvider = this.treeDataProvider = new HistoryTreeDataProvider(ctx); const treeDataProvider = this.treeDataProvider = new HistoryTreeDataProvider();
this.treeView = Window.createTreeView('codeQLQueryHistory', { treeDataProvider }); this.treeView = Window.createTreeView('codeQLQueryHistory', { treeDataProvider });
this.treeView.onDidChangeSelection(async ev => { this.treeView.onDidChangeSelection(async ev => {
if (ev.selection.length == 0) { if (ev.selection.length == 0) {

View File

@@ -48,7 +48,7 @@ describe("Releases API consumer", () => {
it("picking latest release: is based on version", async () => { it("picking latest release: is based on version", async () => {
class MockReleasesApiConsumer extends ReleasesApiConsumer { class MockReleasesApiConsumer extends ReleasesApiConsumer {
protected async makeApiCall(apiPath: string, additionalHeaders: { [key: string]: string } = {}): Promise<fetch.Response> { protected async makeApiCall(apiPath: string): Promise<fetch.Response> {
if (apiPath === `/repos/${owner}/${repo}/releases`) { if (apiPath === `/repos/${owner}/${repo}/releases`) {
return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse))); return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse)));
} }
@@ -64,7 +64,7 @@ describe("Releases API consumer", () => {
it("picking latest release: obeys version constraints", async () => { it("picking latest release: obeys version constraints", async () => {
class MockReleasesApiConsumer extends ReleasesApiConsumer { class MockReleasesApiConsumer extends ReleasesApiConsumer {
protected async makeApiCall(apiPath: string, additionalHeaders: { [key: string]: string } = {}): Promise<fetch.Response> { protected async makeApiCall(apiPath: string): Promise<fetch.Response> {
if (apiPath === `/repos/${owner}/${repo}/releases`) { if (apiPath === `/repos/${owner}/${repo}/releases`) {
return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse))); return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse)));
} }
@@ -83,7 +83,7 @@ describe("Releases API consumer", () => {
it("picking latest release: includes prereleases when option set", async () => { it("picking latest release: includes prereleases when option set", async () => {
class MockReleasesApiConsumer extends ReleasesApiConsumer { class MockReleasesApiConsumer extends ReleasesApiConsumer {
protected async makeApiCall(apiPath: string, additionalHeaders: { [key: string]: string } = {}): Promise<fetch.Response> { protected async makeApiCall(apiPath: string): Promise<fetch.Response> {
if (apiPath === `/repos/${owner}/${repo}/releases`) { if (apiPath === `/repos/${owner}/${repo}/releases`) {
return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse))); return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse)));
} }
@@ -112,7 +112,7 @@ describe("Releases API consumer", () => {
]; ];
class MockReleasesApiConsumer extends ReleasesApiConsumer { class MockReleasesApiConsumer extends ReleasesApiConsumer {
protected async makeApiCall(apiPath: string, additionalHeaders: { [key: string]: string } = {}): Promise<fetch.Response> { protected async makeApiCall(apiPath: string): Promise<fetch.Response> {
if (apiPath === `/repos/${owner}/${repo}/releases`) { if (apiPath === `/repos/${owner}/${repo}/releases`) {
const responseBody: GithubRelease[] = [{ const responseBody: GithubRelease[] = [{
"assets": expectedAssets, "assets": expectedAssets,

View File

@@ -100,7 +100,7 @@ describe('using the query server', function () {
}; };
const logger = { const logger = {
log: (s: string) => console.log('logger says', s), log: (s: string) => console.log('logger says', s),
logWithoutTrailingNewline: (s: string) => { } logWithoutTrailingNewline: (s: string) => console.log('logger says', s)
}; };
cliServer = new cli.CodeQLCliServer({ cliServer = new cli.CodeQLCliServer({
async getCodeQlPathWithoutVersionCheck(): Promise<string | undefined> { async getCodeQlPathWithoutVersionCheck(): Promise<string | undefined> {
@@ -167,7 +167,7 @@ describe('using the query server', function () {
it(`should be able to run query ${queryName}`, async function () { it(`should be able to run query ${queryName}`, async function () {
try { try {
await compilationSucceeded.done(); await compilationSucceeded.done();
const callbackId = qs.registerCallback(res => { const callbackId = qs.registerCallback(_res => {
evaluationSucceeded.resolve(); evaluationSucceeded.resolve();
}); });
const queryToRun: messages.QueryToRun = { const queryToRun: messages.QueryToRun = {

View File

@@ -166,7 +166,7 @@ type ParseTupleAction = (src: readonly ColumnValue[], dest: any) => void;
type TupleParser<T> = (src: readonly ColumnValue[]) => T; type TupleParser<T> = (src: readonly ColumnValue[]) => T;
export class CustomResultSet<TTuple> { export class CustomResultSet<TTuple> {
public constructor(private reader: ResultSetReader, private readonly type: { new(): TTuple }, public constructor(private reader: ResultSetReader,
private readonly tupleParser: TupleParser<TTuple>) { private readonly tupleParser: TupleParser<TTuple>) {
} }
@@ -192,7 +192,7 @@ class CustomResultSetBinder {
const binder = new CustomResultSetBinder(rowType, reader.schema); const binder = new CustomResultSetBinder(rowType, reader.schema);
const tupleParser = binder.bindRoot<TTuple>(); const tupleParser = binder.bindRoot<TTuple>();
return new CustomResultSet<TTuple>(reader, rowType, tupleParser); return new CustomResultSet<TTuple>(reader, tupleParser);
} }
private bindRoot<TTuple>(): TupleParser<TTuple> { private bindRoot<TTuple>(): TupleParser<TTuple> {

View File

@@ -124,7 +124,7 @@ export class StreamDigester {
} }
/** /**
* Implements an async read that span multple buffers. * Implements an async read that spans multiple buffers.
* *
* @param canReadFunc Callback function to determine how many bytes are required to complete the * @param canReadFunc Callback function to determine how many bytes are required to complete the
* read operation. * read operation.
@@ -186,7 +186,7 @@ export class StreamDigester {
private readKnownSizeAcrossSeam<T>(byteCount: number, private readKnownSizeAcrossSeam<T>(byteCount: number,
readFunc: (buffer: Buffer, offset: number) => T): Promise<T> { readFunc: (buffer: Buffer, offset: number) => T): Promise<T> {
return this.readAcrossSeam((buffer, offset, availableByteCount) => byteCount, readFunc); return this.readAcrossSeam((_buffer, _offset, _availableByteCount) => byteCount, readFunc);
} }
private readKnownSize<T>(byteCount: number, readFunc: (buffer: Buffer, offset: number) => T): private readKnownSize<T>(byteCount: number, readFunc: (buffer: Buffer, offset: number) => T):
@@ -300,4 +300,4 @@ function canDecodeLEB128UInt32(buffer: Buffer, offset: number, byteCount: number
function decodeLEB128UInt32(buffer: Buffer, offset: number): number { function decodeLEB128UInt32(buffer: Buffer, offset: number): number {
const { value } = leb.decodeUInt32(buffer, offset); const { value } = leb.decodeUInt32(buffer, offset);
return value; return value;
} }

View File

@@ -218,7 +218,7 @@ function transformFile(yaml: any) {
} }
export function transpileTextMateGrammar() { export function transpileTextMateGrammar() {
return through.obj((file: Vinyl, encoding: string, callback: Function): void => { return through.obj((file: Vinyl, _encoding: string, callback: Function): void => {
if (file.isNull()) { if (file.isNull()) {
callback(null, file); callback(null, file);
} }

View File

@@ -43,7 +43,7 @@ export function compileTypeScript() {
return tsProject.src() return tsProject.src()
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(tsProject(goodReporter())) .pipe(tsProject(goodReporter()))
.pipe(sourcemaps.mapSources((sourcePath, file) => { .pipe(sourcemaps.mapSources((sourcePath, _file) => {
// The source path is kind of odd, because it's relative to the `tsconfig.json` file in the // The source path is kind of odd, because it's relative to the `tsconfig.json` file in the
// `typescript-config` package, which lives in the `node_modules` directory of the package // `typescript-config` package, which lives in the `node_modules` directory of the package
// that is being built. It starts out as something like '../../../src/foo.ts', and we need to // that is being built. It starts out as something like '../../../src/foo.ts', and we need to