Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #879 from zowe/fix-code-smells-v1
Browse files Browse the repository at this point in the history
[Backport] Fix code smells
  • Loading branch information
zFernand0 authored Aug 29, 2022
2 parents 2d15654 + 7eff9cd commit 5cf170b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions packages/cmd/src/profiles/CliProfileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class CliProfileManager extends BasicProfileManager<ICommandProfileTypeCo
name,
failNotFound: true,
loadDependencies: false,
noSecure: (params != null) ? params.noSecure : undefined
noSecure: params.noSecure
}));
}
} else {
Expand Down Expand Up @@ -343,7 +343,7 @@ export class CliProfileManager extends BasicProfileManager<ICommandProfileTypeCo
* @returns {Promise<any>} Processed version of a property
*/
private async findOptions(prop: ICommandProfileProperty, propNamePath: string, propValue: any, secureOp?: SecureOperationFunction): Promise<any> {
if (!isNullOrUndefined(prop.optionDefinition)) {
if (prop.optionDefinition != null) {
// once we reach a property with an option definition,
// we now have the complete path to the property
// so we will set the value on the property from the profile
Expand All @@ -353,12 +353,12 @@ export class CliProfileManager extends BasicProfileManager<ICommandProfileTypeCo
this.log.debug("Performing secure operation on property %s", propNamePath);
return secureOp(propNamePath, propValue, !prop.optionDefinition.required);
}
return propValue;
return Promise.resolve(propValue);
}
if (!isNullOrUndefined(prop.properties)) {
if (prop.properties != null) {
if (secureOp && prop.secure) {
if (!propValue || Object.keys(propValue).length === 0) { // prevents from performing operations on empty objects
return null;
return Promise.resolve(null);
}

this.log.debug("Performing secure operation on property %s", propNamePath);
Expand All @@ -370,15 +370,15 @@ export class CliProfileManager extends BasicProfileManager<ICommandProfileTypeCo
await this.findOptions(
prop.properties[childPropertyName],
propNamePath + "." + childPropertyName,
(!isNullOrUndefined(propValue) && !isNullOrUndefined(propValue[childPropertyName])) ?
(propValue != null && propValue[childPropertyName] != null) ?
JSON.parse(JSON.stringify(propValue[childPropertyName])) : null,
secureOp
);
}
return tempProperties;
return Promise.resolve(tempProperties);
}

return propValue;
return Promise.resolve(propValue);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/cmd/src/response/CommandResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class CommandResponse implements ICommandResponseApi {
ImperativeExpect.toBeOneOf(this.mResponseFormat, formats,
`${CommandResponse.RESPONSE_ERR_TAG} Response format invalid. Valid formats: "${formats.join(",")}"`);
this.mSilent = (this.mControl.silent == null) ? false : this.mControl.silent;
this.mProgressBarSpinnerChars = (this.mControl.progressBarSpinner == null) ? this.mProgressBarSpinnerChars : params.progressBarSpinner;
this.mProgressBarSpinnerChars = (this.mControl.progressBarSpinner == null) ? this.mProgressBarSpinnerChars : this.mControl.progressBarSpinner;
}

get format(): IHandlerFormatOutputApi {
Expand Down

0 comments on commit 5cf170b

Please sign in to comment.