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 additional codeql flagged items #2437

Merged
merged 6 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ describe("Zowe daemon suite", () => {
break;
}
default: {
zoweExeFileNm = "exeForUnknownOs";
zoweExeTgzPath += "unknownOs.tgz";
throw "cli.zowe.daemon.integration.suite.test.ts: beforeAll: " +
sysInfo.platform + " is not a known OS.";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ describe("DaemonDecider tests", () => {

let existTimes;
if (process.platform === "win32") {
existsSyncSpy.mockImplementationOnce;
existTimes = 2;
} else {
existTimes = 3;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Object {
"options": "--workflow-key \\"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\\"",
},
Object {
"description": "To start a workflow instance in z/OSMF with workflow key \\"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\\" and wait forit to be finished",
"description": "To start a workflow instance in z/OSMF with workflow key \\"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\\" and wait for it to be finished",
"options": "--workflow-key \\"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\\" --wait",
},
Object {
"description": "To start a workflow instance in z/OSMF with workflow key \\"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\\"and if there is a conflict in variable's value use the value that is in output file",
"description": "To start a workflow instance in z/OSMF with workflow key \\"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\\" and if there is a conflict in variable's value use the value that is in output file",
"options": "--workflow-key \\"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\\" --resolve-conflict-by \\"outputFileValue\\"",
},
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export const WorkflowFull: ICommandDefinition = {
options: "--workflow-key \"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\""
},
{
description: "To start a workflow instance in z/OSMF with workflow key \"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\" and wait for" +
description: "To start a workflow instance in z/OSMF with workflow key \"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\" and wait for " +
"it to be finished",
options: "--workflow-key \"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\" --wait"
},
{
description: "To start a workflow instance in z/OSMF with workflow key \"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\"" +
description: "To start a workflow instance in z/OSMF with workflow key \"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\" " +
"and if there is a conflict in variable's value use the value that is in output file",
options: "--workflow-key \"d043b5f1-adab-48e7-b7c3-d41cd95fa4b0\" --resolve-conflict-by \"outputFileValue\""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe("Command Response", () => {
});

it("If we create a progress bar, an interval should be set to update the bar. " +
"If we finish the bar, the interval should be stopped and no longer stored" +
"If we finish the bar, the interval should be stopped and no longer stored " +
"in the command response. ", (done) => { // eslint-disable-line jest/no-done-callback
process.env.FORCE_COLOR = "1";
const response = new CommandResponse({ silent: false, responseFormat: "default" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export abstract class AbstractHelpGenerator implements IHelpGenerator {
(alias.length === 1 ? "-" : "--") + alias + "{{codeEnd}}");
}
else {
this.log.warn("The aliases for option " + option.name + " contained a null or empty alias." +
this.log.warn("The aliases for option " + option.name + " contained a null or empty alias. " +
"This has been ignored; please take corrective action in your option definition.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export abstract class AbstractCommandYargs {
tempOpPath = path.substring(0, path.length - "options".length);
if (completeName) {
tempOp = `${completeName} ${value}`;
} else if(topLevelName && !completeName) {
} else if (topLevelName) {
tempOp = `${topLevelName} ${value}`;
} else {
tempOp = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

exports[`DefinitionTreeResolver tests should error with unmatching globs commands 1`] = `"Command module glob for the glob **/bad/glob did not match any files searching from: /random/caller/dir"`;

exports[`DefinitionTreeResolver tests should error without commands 1`] = `"No command definitions have been provided to Imperative. Specify modules and/or definitions on your Imperativeconfiguration."`;
exports[`DefinitionTreeResolver tests should error without commands 1`] = `"No command definitions have been provided to Imperative. Specify modules and/or definitions on your Imperative configuration."`;
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class DefinitionTreeResolver {
if (childrenDefinitions == null && childrenModuleGlobs == null) {
throw new ImperativeError({
msg: "No command definitions have been provided " +
"to Imperative. Specify modules and/or definitions on your Imperative" +
"to Imperative. Specify modules and/or definitions on your Imperative " +
"configuration."
});
} else if (childrenDefinitions == null) {
Expand Down
4 changes: 1 addition & 3 deletions packages/imperative/src/utilities/src/DaemonRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export class DaemonRequest {
* @param {IDaemonRequest} request
* @memberof DaemonRequest
*/
constructor(private request: IDaemonRequest) {
this.request = request;
}
constructor(private request: IDaemonRequest) {}

/**
* Create daemon request from input options
Expand Down
95 changes: 44 additions & 51 deletions packages/zostso/src/IssueTso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class IssueTso {
session,
ZosmfConstants.VERSIONS.V2R4
);
let useNewApi =
const useNewApi =
opts.addressSpaceOptions == null ||
versionCheck && opts.suppressStartupMessages;

Expand Down Expand Up @@ -72,64 +72,57 @@ export class IssueTso {
};
return response;
} catch (e) {
if (e.message?.includes("status 404")) {
// Set useNewApi to false to handle fallback logic
useNewApi = false;
} else {
// Re-throw for other exceptions
if (e.message == null || !e.message.includes("status 404")) {
throw e;
}
}
}
// Deprecated API Behavior [former issueTsoCommand() behavior]
if (!useNewApi) {
TsoValidator.validateSession(session);
TsoValidator.validateNotEmptyString(
opts.addressSpaceOptions?.account,
noAccountNumber.message
);
TsoValidator.validateNotEmptyString(
command as string,
noCommandInput.message
);

const response: IIssueResponse = {
success: false,
startResponse: await StartTso.start(
session,
opts.addressSpaceOptions?.account,
opts.addressSpaceOptions || {}
),
startReady: false,
zosmfResponse: null,
commandResponse: null,
stopResponse: null,
};

if (!response.startResponse.success) {
throw new ImperativeError({
msg: `TSO address space failed to start.`,
additionalDetails:
response.startResponse.failureResponse?.message,
});
}
// Deprecated API Behavior [former issueTsoCommand() behavior]
TsoValidator.validateSession(session);
TsoValidator.validateNotEmptyString(
opts.addressSpaceOptions?.account,
noAccountNumber.message
);
TsoValidator.validateNotEmptyString(
command as string,
noCommandInput.message
);

const sendResponse = await SendTso.sendDataToTSOCollect(
session,
response.startResponse.servletKey,
command as string
);
response.success = sendResponse.success;
response.zosmfResponse = sendResponse.zosmfResponse;
response.commandResponse = sendResponse.commandResponse;
response.stopResponse = await StopTso.stop(
const response: IIssueResponse = {
success: false,
startResponse: await StartTso.start(
session,
response.startResponse.servletKey
);
return response;
} else {
throw "ERROR";
opts.addressSpaceOptions?.account,
opts.addressSpaceOptions || {}
),
startReady: false,
zosmfResponse: null,
commandResponse: null,
stopResponse: null,
};

if (!response.startResponse.success) {
throw new ImperativeError({
msg: `TSO address space failed to start.`,
additionalDetails:
response.startResponse.failureResponse?.message,
});
}

const sendResponse = await SendTso.sendDataToTSOCollect(
session,
response.startResponse.servletKey,
command as string
);
response.success = sendResponse.success;
response.zosmfResponse = sendResponse.zosmfResponse;
response.commandResponse = sendResponse.commandResponse;
response.stopResponse = await StopTso.stop(
session,
response.startResponse.servletKey
);
return response;
}

/**
Expand Down
Loading