No unused locals (#8231)

* add no unused local

* fix strict null

* fix compile errors

* update vscode comments
This commit is contained in:
Anthony Dresser
2019-11-06 17:22:05 -08:00
committed by GitHub
parent 564f78b6f6
commit df0c505452
147 changed files with 726 additions and 892 deletions

View File

@@ -1,190 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as azdata from 'azdata';
import * as TypeMoq from 'typemoq';
import { AddAccountAction, RemoveAccountAction } from 'sql/platform/accounts/common/accountActions';
import { TestAccountManagementService } from 'sql/platform/accounts/test/common/testAccountManagementService';
// import { MessageServiceStub } from 'sqltest/stubs/messageServiceStub';
import { TestErrorMessageService } from 'sql/platform/errorMessage/test/common/testErrorMessageService';
let testAccount = <azdata.Account>{
key: {
providerId: 'azure',
accountId: 'testAccount'
},
displayInfo: {
accountType: 'test',
displayName: 'Test Account',
contextualDisplayName: 'Azure Account'
},
isStale: false
};
suite('Account Management Dialog Actions Tests', () => {
test('AddAccount - Success', (done) => {
done();
// // Setup: Create an AddAccountAction object
// let param = 'azure';
// let mocks = createAddAccountAction(true, true, param);
// // If: I run the action when it will resolve
// mocks.action.run()
// .then(result => {
// // Then:
// // ... I should have gotten true back
// assert.ok(result);
// // ... The account management service should have gotten a add account request
// mocks.accountMock.verify(x => x.addAccount(param), TypeMoq.Times.once());
// })
// .then(
// () => done(),
// err => done(err)
// );
});
// test('AddAccount - Failure', (done) => {
// // // Setup: Create an AddAccountAction object
// // let param = 'azure';
// // let mocks = createAddAccountAction(false, true, param);
// // // If: I run the action when it will reject
// // mocks.action.run().then(result => {
// // // Then:
// // // ... The result should be false since the operation failed
// // assert.ok(!result);
// // // ... The account management service should have gotten a add account request
// // mocks.accountMock.verify(x => x.addAccount(param), TypeMoq.Times.once());
// // done();
// // }, error => {
// // // Should fail as rejected actions cause the debugger to crash
// // done(error);
// // });
// });
// test('RemoveAccount - Confirm Success', (done) => {
// // // Setup: Create an AddAccountAction object
// // let ams = getMockAccountManagementService(true);
// // let ms = getMockMessageService(true);
// // let es = getMockErrorMessageService();
// // let action = new RemoveAccountAction(testAccount, ms.object, es.object, ams.object);
// // // If: I run the action when it will resolve
// // action.run()
// // .then(result => {
// // // Then:
// // // ... I should have gotten true back
// // assert.ok(result);
// // // ... A confirmation dialog should have opened
// // ms.verify(x => x.confirm(TypeMoq.It.isAny()), TypeMoq.Times.once());
// // // ... The account management service should have gotten a remove account request
// // ams.verify(x => x.removeAccount(TypeMoq.It.isValue(testAccount.key)), TypeMoq.Times.once());
// // })
// // .then(
// // () => done(),
// // err => done(err)
// // );
// });
// test('RemoveAccount - Declined Success', (done) => {
// // // Setup: Create an AddAccountAction object
// // let ams = getMockAccountManagementService(true);
// // let ms = getMockMessageService(false);
// // let es = getMockErrorMessageService();
// // let action = new RemoveAccountAction(testAccount, ms.object, es.object, ams.object);
// // // If: I run the action when it will resolve
// // action.run()
// // .then(result => {
// // try {
// // // Then:
// // // ... I should have gotten false back
// // assert.ok(!result);
// // // ... A confirmation dialog should have opened
// // ms.verify(x => x.confirm(TypeMoq.It.isAny()), TypeMoq.Times.once());
// // // ... The account management service should not have gotten a remove account request
// // ams.verify(x => x.removeAccount(TypeMoq.It.isAny()), TypeMoq.Times.never());
// // done();
// // } catch (e) {
// // done(e);
// // }
// // });
// });
// test('RemoveAccount - Failure', (done) => {
// // // Setup: Create an AddAccountAction object
// // let ams = getMockAccountManagementService(false);
// // let ms = getMockMessageService(true);
// // let es = getMockErrorMessageService();
// // let action = new RemoveAccountAction(testAccount, ms.object, es.object, ams.object);
// // // If: I run the action when it will reject
// // action.run().then(result => {
// // // Then:
// // // ... The result should be false since the operation failed
// // assert.ok(!result);
// // // ... The account management service should have gotten a remove account request
// // ams.verify(x => x.removeAccount(TypeMoq.It.isValue(testAccount.key)), TypeMoq.Times.once());
// // done();
// // }, error => {
// // // Should fail as rejected actions cause the debugger to crash
// // done(error);
// // });
// });
});
// function createAddAccountAction(resolve: boolean, confirm: boolean, param: string): IAddActionMocks {
// let ams = getMockAccountManagementService(resolve);
// let mockMessageService = getMockMessageService(confirm);
// let mockErrorMessageService = getMockErrorMessageService();
// return {
// accountMock: ams,
// messageMock: mockMessageService,
// errorMessageMock: mockErrorMessageService,
// action: new AddAccountAction(param, mockMessageService.object,
// mockErrorMessageService.object, ams.object)
// };
// }
// function getMockAccountManagementService(resolve: boolean): TypeMoq.Mock<AccountManagementTestService> {
// let mockAccountManagementService = TypeMoq.Mock.ofType(AccountManagementTestService);
// mockAccountManagementService.setup(x => x.addAccount(TypeMoq.It.isAnyString()))
// .returns(resolve ? () => Promise.resolve(null) : () => Promise.reject(null));
// mockAccountManagementService.setup(x => x.removeAccount(TypeMoq.It.isAny()))
// .returns(resolve ? () => Promise.resolve(true) : () => Promise.reject(null).then());
// return mockAccountManagementService;
// }
// function getMockMessageService(confirm: boolean): TypeMoq.Mock<MessageServiceStub> {
// let mockMessageService = TypeMoq.Mock.ofType(MessageServiceStub);
// mockMessageService.setup(x => x.confirm(TypeMoq.It.isAny()))
// .returns(() => undefined);
// return mockMessageService;
// }
// function getMockErrorMessageService(): TypeMoq.Mock<ErrorMessageServiceStub> {
// let mockMessageService = TypeMoq.Mock.ofType(ErrorMessageServiceStub);
// mockMessageService.setup(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()));
// return mockMessageService;
// }
// interface IAddActionMocks
// {
// accountMock: TypeMoq.Mock<AccountManagementTestService>;
// messageMock: TypeMoq.Mock<MessageServiceStub>;
// errorMessageMock: TypeMoq.Mock<ErrorMessageServiceStub>;
// action: AddAccountAction;
// }

View File

@@ -3,8 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
// constants
export const sqlConfigSectionName = 'sql';
export const outputChannelName = 'MSSQL';

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { getConfigurationKeys, IConfigurationOverrides, IConfigurationService, getConfigurationValue, isConfigurationOverrides, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { getConfigurationKeys, IConfigurationOverrides, IConfigurationService, getConfigurationValue, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
export class TestConfigurationService implements IConfigurationService {
public _serviceBrand: undefined;

View File

@@ -100,7 +100,6 @@ suite('SQL ConnectionStatusManager tests', () => {
test('findConnection should return connection given valid id', () => {
let id: string = connection1Id;
let expected = connectionProfileObject;
let actual = connections.findConnection(id);
assert.equal(connectionProfileObject.matches(actual.connectionProfile), true);
});
@@ -114,7 +113,6 @@ suite('SQL ConnectionStatusManager tests', () => {
test('getConnectionProfile should return connection given valid id', () => {
let id: string = connection1Id;
let expected = connectionProfileObject;
let actual = connections.getConnectionProfile(id);
assert.equal(connectionProfileObject.matches(actual), true);
});

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { IDisposable } from 'vs/base/common/lifecycle';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import * as azdata from 'azdata';
import { Deferred } from 'sql/base/common/promise';

View File

@@ -21,7 +21,6 @@ import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
import { JobManagementView } from 'sql/workbench/parts/jobManagement/browser/jobManagementView';
import { NotebooksViewComponent } from 'sql/workbench/parts/jobManagement/browser/notebooksView.component';
import { NotebookHistoryComponent } from 'sql/workbench/parts/jobManagement/browser/notebookHistory.component';
export const successLabel: string = nls.localize('jobaction.successLabel', "Success");
export const errorLabel: string = nls.localize('jobaction.faillabel', "Error");
@@ -177,9 +176,7 @@ export class OpenMaterializedNotebookAction extends Action {
public static ID = 'notebookAction.openNotebook';
public static LABEL = nls.localize('notebookAction.openNotebook', "Open");
constructor(
@ICommandService private _commandService: ICommandService
) {
constructor() {
super(OpenMaterializedNotebookAction.ID, OpenMaterializedNotebookAction.LABEL, 'openNotebook');
}
@@ -610,9 +607,7 @@ export class OpenTemplateNotebookAction extends Action {
public static ID = 'notebookaction.openTemplate';
public static LABEL = nls.localize('notebookaction.openNotebook', "Open Template Notebook");
constructor(
@ICommandService private _commandService: ICommandService
) {
constructor() {
super(OpenTemplateNotebookAction.ID, OpenTemplateNotebookAction.LABEL, 'opennotebook');
}
@@ -673,9 +668,7 @@ export class PinNotebookMaterializedAction extends Action {
public static ID = 'notebookaction.openTemplate';
public static LABEL = nls.localize('notebookaction.pinNotebook', "Pin");
constructor(
@ICommandService private _commandService: ICommandService
) {
constructor() {
super(PinNotebookMaterializedAction.ID, PinNotebookMaterializedAction.LABEL);
}
@@ -689,9 +682,7 @@ export class DeleteMaterializedNotebookAction extends Action {
public static ID = 'notebookaction.deleteMaterializedNotebook';
public static LABEL = nls.localize('notebookaction.deleteMaterializedNotebook', "Delete");
constructor(
@ICommandService private _commandService: ICommandService
) {
constructor() {
super(DeleteMaterializedNotebookAction.ID, DeleteMaterializedNotebookAction.LABEL);
}
@@ -705,9 +696,7 @@ export class UnpinNotebookMaterializedAction extends Action {
public static ID = 'notebookaction.unpinNotebook';
public static LABEL = nls.localize('notebookaction.unpinNotebook', "Unpin");
constructor(
@ICommandService private _commandService: ICommandService
) {
constructor() {
super(UnpinNotebookMaterializedAction.ID, UnpinNotebookMaterializedAction.LABEL);
}
@@ -721,9 +710,7 @@ export class RenameNotebookMaterializedAction extends Action {
public static ID = 'notebookaction.openTemplate';
public static LABEL = nls.localize('notebookaction.renameNotebook', "Rename");
constructor(
@ICommandService private _commandService: ICommandService,
) {
constructor() {
super(RenameNotebookMaterializedAction.ID, RenameNotebookMaterializedAction.LABEL);
}
@@ -737,9 +724,7 @@ export class OpenLatestRunMaterializedNotebook extends Action {
public static ID = 'notebookaction.openLatestRun';
public static LABEL = nls.localize('notebookaction.openLatestRun', "Open Latest Run");
constructor(
@ICommandService private _commandService: ICommandService,
) {
constructor() {
super(OpenLatestRunMaterializedNotebook.ID, OpenLatestRunMaterializedNotebook.LABEL);
}

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { JobManagementService } from 'sql/platform/jobManagement/common/jobManagementService';
import * as assert from 'assert';
// TESTS ///////////////////////////////////////////////////////////////////
suite('Job Management service tests', () => {
@@ -13,5 +14,6 @@ suite('Job Management service tests', () => {
test('Construction - Job Service Initialization', () => {
// ... Create instance of the service and reder account picker
let service = new JobManagementService(undefined);
assert(service);
});
});

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import * as azdata from 'azdata';

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import * as azdata from 'azdata';
import { ILogService } from 'vs/platform/log/common/log';

View File

@@ -78,7 +78,7 @@ export abstract class Task {
private readonly _iconClass?: string;
private readonly _description?: ITaskHandlerDescription;
constructor(private opts: ITaskOptions) {
constructor(opts: ITaskOptions) {
this.id = opts.id;
this.title = opts.title;
if (opts.iconPath) {

View File

@@ -10,7 +10,6 @@ import { ILocalizedString, ICommandAction } from 'vs/platform/actions/common/act
import { Event } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IdGenerator } from 'vs/base/common/idGenerator';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
export interface ITaskOptions {