From fc799e3beeae992921d01131bb53ebcd8e30fe7b Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Thu, 14 Nov 2024 10:31:49 -0500 Subject: [PATCH] Fix Coverity code smells in V3 (#3312) * Fix Coverity code smells in V3 Signed-off-by: Timothy Johnson * Improve error handling in case profile is undefined Signed-off-by: Timothy Johnson --------- Signed-off-by: Timothy Johnson Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> --- packages/zowe-explorer-api/src/fs/BaseProvider.ts | 2 +- .../zowe-explorer/src/trees/dataset/DatasetFSProvider.ts | 8 ++++---- packages/zowe-explorer/src/trees/uss/UssFSProvider.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/zowe-explorer-api/src/fs/BaseProvider.ts b/packages/zowe-explorer-api/src/fs/BaseProvider.ts index f68682f2d3..63d534fc30 100644 --- a/packages/zowe-explorer-api/src/fs/BaseProvider.ts +++ b/packages/zowe-explorer-api/src/fs/BaseProvider.ts @@ -428,7 +428,7 @@ export class BaseProvider { }) .then(async ({ userResponse }) => { if (userResponse === "Retry" && opts?.retry?.fn != null) { - await opts.retry.fn(...(opts?.retry.args ?? [])); + await opts.retry.fn(...(opts.retry.args ?? [])); } }) .catch(() => { diff --git a/packages/zowe-explorer/src/trees/dataset/DatasetFSProvider.ts b/packages/zowe-explorer/src/trees/dataset/DatasetFSProvider.ts index 52586182be..c15105bb33 100644 --- a/packages/zowe-explorer/src/trees/dataset/DatasetFSProvider.ts +++ b/packages/zowe-explorer/src/trees/dataset/DatasetFSProvider.ts @@ -605,12 +605,12 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem comment: ["Data set name"], }), apiType: ZoweExplorerApiType.Mvs, - profileType: entry.metadata.profile.type, + profileType: entry.metadata.profile?.type, retry: { fn: this.writeFile.bind(this), args: [uri, content, options], }, - templateArgs: { profileName: entry.metadata.profile.name ?? "" }, + templateArgs: { profileName: entry.metadata.profile?.name ?? "" }, }); throw err; } @@ -664,7 +664,7 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem comment: ["File path"], }), apiType: ZoweExplorerApiType.Mvs, - profileType: entry.metadata.profile.type, + profileType: entry.metadata.profile?.type, retry: { fn: this.delete.bind(this), args: [uri, _options], @@ -711,7 +711,7 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem comment: ["Data set name"], }), apiType: ZoweExplorerApiType.Mvs, - profileType: entry.metadata.profile.type, + profileType: entry.metadata.profile?.type, retry: { fn: this.rename.bind(this), args: [oldUri, newUri, options], diff --git a/packages/zowe-explorer/src/trees/uss/UssFSProvider.ts b/packages/zowe-explorer/src/trees/uss/UssFSProvider.ts index eb39b7d214..fdcf270245 100644 --- a/packages/zowe-explorer/src/trees/uss/UssFSProvider.ts +++ b/packages/zowe-explorer/src/trees/uss/UssFSProvider.ts @@ -501,8 +501,8 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv fn: this.writeFile.bind(this), args: [uri, content, options], }, - profileType: parentDir.metadata.profile.type, - templateArgs: { profileName: parentDir.metadata.profile.name ?? "" }, + profileType: parentDir.metadata.profile?.type, + templateArgs: { profileName: parentDir.metadata.profile?.name ?? "" }, }); throw err; } @@ -611,8 +611,8 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv args: [uri, _options], }, apiType: ZoweExplorerApiType.Uss, - profileType: parent.metadata.profile.type, - templateArgs: { profileName: parent.metadata.profile.name ?? "" }, + profileType: parent.metadata.profile?.type, + templateArgs: { profileName: parent.metadata.profile?.name ?? "" }, }); throw err; }