Skip to content

Commit 9945361

Browse files
committed
fix: missing null handler errors
1 parent 6c089c9 commit 9945361

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

src/main/rules/MissingNullHandler.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class MissingNullHandler extends AdvancedRule implements core.IRuleDefini
2727
for (const getElement of getOperationElements) {
2828
const elementName = getElement.name;
2929
let nullCheckFound = false;
30-
let resultReferences = [];
30+
let resultReferences: string[] = [];
3131
if (getElement.element["storeOutputAutomatically"]) {
3232
resultReferences = [elementName];
3333
} else if (getElement.element["outputReference"]) {
@@ -39,9 +39,18 @@ export class MissingNullHandler extends AdvancedRule implements core.IRuleDefini
3939
}
4040
}
4141
for (const el of decisionElements) {
42-
const rules = el.element["rules"];
42+
let rules = el.element["rules"];
43+
const isRuleAnArray = Array.isArray(rules);
44+
if (!isRuleAnArray) {
45+
rules = [rules];
46+
}
4347
for (const rule of rules) {
44-
for (const condition of rule.conditions) {
48+
let conditions = rule.conditions;
49+
const isConditionsAnArray = Array.isArray(conditions);
50+
if (!isConditionsAnArray) {
51+
conditions = [conditions];
52+
}
53+
for (const condition of conditions) {
4554
let referenceFound: boolean = false;
4655
let isNullOperator: boolean = false;
4756
let checksIfFalse: boolean = false;
@@ -54,15 +63,19 @@ export class MissingNullHandler extends AdvancedRule implements core.IRuleDefini
5463
}
5564
}
5665
}
57-
if (condition.operator && condition.operator.length > 0) {
66+
if (
67+
condition.operator &&
68+
(!Array.isArray(condition.operator) || condition.operator.length > 0)
69+
) {
5870
const operator = condition.operator;
5971
isNullOperator = operator === "IsNull";
6072
}
6173
if (
6274
condition.rightValue &&
63-
condition.rightValue.length > 0 &&
75+
(!Array.isArray(condition.rightValue) || condition.rightValue.length > 0) &&
6476
condition.rightValue.booleanValue &&
65-
condition.rightValue.booleanValue.length > 0
77+
(!Array.isArray(condition.rightValue.booleanValue) ||
78+
condition.rightValue.booleanValue.length > 0)
6679
) {
6780
const rightValue = condition.rightValue.booleanValue;
6881
checksIfFalse = rightValue.toLowerCase() === "false";

tests/MissingNullHandler.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
import * as core from "../src";
1+
import { describe, expect, it } from "@jest/globals";
22
import * as path from "path";
33

4-
import { describe, it, expect } from "@jest/globals";
4+
import * as core from "../src";
55

66
describe("MissingNullHandler ", () => {
7-
const example_uri = path.join(__dirname, "../example-flows/force-app/main/default/flows/Missing_Null_Handler.flow-meta.xml");
8-
const fixed_uri = path.join(__dirname, "../example-flows/force-app/main/default/flows/Missing_Null_Handler_Fixed.flow-meta.xml");
7+
const example_uri = path.join(
8+
__dirname,
9+
"../example-flows/force-app/main/default/flows/Missing_Null_Handler.flow-meta.xml"
10+
);
11+
const fixed_uri = path.join(
12+
__dirname,
13+
"../example-flows/force-app/main/default/flows/Missing_Null_Handler_Fixed.flow-meta.xml"
14+
);
915

1016
it("should return a result when no fault path is implemented", async () => {
1117
const flows = await core.parse([example_uri]);

0 commit comments

Comments
 (0)