Skip to content

Commit eeca6d1

Browse files
authored
Merge pull request #190 from henrymercer/unused-value-checks
Enable unused value compiler checks
2 parents 722619f + 8190e7c commit eeca6d1

File tree

14 files changed

+36
-36
lines changed

14 files changed

+36
-36
lines changed

configs/typescript-config/common.tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"preserveWatchOutput": true,
1616
"newLine": "lf",
1717
"noImplicitReturns": true,
18-
"experimentalDecorators": true
18+
"experimentalDecorators": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true
1921
},
2022
"include": [
2123
"../../src/**/*.ts"

extensions/ql-vscode/src/archive-filesystem-provider.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
163163
// metadata
164164

165165
async stat(uri: vscode.Uri): Promise<vscode.FileStat> {
166-
return await this._lookup(uri, false);
166+
return await this._lookup(uri);
167167
}
168168

169169
async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> {
@@ -180,7 +180,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
180180
// file contents
181181

182182
async readFile(uri: vscode.Uri): Promise<Uint8Array> {
183-
const data = (await this._lookupAsFile(uri, false)).data;
183+
const data = (await this._lookupAsFile(uri)).data;
184184
if (data) {
185185
return data;
186186
}
@@ -189,25 +189,25 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
189189

190190
// write operations, all disabled
191191

192-
writeFile(uri: vscode.Uri, content: Uint8Array, options: { create: boolean, overwrite: boolean }): void {
192+
writeFile(_uri: vscode.Uri, _content: Uint8Array, _options: { create: boolean, overwrite: boolean }): void {
193193
throw this.readOnlyError;
194194
}
195195

196-
rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean }): void {
196+
rename(_oldUri: vscode.Uri, _newUri: vscode.Uri, _options: { overwrite: boolean }): void {
197197
throw this.readOnlyError;
198198
}
199199

200-
delete(uri: vscode.Uri): void {
200+
delete(_uri: vscode.Uri): void {
201201
throw this.readOnlyError;
202202
}
203203

204-
createDirectory(uri: vscode.Uri): void {
204+
createDirectory(_uri: vscode.Uri): void {
205205
throw this.readOnlyError;
206206
}
207207

208208
// content lookup
209209

210-
private async _lookup(uri: vscode.Uri, silent: boolean): Promise<Entry> {
210+
private async _lookup(uri: vscode.Uri): Promise<Entry> {
211211
const ref = decodeSourceArchiveUri(uri);
212212
const archive = await this.getArchive(ref.sourceArchiveZipPath);
213213

@@ -238,8 +238,8 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
238238
throw vscode.FileSystemError.FileNotFound(uri);
239239
}
240240

241-
private async _lookupAsFile(uri: vscode.Uri, silent: boolean): Promise<File> {
242-
let entry = await this._lookup(uri, silent);
241+
private async _lookupAsFile(uri: vscode.Uri): Promise<File> {
242+
let entry = await this._lookup(uri);
243243
if (entry instanceof File) {
244244
return entry;
245245
}

extensions/ql-vscode/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class CodeQLCliServer implements Disposable {
154154
if (!config) {
155155
throw new Error("Failed to find codeql distribution")
156156
}
157-
return spawnServer(config, "CodeQL CLI Server", ["execute", "cli-server"], [], this.logger, data => { })
157+
return spawnServer(config, "CodeQL CLI Server", ["execute", "cli-server"], [], this.logger, _data => {})
158158
}
159159

160160
private async runCodeQlCliInternal(command: string[], commandArgs: string[], description: string): Promise<string> {

extensions/ql-vscode/src/databases-ui.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class DatabaseTreeDataProvider extends DisposableObject
9090
}
9191
}
9292

93-
public getParent(element: DatabaseItem): ProviderResult<DatabaseItem> {
93+
public getParent(_element: DatabaseItem): ProviderResult<DatabaseItem> {
9494
return null;
9595
}
9696

@@ -128,7 +128,7 @@ async function chooseDatabaseDir(): Promise<Uri | undefined> {
128128
}
129129

130130
export class DatabaseUI extends DisposableObject {
131-
public constructor(private ctx: ExtensionContext, private cliserver: cli.CodeQLCliServer, private databaseManager: DatabaseManager,
131+
public constructor(ctx: ExtensionContext, private cliserver: cli.CodeQLCliServer, private databaseManager: DatabaseManager,
132132
private readonly queryServer: qsClient.QueryServerClient | undefined) {
133133

134134
super();

extensions/ql-vscode/src/databases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ class DatabaseItemImpl implements DatabaseItem {
415415
* >1000ms) log a warning, and resolve to undefined.
416416
*/
417417
function eventFired<T>(event: vscode.Event<T>, timeoutMs: number = 1000): Promise<T | undefined> {
418-
return new Promise((res, rej) => {
418+
return new Promise((res, _rej) => {
419419
let timeout: NodeJS.Timeout | undefined;
420420
let disposable: vscode.Disposable | undefined;
421421
function dispose() {

extensions/ql-vscode/src/extension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ let isInstallingOrUpdatingDistribution = false;
4949
*
5050
* @param excludedCommands List of commands for which we should not register error stubs.
5151
*/
52-
function registerErrorStubs(ctx: ExtensionContext, excludedCommands: string[], stubGenerator: (command: string) => () => void) {
52+
function registerErrorStubs(excludedCommands: string[], stubGenerator: (command: string) => () => void) {
5353
// Remove existing stubs
5454
errorStubs.forEach(stub => stub.dispose());
5555

@@ -79,7 +79,7 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
7979

8080
const shouldUpdateOnNextActivationKey = "shouldUpdateOnNextActivation";
8181

82-
registerErrorStubs(ctx, [checkForUpdatesCommand], command => () => {
82+
registerErrorStubs([checkForUpdatesCommand], command => () => {
8383
helpers.showAndLogErrorMessage(`Can't execute ${command}: waiting to finish loading CodeQL CLI.`);
8484
});
8585

@@ -189,7 +189,7 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
189189
if (!beganMainExtensionActivation && distributionResult.kind !== FindDistributionResultKind.NoDistribution) {
190190
await activateWithInstalledDistribution(ctx, distributionManager);
191191
} else if (distributionResult.kind === FindDistributionResultKind.NoDistribution) {
192-
registerErrorStubs(ctx, [checkForUpdatesCommand], command => async () => {
192+
registerErrorStubs([checkForUpdatesCommand], command => async () => {
193193
const installActionName = "Install CodeQL CLI";
194194
const chosenAction = await helpers.showAndLogErrorMessage(`Can't execute ${command}: missing CodeQL CLI.`, installActionName);
195195
if (chosenAction === installActionName) {

extensions/ql-vscode/src/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export class InterfaceManager extends DisposableObject {
199199
}
200200

201201
private waitForPanelLoaded(): Promise<void> {
202-
return new Promise((resolve, reject) => {
202+
return new Promise((resolve, _reject) => {
203203
if (this._panelLoaded) {
204204
resolve();
205205
} else {

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,14 @@ class HistoryTreeDataProvider implements vscode.TreeDataProvider<QueryHistoryIte
8989
private _onDidChangeTreeData: vscode.EventEmitter<QueryHistoryItem | undefined> = new vscode.EventEmitter<QueryHistoryItem | undefined>();
9090
readonly onDidChangeTreeData: vscode.Event<QueryHistoryItem | undefined> = this._onDidChangeTreeData.event;
9191

92-
private ctx: ExtensionContext;
9392
private history: QueryHistoryItem[] = [];
9493

9594
/**
9695
* When not undefined, must be reference-equal to an item in `this.databases`.
9796
*/
9897
private current: QueryHistoryItem | undefined;
9998

100-
constructor(ctx: ExtensionContext) {
101-
this.ctx = ctx;
99+
constructor() {
102100
this.history = [];
103101
}
104102

@@ -123,7 +121,7 @@ class HistoryTreeDataProvider implements vscode.TreeDataProvider<QueryHistoryIte
123121
}
124122
}
125123

126-
getParent(element: QueryHistoryItem): vscode.ProviderResult<QueryHistoryItem> {
124+
getParent(_element: QueryHistoryItem): vscode.ProviderResult<QueryHistoryItem> {
127125
return null;
128126
}
129127

@@ -238,7 +236,7 @@ export class QueryHistoryManager {
238236
) {
239237
this.ctx = ctx;
240238
this.selectedCallback = selectedCallback;
241-
const treeDataProvider = this.treeDataProvider = new HistoryTreeDataProvider(ctx);
239+
const treeDataProvider = this.treeDataProvider = new HistoryTreeDataProvider();
242240
this.treeView = Window.createTreeView('codeQLQueryHistory', { treeDataProvider });
243241
this.treeView.onDidChangeSelection(async ev => {
244242
if (ev.selection.length == 0) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe("Releases API consumer", () => {
4848

4949
it("picking latest release: is based on version", async () => {
5050
class MockReleasesApiConsumer extends ReleasesApiConsumer {
51-
protected async makeApiCall(apiPath: string, additionalHeaders: { [key: string]: string } = {}): Promise<fetch.Response> {
51+
protected async makeApiCall(apiPath: string): Promise<fetch.Response> {
5252
if (apiPath === `/repos/${owner}/${repo}/releases`) {
5353
return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse)));
5454
}
@@ -64,7 +64,7 @@ describe("Releases API consumer", () => {
6464

6565
it("picking latest release: obeys version constraints", async () => {
6666
class MockReleasesApiConsumer extends ReleasesApiConsumer {
67-
protected async makeApiCall(apiPath: string, additionalHeaders: { [key: string]: string } = {}): Promise<fetch.Response> {
67+
protected async makeApiCall(apiPath: string): Promise<fetch.Response> {
6868
if (apiPath === `/repos/${owner}/${repo}/releases`) {
6969
return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse)));
7070
}
@@ -83,7 +83,7 @@ describe("Releases API consumer", () => {
8383

8484
it("picking latest release: includes prereleases when option set", async () => {
8585
class MockReleasesApiConsumer extends ReleasesApiConsumer {
86-
protected async makeApiCall(apiPath: string, additionalHeaders: { [key: string]: string } = {}): Promise<fetch.Response> {
86+
protected async makeApiCall(apiPath: string): Promise<fetch.Response> {
8787
if (apiPath === `/repos/${owner}/${repo}/releases`) {
8888
return Promise.resolve(new fetch.Response(JSON.stringify(sampleReleaseResponse)));
8989
}
@@ -112,7 +112,7 @@ describe("Releases API consumer", () => {
112112
];
113113

114114
class MockReleasesApiConsumer extends ReleasesApiConsumer {
115-
protected async makeApiCall(apiPath: string, additionalHeaders: { [key: string]: string } = {}): Promise<fetch.Response> {
115+
protected async makeApiCall(apiPath: string): Promise<fetch.Response> {
116116
if (apiPath === `/repos/${owner}/${repo}/releases`) {
117117
const responseBody: GithubRelease[] = [{
118118
"assets": expectedAssets,

extensions/ql-vscode/test/pure-tests/query-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe('using the query server', function () {
100100
};
101101
const logger = {
102102
log: (s: string) => console.log('logger says', s),
103-
logWithoutTrailingNewline: (s: string) => { }
103+
logWithoutTrailingNewline: (s: string) => console.log('logger says', s)
104104
};
105105
cliServer = new cli.CodeQLCliServer({
106106
async getCodeQlPathWithoutVersionCheck(): Promise<string | undefined> {
@@ -167,7 +167,7 @@ describe('using the query server', function () {
167167
it(`should be able to run query ${queryName}`, async function () {
168168
try {
169169
await compilationSucceeded.done();
170-
const callbackId = qs.registerCallback(res => {
170+
const callbackId = qs.registerCallback(_res => {
171171
evaluationSucceeded.resolve();
172172
});
173173
const queryToRun: messages.QueryToRun = {

0 commit comments

Comments
 (0)