Skip to content

Commit a87fb7b

Browse files
authored
Address Sonar warnings (#14921)
1 parent f753af1 commit a87fb7b

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

src/client/common/cancellation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export function createPromiseFromCancellation<T>(options: {
3333
return;
3434
}
3535
const complete = () => {
36-
// NOSONAR
37-
if (options.token!.isCancellationRequested) {
36+
const optionsToken = options.token!; // NOSONAR
37+
if (optionsToken.isCancellationRequested) {
3838
if (options.cancelAction === 'resolve') {
3939
return resolve(options.defaultValue);
4040
}

src/client/formatters/yapfFormatter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export class YapfFormatter extends BaseFormatter {
2525
const formatSelection = range ? !range.isEmpty : false;
2626

2727
const yapfArgs = ['--diff'];
28-
if (formatSelection) {
28+
if (formatSelection && range !== undefined) {
2929
// tslint:disable-next-line:no-non-null-assertion
30-
yapfArgs.push(...['--lines', `${range!.start.line + 1}-${range!.end.line + 1}`]);
30+
yapfArgs.push(...['--lines', `${range.start.line + 1}-${range.end.line + 1}`]);
3131
}
3232
// Yapf starts looking for config file starting from the file path.
3333
const fallbarFolder = this.getWorkspaceUri(document).fsPath;

src/client/linters/errorHandlers/standard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class StandardErrorHandler extends BaseErrorHandler {
1313
public async handleError(error: Error, resource: Uri, execInfo: ExecutionInfo): Promise<boolean> {
1414
if (
1515
typeof error === 'string' &&
16-
(error as string).indexOf("OSError: [Errno 2] No such file or directory: '/") > 0
16+
(error as string).includes("OSError: [Errno 2] No such file or directory: '/")
1717
) {
1818
return this.nextHandler ? this.nextHandler.handleError(error, resource, execInfo) : Promise.resolve(false);
1919
}

src/client/pythonEnvironments/discovery/locators/services/condaService.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ export class CondaService implements ICondaService {
130130
if (!this.condaFile) {
131131
this.condaFile = this.getCondaFileImpl();
132132
}
133-
// tslint:disable-next-line:no-unnecessary-local-variable
134-
const condaFile = await this.condaFile!;
135-
return condaFile!;
133+
return (await this.condaFile)!;
136134
}
137135

138136
/**

src/client/terminals/codeExecution/terminalCodeExecution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
4343
await this.getTerminalService(resource).sendText(code);
4444
}
4545
public async initializeRepl(resource?: Uri) {
46-
if (this.replActive && (await this.replActive!)) {
47-
await this._terminalService!.show();
46+
if (this.replActive && (await this.replActive)) {
47+
await this._terminalService.show();
4848
return;
4949
}
5050
this.replActive = new Promise<boolean>(async (resolve) => {

src/client/testing/common/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ export type TestFile = TestingXMLNode & {
129129
export type TestSuite = TestingXMLNode & {
130130
functions: TestFunction[];
131131
suites: TestSuite[];
132-
isUnitTest: Boolean;
133-
isInstance: Boolean;
132+
isUnitTest: boolean;
133+
isInstance: boolean;
134134
};
135135

136136
export type TestFunction = TestingNode & {

0 commit comments

Comments
 (0)