diff --git a/src/components/cargo/cargo_manager.ts b/src/components/cargo/cargo_manager.ts index d8ed344..7d56920 100644 --- a/src/components/cargo/cargo_manager.ts +++ b/src/components/cargo/cargo_manager.ts @@ -69,7 +69,7 @@ class UserDefinedArgs { const configuration = getConfiguration(); const args = configuration.get(property); - if (args === undefined) { + if (!args) { throw new Error(`Failed to get args for property=${property}`); } @@ -465,7 +465,7 @@ export default class CargoManager { vscode.window.showQuickPick(playgroundProjectTypes) .then((playgroundProjectType: string | undefined) => { - if (playgroundProjectType === undefined) { + if (!playgroundProjectType) { logger.debug('quick pick has been cancelled'); return; diff --git a/src/components/cargo/custom_configuration_chooser.ts b/src/components/cargo/custom_configuration_chooser.ts index d8f3741..a6333eb 100644 --- a/src/components/cargo/custom_configuration_chooser.ts +++ b/src/components/cargo/custom_configuration_chooser.ts @@ -36,7 +36,7 @@ export default class CustomConfigurationChooser { const customConfigurations = configuration.get(propertyName); - if (customConfigurations === undefined) { + if (!customConfigurations) { throw new Error(`No custom configurations for property=${propertyName}`); } diff --git a/src/components/cargo/diagnostic_utils.ts b/src/components/cargo/diagnostic_utils.ts index 9f6bf28..57b456a 100644 --- a/src/components/cargo/diagnostic_utils.ts +++ b/src/components/cargo/diagnostic_utils.ts @@ -28,7 +28,7 @@ export function addUniqueDiagnostic(diagnostic: FileDiagnostic, diagnostics: Dia const fileDiagnostics = diagnostics.get(uri); - if (fileDiagnostics === undefined) { + if (!fileDiagnostics) { // No diagnostics for the file // The diagnostic is unique diagnostics.set(uri, [diagnostic.diagnostic]); @@ -51,5 +51,5 @@ export function isUniqueDiagnostic(diagnostic: Diagnostic, diagnostics: Diagnost return true; }); - return foundDiagnostic === undefined; + return !foundDiagnostic; } diff --git a/src/components/cargo/output_channel_task_manager.ts b/src/components/cargo/output_channel_task_manager.ts index 5b13a47..7d6dc3d 100644 --- a/src/components/cargo/output_channel_task_manager.ts +++ b/src/components/cargo/output_channel_task_manager.ts @@ -63,7 +63,7 @@ export class OutputChannelTaskManager { * which differs from the directory containing Cargo.toml. */ function prependArgsWithManifestPathIfRequired(): void { - if (cargoCwd === undefined || cargoCwd === cwd) { + if (!cargoCwd || cargoCwd === cwd) { return; } diff --git a/src/components/completion/completion_manager.ts b/src/components/completion/completion_manager.ts index c33e4a9..8f83e23 100644 --- a/src/components/completion/completion_manager.ts +++ b/src/components/completion/completion_manager.ts @@ -233,7 +233,7 @@ export default class CompletionManager { } private stopDaemon(): void { - if (this.racerDaemon === undefined) { + if (!this.racerDaemon) { return; } this.racerDaemon.kill(); @@ -306,7 +306,7 @@ export default class CompletionManager { : results.find(parts => parts[2] === word); // We actually found a completion instead of a definition, so we won't show the returned info. - if (result === undefined) { + if (!result) { return undefined; } @@ -547,7 +547,7 @@ export default class CompletionManager { // Get the first dangling parenthesis, so we don't stop on a function call used as a previous parameter const startPos = this.firstDanglingParen(document, position); - if (startPos === undefined) { + if (!startPos) { return undefined; } @@ -566,7 +566,7 @@ export default class CompletionManager { } } - if (parts === undefined) { + if (!parts) { return undefined; } @@ -654,7 +654,7 @@ export default class CompletionManager { } private runCommand(document: TextDocument, command: string, args: any[]): Promise { - if (this.racerDaemon === undefined) { + if (!this.racerDaemon) { return Promise.reject(undefined); } diff --git a/src/components/configuration/configuration_manager.ts b/src/components/configuration/configuration_manager.ts index e083981..2e7d1fd 100644 --- a/src/components/configuration/configuration_manager.ts +++ b/src/components/configuration/configuration_manager.ts @@ -44,7 +44,7 @@ export class ConfigurationManager { const rlsConfiguration: any | null = configuration['rls']; - if (rlsConfiguration === null) { + if (!rlsConfiguration) { return undefined; } @@ -236,8 +236,8 @@ export class ConfigurationManager { return envPath; } - if (rustcSysRoot === undefined) { - return; + if (!rustcSysRoot) { + return undefined; } if (!rustcSysRoot.includes('.rustup')) { diff --git a/src/components/configuration/current_working_directory_manager.ts b/src/components/configuration/current_working_directory_manager.ts index d39fd6c..83e24f2 100644 --- a/src/components/configuration/current_working_directory_manager.ts +++ b/src/components/configuration/current_working_directory_manager.ts @@ -45,7 +45,7 @@ export default class CurrentWorkingDirectoryManager { } private checkWorkspaceCanBeUsedAsCwd(): Promise { - if (workspace.rootPath === undefined) { + if (!workspace.rootPath) { return Promise.resolve(false); } @@ -61,7 +61,7 @@ export default class CurrentWorkingDirectoryManager { const fileName = window.activeTextEditor.document.fileName; - if (workspace.rootPath === undefined || !fileName.startsWith(workspace.rootPath)) { + if (!workspace.rootPath || !fileName.startsWith(workspace.rootPath)) { return Promise.reject(new Error('Current document not in the workspace')); } @@ -72,11 +72,11 @@ export default class CurrentWorkingDirectoryManager { const opts = { cwd: cwd }; return findUp('Cargo.toml', opts).then((cargoTomlDirPath: string) => { - if (cargoTomlDirPath === null) { + if (!cargoTomlDirPath) { return Promise.reject(new Error('Cargo.toml hasn\'t been found')); } - if (workspace.rootPath === undefined || !cargoTomlDirPath.startsWith(workspace.rootPath)) { + if (!workspace.rootPath || !cargoTomlDirPath.startsWith(workspace.rootPath)) { return Promise.reject(new Error('Cargo.toml hasn\'t been found within the workspace')); } diff --git a/src/components/formatting/formatting_manager.ts b/src/components/formatting/formatting_manager.ts index ebc6ea0..c46a1db 100644 --- a/src/components/formatting/formatting_manager.ts +++ b/src/components/formatting/formatting_manager.ts @@ -99,7 +99,7 @@ export default class FormattingManager implements DocumentFormattingEditProvider currentFile = Uri.file(line.slice('Diff of '.length, -1)); } - if (currentFile === undefined) { + if (!currentFile) { continue; } @@ -177,7 +177,7 @@ export default class FormattingManager implements DocumentFormattingEditProvider continue; } - if (currentPatch === undefined) { + if (!currentPatch) { continue; } diff --git a/src/components/logging/root_logger.ts b/src/components/logging/root_logger.ts index 4190b80..c1ee93d 100644 --- a/src/components/logging/root_logger.ts +++ b/src/components/logging/root_logger.ts @@ -38,7 +38,7 @@ export default class RootLogger extends Logger { } private log(message: string, severityAsString: string): void { - if (this.logFunction === undefined) { + if (!this.logFunction) { return; } diff --git a/src/components/symbol_provision/symbol_information_parser.ts b/src/components/symbol_provision/symbol_information_parser.ts index 8afe23f..390a759 100644 --- a/src/components/symbol_provision/symbol_information_parser.ts +++ b/src/components/symbol_provision/symbol_information_parser.ts @@ -32,7 +32,7 @@ export default class SymbolInformationParser { const symbolInformationList: (SymbolInformation | undefined)[] = rustSymbols.map(rustSymbol => { const kind = this.getSymbolKind(rustSymbol.kind); - if (kind === undefined) { + if (!kind) { return undefined; } diff --git a/src/extension.ts b/src/extension.ts index 0ff2dfc..4188777 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -89,7 +89,7 @@ function addExecutingActionOnSave( const actionOnSave = configurationManager.getActionOnSave(); - if (actionOnSave === null) { + if (!actionOnSave) { return; } diff --git a/test/components/cargo/diagnostic_utils.test.ts b/test/components/cargo/diagnostic_utils.test.ts index ab26578..73942d3 100644 --- a/test/components/cargo/diagnostic_utils.test.ts +++ b/test/components/cargo/diagnostic_utils.test.ts @@ -85,7 +85,7 @@ suite('Diagnostic Utils Tests', () => { const fileDiagnostics = diagnostics.get(Uri.file('/1')); - if (fileDiagnostics === undefined) { + if (!fileDiagnostics) { assert.notEqual(fileDiagnostics, undefined); } else { assert.equal(fileDiagnostics.length, 1); @@ -109,7 +109,7 @@ suite('Diagnostic Utils Tests', () => { const fileDiagnostics = diagnostics.get(Uri.file('/1')); - if (fileDiagnostics === undefined) { + if (!fileDiagnostics) { assert.notEqual(fileDiagnostics, undefined); } else { assert.equal(fileDiagnostics.length, 3); @@ -132,7 +132,7 @@ suite('Diagnostic Utils Tests', () => { const fileDiagnostics = diagnostics.get(Uri.file('/1')); - if (fileDiagnostics === undefined) { + if (!fileDiagnostics) { assert.notEqual(fileDiagnostics, undefined); } else { assert.equal(fileDiagnostics.length, 2);