Skip to content

Commit 93e99cd

Browse files
Fix linting in debugger files
1 parent 5a1fb3f commit 93e99cd

File tree

13 files changed

+107
-85
lines changed

13 files changed

+107
-85
lines changed

src/client/debugger/extension/configuration/debugConfigurationService.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { IDebugConfigurationResolver } from './types';
2828
@injectable()
2929
export class PythonDebugConfigurationService implements IDebugConfigurationService {
3030
private cacheDebugConfig: DebugConfiguration | undefined = undefined;
31+
3132
constructor(
3233
@inject(IDebugConfigurationResolver)
3334
@named('attach')
@@ -47,13 +48,12 @@ export class PythonDebugConfigurationService implements IDebugConfigurationServi
4748

4849
// Disabled until configuration issues are addressed by VS Code. See #4007
4950
const multiStep = this.multiStepFactory.create<DebugConfigurationState>();
50-
await multiStep.run((input, s) => this.pickDebugConfiguration(input, s), state);
51+
await multiStep.run((input, s) => PythonDebugConfigurationService.pickDebugConfiguration(input, s), state);
5152

52-
if (Object.keys(state.config).length === 0) {
53-
return;
54-
} else {
53+
if (Object.keys(state.config).length !== 0) {
5554
return [state.config as DebugConfiguration];
5655
}
56+
return undefined;
5757
}
5858

5959
public async resolveDebugConfiguration(
@@ -67,7 +67,8 @@ export class PythonDebugConfigurationService implements IDebugConfigurationServi
6767
debugConfiguration as AttachRequestArguments,
6868
token,
6969
);
70-
} else if (debugConfiguration.request === 'test') {
70+
}
71+
if (debugConfiguration.request === 'test') {
7172
// `"request": "test"` is now deprecated. But some users might have it in their
7273
// launch config. We get here if they triggered it using F5 or start with debugger.
7374
throw Error(
@@ -80,9 +81,10 @@ export class PythonDebugConfigurationService implements IDebugConfigurationServi
8081
} else {
8182
const configs = await this.provideDebugConfigurations(folder, token);
8283
if (configs === undefined) {
83-
return;
84+
return undefined;
8485
}
8586
if (Array.isArray(configs) && configs.length === 1) {
87+
// eslint-disable-next-line prefer-destructuring
8688
debugConfiguration = configs[0];
8789
}
8890
this.cacheDebugConfig = cloneDeep(debugConfiguration);
@@ -107,7 +109,8 @@ export class PythonDebugConfigurationService implements IDebugConfigurationServi
107109
return debugConfiguration.request === 'attach' ? resolve(this.attachResolver) : resolve(this.launchResolver);
108110
}
109111

110-
protected async pickDebugConfiguration(
112+
// eslint-disable-next-line consistent-return
113+
protected static async pickDebugConfiguration(
111114
input: MultiStepInput<DebugConfigurationState>,
112115
state: DebugConfigurationState,
113116
): Promise<InputStep<DebugConfigurationState> | void> {
@@ -178,7 +181,7 @@ export class PythonDebugConfigurationService implements IDebugConfigurationServi
178181
title: DebugConfigStrings.selectConfiguration.title,
179182
placeholder: DebugConfigStrings.selectConfiguration.placeholder,
180183
activeItem: items[0],
181-
items: items,
184+
items,
182185
});
183186
if (pick) {
184187
const pickedDebugConfiguration = debugConfigurations.get(pick.type)!;

src/client/debugger/extension/configuration/providers/djangoLaunch.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const workspaceFolderToken = '${workspaceFolder}';
2020
export async function buildDjangoLaunchDebugConfiguration(
2121
input: MultiStepInput<DebugConfigurationState>,
2222
state: DebugConfigurationState,
23-
) {
23+
): Promise<void> {
2424
const program = await getManagePyPath(state.folder);
2525
let manuallyEnteredAValue: boolean | undefined;
2626
const defaultProgram = `${workspaceFolderToken}${path.sep}manage.py`;
@@ -73,15 +73,16 @@ export async function validateManagePy(
7373
return error;
7474
}
7575
}
76-
return;
76+
return undefined;
7777
}
7878

7979
export async function getManagePyPath(folder: vscode.WorkspaceFolder | undefined): Promise<string | undefined> {
8080
if (!folder) {
81-
return;
81+
return undefined;
8282
}
8383
const defaultLocationOfManagePy = path.join(folder.uri.fsPath, 'manage.py');
8484
if (await fs.pathExists(defaultLocationOfManagePy)) {
8585
return `${workspaceFolderToken}${path.sep}manage.py`;
8686
}
87+
return undefined;
8788
}

src/client/debugger/extension/configuration/providers/fastapiLaunch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { DebugConfigurationState, DebugConfigurationType } from '../../types';
1717
export async function buildFastAPILaunchDebugConfiguration(
1818
input: MultiStepInput<DebugConfigurationState>,
1919
state: DebugConfigurationState,
20-
) {
20+
): Promise<void> {
2121
const application = await getApplicationPath(state.folder);
2222
let manuallyEnteredAValue: boolean | undefined;
2323
const config: Partial<LaunchRequestArguments> = {
@@ -57,10 +57,11 @@ export async function buildFastAPILaunchDebugConfiguration(
5757
}
5858
export async function getApplicationPath(folder: WorkspaceFolder | undefined): Promise<string | undefined> {
5959
if (!folder) {
60-
return;
60+
return undefined;
6161
}
6262
const defaultLocationOfManagePy = path.join(folder.uri.fsPath, 'main.py');
6363
if (await fs.pathExists(defaultLocationOfManagePy)) {
6464
return 'main.py';
6565
}
66+
return undefined;
6667
}

src/client/debugger/extension/configuration/providers/fileLaunch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DebugConfigurationState, DebugConfigurationType } from '../../types';
1414
export async function buildFileLaunchDebugConfiguration(
1515
_input: MultiStepInput<DebugConfigurationState>,
1616
state: DebugConfigurationState,
17-
) {
17+
): Promise<void> {
1818
const config: Partial<LaunchRequestArguments> = {
1919
name: DebugConfigStrings.file.snippet.name,
2020
type: DebuggerTypeName,

src/client/debugger/extension/configuration/providers/flaskLaunch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { DebugConfigurationState, DebugConfigurationType } from '../../types';
1717
export async function buildFlaskLaunchDebugConfiguration(
1818
input: MultiStepInput<DebugConfigurationState>,
1919
state: DebugConfigurationState,
20-
) {
20+
): Promise<void> {
2121
const application = await getApplicationPath(state.folder);
2222
let manuallyEnteredAValue: boolean | undefined;
2323
const config: Partial<LaunchRequestArguments> = {
@@ -61,10 +61,11 @@ export async function buildFlaskLaunchDebugConfiguration(
6161
}
6262
export async function getApplicationPath(folder: WorkspaceFolder | undefined): Promise<string | undefined> {
6363
if (!folder) {
64-
return;
64+
return undefined;
6565
}
6666
const defaultLocationOfManagePy = path.join(folder.uri.fsPath, 'app.py');
6767
if (await fs.pathExists(defaultLocationOfManagePy)) {
6868
return 'app.py';
6969
}
70+
return undefined;
7071
}

src/client/debugger/extension/configuration/providers/moduleLaunch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DebugConfigurationState, DebugConfigurationType } from '../../types';
1414
export async function buildModuleLaunchConfiguration(
1515
input: MultiStepInput<DebugConfigurationState>,
1616
state: DebugConfigurationState,
17-
) {
17+
): Promise<void> {
1818
let manuallyEnteredAValue: boolean | undefined;
1919
const config: Partial<LaunchRequestArguments> = {
2020
name: DebugConfigStrings.module.snippet.name,

src/client/debugger/extension/configuration/providers/pidAttach.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DebugConfigurationState, DebugConfigurationType } from '../../types';
1414
export async function buildPidAttachConfiguration(
1515
_input: MultiStepInput<DebugConfigurationState>,
1616
state: DebugConfigurationState,
17-
) {
17+
): Promise<void> {
1818
const config: Partial<AttachRequestArguments> = {
1919
name: DebugConfigStrings.attachPid.snippet.name,
2020
type: DebuggerTypeName,

src/client/debugger/extension/configuration/providers/pyramidLaunch.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import * as path from 'path';
77
import * as fs from 'fs-extra';
88
import { WorkspaceFolder } from 'vscode';
9+
import * as nls from 'vscode-nls';
910
import { DebugConfigStrings } from '../../../../common/utils/localize';
1011
import { MultiStepInput } from '../../../../common/utils/multiStepInput';
1112
import { sendTelemetryEvent } from '../../../../telemetry';
1213
import { EventName } from '../../../../telemetry/constants';
1314
import { DebuggerTypeName } from '../../../constants';
1415
import { LaunchRequestArguments } from '../../../types';
1516
import { DebugConfigurationState, DebugConfigurationType } from '../../types';
16-
import * as nls from 'vscode-nls';
1717
import { resolveVariables } from '../utils/common';
1818

1919
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
@@ -23,7 +23,7 @@ const workspaceFolderToken = '${workspaceFolder}';
2323
export async function buildPyramidLaunchConfiguration(
2424
input: MultiStepInput<DebugConfigurationState>,
2525
state: DebugConfigurationState,
26-
) {
26+
): Promise<void> {
2727
const iniPath = await getDevelopmentIniPath(state.folder);
2828
const defaultIni = `${workspaceFolderToken}${path.sep}development.ini`;
2929
let manuallyEnteredAValue: boolean | undefined;
@@ -70,7 +70,7 @@ export async function validateIniPath(
7070
selected?: string,
7171
): Promise<string | undefined> {
7272
if (!folder) {
73-
return;
73+
return undefined;
7474
}
7575
const error = DebugConfigStrings.pyramid.enterDevelopmentIniPath.invalid;
7676
if (!selected || selected.trim().length === 0) {
@@ -85,14 +85,16 @@ export async function validateIniPath(
8585
return error;
8686
}
8787
}
88+
return undefined;
8889
}
8990

9091
export async function getDevelopmentIniPath(folder: WorkspaceFolder | undefined): Promise<string | undefined> {
9192
if (!folder) {
92-
return;
93+
return undefined;
9394
}
9495
const defaultLocationOfManagePy = path.join(folder.uri.fsPath, 'development.ini');
9596
if (await fs.pathExists(defaultLocationOfManagePy)) {
9697
return `${workspaceFolderToken}${path.sep}development.ini`;
9798
}
99+
return undefined;
98100
}

src/client/debugger/extension/configuration/resolvers/attach.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
1616
debugConfiguration: AttachRequestArguments,
1717
_token?: CancellationToken,
1818
): Promise<AttachRequestArguments | undefined> {
19-
const workspaceFolder = this.getWorkspaceFolder(folder);
19+
const workspaceFolder = AttachConfigurationResolver.getWorkspaceFolder(folder);
2020

2121
await this.provideAttachDefaults(workspaceFolder, debugConfiguration as AttachRequestArguments);
2222

@@ -49,41 +49,41 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
4949
debugConfiguration.workspaceFolder = workspaceFolder ? workspaceFolder.fsPath : undefined;
5050
const debugOptions = debugConfiguration.debugOptions!;
5151
if (!debugConfiguration.justMyCode) {
52-
this.debugOption(debugOptions, DebugOptions.DebugStdLib);
52+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.DebugStdLib);
5353
}
5454
if (debugConfiguration.django) {
55-
this.debugOption(debugOptions, DebugOptions.Django);
55+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.Django);
5656
}
5757
if (debugConfiguration.jinja) {
58-
this.debugOption(debugOptions, DebugOptions.Jinja);
58+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.Jinja);
5959
}
6060
if (debugConfiguration.subProcess === true) {
61-
this.debugOption(debugOptions, DebugOptions.SubProcess);
61+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.SubProcess);
6262
}
6363
if (
6464
debugConfiguration.pyramid &&
6565
debugOptions.indexOf(DebugOptions.Jinja) === -1 &&
6666
debugConfiguration.jinja !== false
6767
) {
68-
this.debugOption(debugOptions, DebugOptions.Jinja);
68+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.Jinja);
6969
}
7070
if (debugConfiguration.redirectOutput || debugConfiguration.redirectOutput === undefined) {
71-
this.debugOption(debugOptions, DebugOptions.RedirectOutput);
71+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.RedirectOutput);
7272
}
7373

7474
// We'll need paths to be fixed only in the case where local and remote hosts are the same
7575
// I.e. only if hostName === 'localhost' or '127.0.0.1' or ''
76-
const isLocalHost = this.isLocalHost(debugConfiguration.host);
77-
if (getOSType() == OSType.Windows && isLocalHost) {
78-
this.debugOption(debugOptions, DebugOptions.FixFilePathCase);
76+
const isLocalHost = AttachConfigurationResolver.isLocalHost(debugConfiguration.host);
77+
if (getOSType() === OSType.Windows && isLocalHost) {
78+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.FixFilePathCase);
7979
}
80-
if (getOSType() == OSType.Windows) {
81-
this.debugOption(debugOptions, DebugOptions.WindowsClient);
80+
if (getOSType() === OSType.Windows) {
81+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.WindowsClient);
8282
} else {
83-
this.debugOption(debugOptions, DebugOptions.UnixClient);
83+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.UnixClient);
8484
}
8585
if (debugConfiguration.showReturnValue) {
86-
this.debugOption(debugOptions, DebugOptions.ShowReturnValue);
86+
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.ShowReturnValue);
8787
}
8888

8989
debugConfiguration.pathMappings = this.resolvePathMappings(
@@ -93,9 +93,10 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
9393
debugConfiguration.remoteRoot,
9494
workspaceFolder,
9595
);
96-
this.sendTelemetry('attach', debugConfiguration);
96+
AttachConfigurationResolver.sendTelemetry('attach', debugConfiguration);
9797
}
9898

99+
// eslint-disable-next-line class-methods-use-this
99100
private resolvePathMappings(
100101
pathMappings: PathMapping[],
101102
host?: string,
@@ -106,13 +107,16 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
106107
// This is for backwards compatibility.
107108
if (localRoot && remoteRoot) {
108109
pathMappings.push({
109-
localRoot: localRoot,
110-
remoteRoot: remoteRoot,
110+
localRoot,
111+
remoteRoot,
111112
});
112113
}
113114
// If attaching to local host, then always map local root and remote roots.
114-
if (this.isLocalHost(host)) {
115-
pathMappings = this.fixUpPathMappings(pathMappings, workspaceFolder ? workspaceFolder.fsPath : '');
115+
if (AttachConfigurationResolver.isLocalHost(host)) {
116+
pathMappings = AttachConfigurationResolver.fixUpPathMappings(
117+
pathMappings,
118+
workspaceFolder ? workspaceFolder.fsPath : '',
119+
);
116120
}
117121
return pathMappings.length > 0 ? pathMappings : undefined;
118122
}

0 commit comments

Comments
 (0)