Skip to content

Commit

Permalink
RUles message changes
Browse files Browse the repository at this point in the history
  • Loading branch information
msingh-developer committed Jan 9, 2025
1 parent 8339c8b commit 4c18596
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 109 deletions.
30 changes: 15 additions & 15 deletions docs/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"codes": {
"dv-er-multi-start-001": {
"description": "Multiple start points or floating node(s) found",
"message": "Node % could be one of multiple start points, or floating",
"message": "Flow has multiple start points or a floating node",
"type": "error",
"recommendation": "The '%' node is either disconnected or has multiple starting points. Ensure that the node is correctly connected and has only one starting point.",
"code": "dv-er-multi-start-001"
Expand All @@ -141,21 +141,21 @@
"codes": {
"dv-bp-node-001": {
"description": "All nodes should have a title",
"message": "Missing nodeTitle on node (% - %)",
"message": "Missing node title",
"type": "best-practice",
"recommendation": "The (% %) node is missing a title. For optimal clarity, add a descriptive title.",
"code": "dv-bp-node-001"
},
"dv-bp-node-002": {
"description": "All success/error JSON nodes should proper colors",
"message": "Incorrect node color [%] - %",
"message": "Incorrect node color",
"type": "best-practice",
"recommendation": "The <%> is not using the correct color. To ensure consistency, use the recommended color: [%].",
"recommendation": "The (% %) is not using the correct color. To ensure consistency, use the recommended color: [%].",
"code": "dv-bp-node-002"
},
"dv-bp-node-003": {
"description": "All nodes should have a description",
"message": "Missing Node Description on node (% - %)",
"message": "Missing node description",
"type": "best-practice",
"recommendation": "The (% %) node is missing a description. For optimal clarity, add a meaningful description.",
"code": "dv-bp-node-003"
Expand All @@ -177,9 +177,9 @@
"codes": {
"dv-er-node-001": {
"description": "Disabled Node Found",
"message": "Disabled node % found",
"message": "Disabled node found",
"type": "error",
"recommendation": "A disabled '%' node has been found. Consider removing it from the flow.",
"recommendation": "A disabled (% %) node has been found. Consider removing it from the flow.",
"code": "dv-er-node-001"
},
"dv-er-node-002": {
Expand Down Expand Up @@ -214,21 +214,21 @@
"codes": {
"dv-er-subflow-001": {
"description": "Subflow names mismatched",
"message": "Incorrect or Missing Subflow in (%)",
"message": "Incorrect or missing subflow",
"type": "error",
"recommendation": "There is an incorrect or missing subflow in the (%) flow. Ensure that the appropriate subflow is selected and that the names match within the configuration.",
"code": "dv-er-subflow-001"
},
"dv-er-subflow-002": {
"description": "Circular SubFlow Found",
"message": "Circular SubFlow Dependency Found - '%' points back to '%' via subflow",
"message": "Circular subflow dependency found",
"type": "error",
"recommendation": "In this subflow, '%' points back to '%', which can cause import and export errors. Configure the subflow to return to the parent flow.",
"code": "dv-er-subflow-002"
},
"dv-er-subflow-003": {
"description": "Missing Input schema values",
"message": "Input Schema values for '%' subflow is not configured.",
"message": "Subflow input schema missing",
"type": "error",
"recommendation": "The input schema values for the '%' subflow are not currently configured. Configure the schema in the subflow.",
"code": "dv-er-subflow-003"
Expand All @@ -243,14 +243,14 @@
"codes": {
"dv-er-teleport-001": {
"description": "Unused Teleport Found",
"message": "Teleport '%' found, but never used",
"message": "Unused teleport node found",
"type": "error",
"recommendation": "<%> is not being used. Consider removing it from the flow.",
"code": "dv-er-teleport-001"
},
"dv-er-teleport-002": {
"description": "Teleport schema mismatch",
"message": "Teleport schema mismatch. Attribute '%' found, but not defined",
"message": "Teleport schema mismatch",
"type": "error",
"recommendation": "Update the JSON to align with the Teleport node schema, ensuring that the '%' attribute is properly defined.",
"code": "dv-er-teleport-002"
Expand All @@ -265,14 +265,14 @@
"codes": {
"dv-er-variable-001": {
"description": "Unused Variable Found",
"message": "Variable '%' found, but never used",
"message": "Unused Variable Found",
"type": "error",
"recommendation": "The '%' variable has been found but is not utilized in the flow. Consider removing the unused variable.",
"code": "dv-er-variable-001"
},
"dv-er-variable-002": {
"description": "Variable '%' used, but never defined in a Variable connector",
"message": "Variable '%' used, but never defined in a Variable connector",
"description": "Undefined variable found",
"message": "Undefined variable found",
"type": "error",
"recommendation": "The '%' variable is not defined within a variable connector, which may lead to unexpected behavior. Define the variable appropriately.",
"code": "dv-er-variable-002"
Expand Down
4 changes: 2 additions & 2 deletions rules/dv-rule-multi-start-001/MultiStartRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MultiStartRule extends LintRule {

this.addCode("dv-er-multi-start-001", {
description: "Multiple start points or floating node(s) found",
message: "Node % could be one of multiple start points, or floating",
message: "Flow has multiple start points or a floating node",
type: "error",
recommendation:
"The '%' node is either disconnected or has multiple starting points. Ensure that the node is correctly connected and has only one starting point.",
Expand Down Expand Up @@ -48,8 +48,8 @@ class MultiStartRule extends LintRule {
notTargets.forEach((node) =>
this.addError("dv-er-multi-start-001", {
flowId: flow.flowId,
messageArgs: [`${node.nodeId} (${node.nodeType})`],
recommendationArgs: [`${node.nodeId} (${node.nodeType})`],
nodeId: node.nodeId,
})
);
}
Expand Down
12 changes: 6 additions & 6 deletions rules/dv-rule-multi-start-001/tests/MultiStartRule.expect.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
{
"flowId": "3de5ba439a95765a5a08242546d963d8",
"code": "dv-er-multi-start-001",
"message": "Node v9172ugldd (httpConnector) could be one of multiple start points, or floating",
"message": "Flow has multiple start points or a floating node",
"type": "error",
"recommendation": "The 'v9172ugldd (httpConnector)' node is either disconnected or has multiple starting points. Ensure that the node is correctly connected and has only one starting point."
},
{
"flowId": "3de5ba439a95765a5a08242546d963d8",
"code": "dv-er-multi-start-001",
"message": "Node 20n6fhhgqz (httpConnector) could be one of multiple start points, or floating",
"message": "Flow has multiple start points or a floating node",
"type": "error",
"recommendation": "The '20n6fhhgqz (httpConnector)' node is either disconnected or has multiple starting points. Ensure that the node is correctly connected and has only one starting point."
},
{
"flowId": "3de5ba439a95765a5a08242546d963d8",
"code": "dv-er-multi-start-001",
"message": "Node ilgr9525d6 (httpConnector) could be one of multiple start points, or floating",
"message": "Flow has multiple start points or a floating node",
"type": "error",
"recommendation": "The 'ilgr9525d6 (httpConnector)' node is either disconnected or has multiple starting points. Ensure that the node is correctly connected and has only one starting point."
}
Expand All @@ -48,21 +48,21 @@
{
"flowId": "3de5ba439a95765a5a08242546d963d8",
"code": "dv-er-multi-start-001",
"message": "Node v9172ugldd (httpConnector) could be one of multiple start points, or floating",
"message": "Flow has multiple start points or a floating node",
"type": "error",
"recommendation": "The 'v9172ugldd (httpConnector)' node is either disconnected or has multiple starting points. Ensure that the node is correctly connected and has only one starting point."
},
{
"flowId": "3de5ba439a95765a5a08242546d963d8",
"code": "dv-er-multi-start-001",
"message": "Node 20n6fhhgqz (httpConnector) could be one of multiple start points, or floating",
"message": "Flow has multiple start points or a floating node",
"type": "error",
"recommendation": "The '20n6fhhgqz (httpConnector)' node is either disconnected or has multiple starting points. Ensure that the node is correctly connected and has only one starting point."
},
{
"flowId": "3de5ba439a95765a5a08242546d963d8",
"code": "dv-er-multi-start-001",
"message": "Node ilgr9525d6 (httpConnector) could be one of multiple start points, or floating",
"message": "Flow has multiple start points or a floating node",
"type": "error",
"recommendation": "The 'ilgr9525d6 (httpConnector)' node is either disconnected or has multiple starting points. Ensure that the node is correctly connected and has only one starting point."
}
Expand Down
25 changes: 10 additions & 15 deletions rules/dv-rule-node-001/NodeRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class NodeRule extends LintRule {

this.addCode("dv-bp-node-001", {
description: "All nodes should have a title",
message: "Missing nodeTitle on node (% - %)",
message: "Missing node title",
type: "best-practice",
recommendation: "The (% %) node is missing a title. For optimal clarity, add a descriptive title.",
});
this.addCode("dv-bp-node-002", {
description: "All success/error JSON nodes should proper colors",
message: "Incorrect node color [%] - %",
message: "Incorrect node color",
type: "best-practice",
recommendation: "The <%> is not using the correct color. To ensure consistency, use the recommended color: [%].",
recommendation: "The (% %) is not using the correct color. To ensure consistency, use the recommended color: [%].",
});
this.addCode("dv-bp-node-003", {
description: "All nodes should have a description",
message: "Missing Node Description on node (% - %)",
message: "Missing node description",
type: "best-practice",
recommendation: "The (% %) node is missing a description. For optimal clarity, add a meaningful description.",
});
Expand All @@ -42,33 +42,32 @@ class NodeRule extends LintRule {

runRule() {
try {
const ignoreNodeTypes = ["nodeConnector", "functionsConnector"];
for (const flow of this.allFlows) {
flow?.graphData?.elements?.nodes?.forEach((node) => {
const { data } = node;

// Check for node title
if (
data.nodeType === "CONNECTION" &&
!data.properties?.nodeTitle?.value &&
!(data.capabilityName === 'goToNode' || data.capabilityName === 'returnBackToCallingNode')
!(data.capabilityName === 'goToNode' || data.capabilityName === 'returnBackToCallingNode') &&
!data.properties?.nodeTitle?.value
) {
this.addError("dv-bp-node-001", {
flowId: flow.flowId,
messageArgs: [data.id, data.name],
recommendationArgs: [data.id, data.name],
nodeId: data.id,
});
}

// Check for node description
if (
!ignoreNodeTypes.includes(data.connectorId) &&
data.nodeType === "CONNECTION" &&
!data.properties?.nodeDescription?.value &&
!(data.capabilityName === 'goToNode' || data.capabilityName === 'returnBackToCallingNode')
!data.properties?.nodeDescription?.value
) {
this.addError("dv-bp-node-003", {
flowId: flow.flowId,
messageArgs: [data.id, data.name],
recommendationArgs: [data.id, data.name],
nodeId: data.id,
});
Expand All @@ -88,11 +87,7 @@ class NodeRule extends LintRule {
) {
this.addError("dv-bp-node-002", {
flowId: flow.flowId,
messageArgs: [
data.properties?.backgroundColor?.value.toLowerCase() || '',
`${data.name} (${data.id}) - ${data.capabilityName}`,
],
recommendationArgs: [`${data.name} (${data.id}) - ${data.capabilityName}`, backgroundColor[connectorCapability]],
recommendationArgs: [data.id, data.name, backgroundColor[connectorCapability]],
nodeId: data.id,
});
}
Expand Down
6 changes: 3 additions & 3 deletions rules/dv-rule-node-001/tests/IgnoreRules.expect.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@
{
"flowId": "08c45a026b2f5779afca6d437dce2f49",
"code": "dv-bp-node-003",
"message": "Missing Node Description on node (osyiff3qqw - Variables)",
"message": "Missing node description",
"nodeId": "osyiff3qqw",
"recommendation": "The (osyiff3qqw Variables) node is missing a description. For optimal clarity, add a meaningful description.",
"type": "best-practice"
},
{
"flowId": "08c45a026b2f5779afca6d437dce2f49",
"code": "dv-bp-node-001",
"message": "Missing nodeTitle on node (61te8qo77t - HTTP)",
"message": "Missing node title",
"nodeId": "61te8qo77t",
"recommendation": "The (61te8qo77t HTTP) node is missing a title. For optimal clarity, add a descriptive title.",
"type": "best-practice"
},
{
"flowId": "08c45a026b2f5779afca6d437dce2f49",
"code": "dv-bp-node-003",
"message": "Missing Node Description on node (61te8qo77t - HTTP)",
"message": "Missing node description",
"nodeId": "61te8qo77t",
"recommendation": "The (61te8qo77t HTTP) node is missing a description. For optimal clarity, add a meaningful description.",
"type": "best-practice"
Expand Down
32 changes: 8 additions & 24 deletions rules/dv-rule-node-001/tests/NodeRule.expect.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
{
"name": "PingOne DaVinci Linter",
"pass": false,
"errorCount": 3,
"errorCount": 2,
"rulePackResults": [
{
"pass": false,
"errorCount": 3,
"errorCount": 2,
"lintResults": [
{
"flowId": "47360733f8216ad35114e9a787ca83e0",
"flowName": "Starter Flow",
"pass": false,
"errorCount": 3,
"errorCount": 2,
"errors": [
{
"flowId": "47360733f8216ad35114e9a787ca83e0",
"code": "dv-bp-node-003",
"message": "Missing Node Description on node (4zjizi23c6 - Node)",
"nodeId": "4zjizi23c6",
"recommendation": "The (4zjizi23c6 Node) node is missing a description. For optimal clarity, add a meaningful description.",
"type": "best-practice"
},
{
"flowId": "47360733f8216ad35114e9a787ca83e0",
"code": "dv-bp-node-001",
"message": "Missing nodeTitle on node (13xqy80afe - Http)",
"message": "Missing node title",
"type": "best-practice",
"recommendation": "The (13xqy80afe Http) node is missing a title. For optimal clarity, add a descriptive title.",
"nodeId": "13xqy80afe"
},
{
"flowId": "47360733f8216ad35114e9a787ca83e0",
"code": "dv-bp-node-003",
"message": "Missing Node Description on node (13xqy80afe - Http)",
"message": "Missing node description",
"nodeId": "13xqy80afe",
"recommendation": "The (13xqy80afe Http) node is missing a description. For optimal clarity, add a meaningful description.",
"type": "best-practice"
Expand All @@ -46,28 +38,20 @@
"ruleId": "dv-rule-node-001",
"ruleDescription": "Ensure nodes have names/titles",
"pass": false,
"errorCount": 3,
"errorCount": 2,
"errors": [
{
"flowId": "47360733f8216ad35114e9a787ca83e0",
"code": "dv-bp-node-003",
"message": "Missing Node Description on node (4zjizi23c6 - Node)",
"nodeId": "4zjizi23c6",
"recommendation": "The (4zjizi23c6 Node) node is missing a description. For optimal clarity, add a meaningful description.",
"type": "best-practice"
},
{
"flowId": "47360733f8216ad35114e9a787ca83e0",
"code": "dv-bp-node-001",
"message": "Missing nodeTitle on node (13xqy80afe - Http)",
"message": "Missing node title",
"type": "best-practice",
"recommendation": "The (13xqy80afe Http) node is missing a title. For optimal clarity, add a descriptive title.",
"nodeId": "13xqy80afe"
},
{
"flowId": "47360733f8216ad35114e9a787ca83e0",
"code": "dv-bp-node-003",
"message": "Missing Node Description on node (13xqy80afe - Http)",
"message": "Missing node description",
"nodeId": "13xqy80afe",
"recommendation": "The (13xqy80afe Http) node is missing a description. For optimal clarity, add a meaningful description.",
"type": "best-practice"
Expand Down
7 changes: 3 additions & 4 deletions rules/dv-rule-node-002/DisabledNodeRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class DisabledNodeRule extends LintRule {

this.addCode("dv-er-node-001", {
description: "Disabled Node Found",
message: "Disabled node % found",
message: "Disabled node found",
type: "error",
recommendation: "A disabled '%' node has been found. Consider removing it from the flow.",
recommendation: "A disabled (% %) node has been found. Consider removing it from the flow.",
});
this.addCode("dv-er-node-002", {
description: "Connector Capability not configured",
Expand All @@ -33,8 +33,7 @@ class DisabledNodeRule extends LintRule {
if (data.isDisabled === true) {
this.addError("dv-er-node-001", {
flowId: flow.flowId,
messageArgs: [`(${data.id})`],
recommendationArgs: [`(${data.id})`],
recommendationArgs: [data.id, data.name],
nodeId: data.id,
});
}
Expand Down
Loading

0 comments on commit 4c18596

Please sign in to comment.