Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Coverity code smells in Profiles.ts #3029

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions packages/zowe-explorer/src/Profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ export class Profiles extends ProfilesCache {
await configApi.save();
}

public async handleSwitchAuthentication(node?: IZoweNodeType): Promise<void> {
public async handleSwitchAuthentication(node: IZoweNodeType): Promise<void> {
const qp = Gui.createQuickPick();
const qpItemYes: vscode.QuickPickItem = {
label: localize("Profiles.switchAuthenticationQuickPick.yesLbl", "Yes"),
Expand All @@ -1292,15 +1292,12 @@ export class Profiles extends ProfilesCache {
Gui.infoMessage(localize("profiles.operation.cancelled", "Operation Cancelled"));
return;
}
if (qpSelection.label === localize("Profiles.getSwitchAuthenticationQpItems.noLbl", "No")) return;
if (qpSelection.label === localize("Profiles.getSwitchAuthenticationQpItems.noLbl", "No")) {
return;
}

let loginTokenType: string;
let serviceProfile: zowe.imperative.IProfileLoaded;
if (node) {
serviceProfile = node.getProfile();
} else {
serviceProfile = this.loadNamedProfile(node.label.toString().trim());
}
const serviceProfile = node.getProfile() ?? this.loadNamedProfile(node.label.toString().trim());
const zeInstance = ZoweExplorerApiRegister.getInstance();
try {
loginTokenType = await zeInstance.getCommonApi(serviceProfile).getTokenTypeName();
Expand Down Expand Up @@ -1354,7 +1351,7 @@ export class Profiles extends ProfilesCache {
break;
}
case await ProfilesUtils.isUsingTokenAuth(serviceProfile.name): {
const profile: string | zowe.imperative.IProfileLoaded = node?.getProfile();
const profile: string | zowe.imperative.IProfileLoaded = node.getProfile();
const creds = await Profiles.getInstance().promptCredentials(profile, true);

if (creds != null) {
Expand Down
Loading