@flow-scanner/lightning-flow-scanner-core 6.4.2 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +51 -14
  2. package/index.d.ts +4 -3
  3. package/index.js +4 -4
  4. package/main/interfaces/IRulesConfig.d.ts +6 -0
  5. package/main/interfaces/IRulesConfig.js +11 -0
  6. package/main/internals/internals.d.ts +6 -5
  7. package/main/internals/internals.js +11 -7
  8. package/main/libs/GetRuleDefinitions.d.ts +1 -1
  9. package/main/libs/GetRuleDefinitions.js +5 -6
  10. package/main/libs/ScanFlows.js +29 -3
  11. package/main/libs/exportAsDetails.d.ts +2 -15
  12. package/main/libs/exportAsDetails.js +69 -26
  13. package/main/libs/exportAsSarif.js +19 -18
  14. package/main/models/FlatViolation.d.ts +7 -0
  15. package/main/models/Flow.d.ts +18 -10
  16. package/main/models/Flow.js +82 -61
  17. package/main/models/LoopRuleCommon.d.ts +2 -2
  18. package/main/models/LoopRuleCommon.js +8 -10
  19. package/main/models/RuleCommon.d.ts +14 -2
  20. package/main/models/RuleCommon.js +16 -3
  21. package/main/models/RuleResult.d.ts +3 -3
  22. package/main/models/ScanResult.d.ts +1 -1
  23. package/main/models/Violation.d.ts +12 -0
  24. package/main/models/Violation.js +101 -0
  25. package/main/rules/APIVersion.d.ts +3 -3
  26. package/main/rules/APIVersion.js +20 -24
  27. package/main/rules/ActionCallsInLoop.js +1 -1
  28. package/main/rules/AutoLayout.d.ts +1 -3
  29. package/main/rules/AutoLayout.js +10 -20
  30. package/main/rules/CopyAPIName.d.ts +1 -1
  31. package/main/rules/CopyAPIName.js +4 -13
  32. package/main/rules/CyclomaticComplexity.d.ts +4 -4
  33. package/main/rules/CyclomaticComplexity.js +19 -27
  34. package/main/rules/DuplicateDMLOperation.d.ts +2 -2
  35. package/main/rules/DuplicateDMLOperation.js +53 -56
  36. package/main/rules/FlowDescription.d.ts +1 -1
  37. package/main/rules/FlowDescription.js +8 -12
  38. package/main/rules/FlowName.d.ts +2 -2
  39. package/main/rules/FlowName.js +12 -18
  40. package/main/rules/GetRecordAllFields.d.ts +1 -1
  41. package/main/rules/GetRecordAllFields.js +11 -21
  42. package/main/rules/HardcodedId.d.ts +1 -1
  43. package/main/rules/HardcodedId.js +4 -15
  44. package/main/rules/HardcodedUrl.d.ts +2 -2
  45. package/main/rules/HardcodedUrl.js +4 -17
  46. package/main/rules/InactiveFlow.d.ts +1 -1
  47. package/main/rules/InactiveFlow.js +7 -10
  48. package/main/rules/MissingFaultPath.d.ts +1 -1
  49. package/main/rules/MissingFaultPath.js +22 -24
  50. package/main/rules/MissingNullHandler.d.ts +1 -1
  51. package/main/rules/MissingNullHandler.js +67 -70
  52. package/main/rules/ProcessBuilder.d.ts +1 -3
  53. package/main/rules/ProcessBuilder.js +4 -8
  54. package/main/rules/RecursiveAfterUpdate.d.ts +1 -1
  55. package/main/rules/RecursiveAfterUpdate.js +29 -31
  56. package/main/rules/SameRecordFieldUpdates.d.ts +1 -1
  57. package/main/rules/SameRecordFieldUpdates.js +15 -21
  58. package/main/rules/TriggerOrder.d.ts +1 -1
  59. package/main/rules/TriggerOrder.js +8 -13
  60. package/main/rules/UnconnectedElement.d.ts +1 -1
  61. package/main/rules/UnconnectedElement.js +12 -15
  62. package/main/rules/UnsafeRunningContext.d.ts +1 -1
  63. package/main/rules/UnsafeRunningContext.js +12 -13
  64. package/main/rules/UnusedVariable.d.ts +1 -1
  65. package/main/rules/UnusedVariable.js +23 -27
  66. package/main/store/DefaultRuleStore.js +2 -3
  67. package/package.json +6 -7
  68. package/main/interfaces/AutoFixable.d.ts +0 -10
  69. package/main/models/ResultDetails.d.ts +0 -10
  70. package/main/models/ResultDetails.js +0 -57
  71. /package/main/{interfaces/AutoFixable.js → models/FlatViolation.js} +0 -0
@@ -65,33 +65,25 @@ function _interop_require_wildcard(obj, nodeInterop) {
65
65
  return newObj;
66
66
  }
67
67
  let CyclomaticComplexity = class CyclomaticComplexity extends _RuleCommon.RuleCommon {
68
- execute(flow, options, suppressions = []) {
69
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
70
- var _flow_elements, _flow_elements1;
71
- const threshold = (options === null || options === void 0 ? void 0 : options.threshold) || this.defaultThreshold;
72
- let cyclomaticComplexity = 1;
73
- const flowDecisions = flow === null || flow === void 0 ? void 0 : (_flow_elements = flow.elements) === null || _flow_elements === void 0 ? void 0 : _flow_elements.filter((node)=>node.subtype === "decisions");
74
- const flowLoops = flow === null || flow === void 0 ? void 0 : (_flow_elements1 = flow.elements) === null || _flow_elements1 === void 0 ? void 0 : _flow_elements1.filter((node)=>node.subtype === "loops");
75
- for (const decision of flowDecisions || []){
76
- const rules = decision.element["rules"];
77
- if (Array.isArray(rules)) {
78
- cyclomaticComplexity += rules.length + 1;
79
- } else {
80
- cyclomaticComplexity += 1;
81
- }
82
- }
83
- var _flowLoops_length;
84
- cyclomaticComplexity += (_flowLoops_length = flowLoops === null || flowLoops === void 0 ? void 0 : flowLoops.length) !== null && _flowLoops_length !== void 0 ? _flowLoops_length : 0;
85
- this.cyclomaticComplexityUnit = cyclomaticComplexity;
86
- const results = [];
87
- if (cyclomaticComplexity > threshold) {
88
- const detail = new _internals.ResultDetails(new _internals.FlowAttribute(`${cyclomaticComplexity}`, "CyclomaticComplexity", `>${threshold}`));
89
- if (!suppSet.has(detail.name)) {
90
- results.push(detail);
91
- }
92
- }
93
- return new _internals.RuleResult(this, results);
94
- });
68
+ check(flow, options) {
69
+ var _flow_elements, _flow_elements1;
70
+ const threshold = (options === null || options === void 0 ? void 0 : options.threshold) || this.defaultThreshold;
71
+ let cyclomaticComplexity = 1;
72
+ const flowDecisions = flow === null || flow === void 0 ? void 0 : (_flow_elements = flow.elements) === null || _flow_elements === void 0 ? void 0 : _flow_elements.filter((node)=>node.subtype === "decisions");
73
+ const flowLoops = flow === null || flow === void 0 ? void 0 : (_flow_elements1 = flow.elements) === null || _flow_elements1 === void 0 ? void 0 : _flow_elements1.filter((node)=>node.subtype === "loops");
74
+ for (const decision of flowDecisions || []){
75
+ const rules = decision.element["rules"];
76
+ cyclomaticComplexity += Array.isArray(rules) ? rules.length + 1 : 1;
77
+ }
78
+ var _flowLoops_length;
79
+ cyclomaticComplexity += (_flowLoops_length = flowLoops === null || flowLoops === void 0 ? void 0 : flowLoops.length) !== null && _flowLoops_length !== void 0 ? _flowLoops_length : 0;
80
+ this.cyclomaticComplexityUnit = cyclomaticComplexity;
81
+ if (cyclomaticComplexity > threshold) {
82
+ return [
83
+ new _internals.Violation(new _internals.FlowAttribute(`${cyclomaticComplexity}`, "CyclomaticComplexity", `>${threshold}`))
84
+ ];
85
+ }
86
+ return [];
95
87
  }
96
88
  constructor(){
97
89
  super({
@@ -3,7 +3,7 @@ import { RuleCommon } from "../models/RuleCommon";
3
3
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
4
  export declare class DuplicateDMLOperation extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
7
- private flagDML;
6
+ protected check(flow: core.Flow, _options: object | undefined, suppressions: Set<string>): core.Violation[];
8
7
  private findStart;
8
+ private flagDML;
9
9
  }
@@ -52,64 +52,69 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
52
  return newObj;
53
53
  }
54
54
  let DuplicateDMLOperation = class DuplicateDMLOperation extends _RuleCommon.RuleCommon {
55
- execute(flow, options, suppressions = []) {
56
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
57
- const flowElements = flow.elements.filter((node)=>node instanceof _internals.FlowNode);
58
- const processedElementIndexes = [];
59
- const unconnectedElementIndexes = [];
60
- const DuplicateDMLOperations = [];
61
- const startingNode = this.findStart(flow);
62
- if (startingNode === -1) {
63
- return new _internals.RuleResult(this, []);
64
- }
65
- let dmlFlag = false;
66
- let indexesToProcess = [
67
- startingNode
68
- ];
69
- do {
70
- indexesToProcess = indexesToProcess.filter((index)=>!processedElementIndexes.includes(index));
71
- if (indexesToProcess.length > 0) {
72
- for (const [index, element] of flowElements.entries()){
73
- if (indexesToProcess.includes(index)) {
74
- const references = [];
75
- if (element.connectors && element.connectors.length > 0) {
76
- for (const connector of element.connectors){
77
- if (connector.reference) {
78
- references.push(connector.reference);
79
- }
55
+ check(flow, _options, suppressions) {
56
+ const flowElements = flow.elements.filter((node)=>node instanceof _internals.FlowNode);
57
+ const processedElementIndexes = [];
58
+ const unconnectedElementIndexes = [];
59
+ const DuplicateDMLOperations = [];
60
+ const startingNode = this.findStart(flow);
61
+ if (startingNode === -1) {
62
+ return [];
63
+ }
64
+ let dmlFlag = false;
65
+ let indexesToProcess = [
66
+ startingNode
67
+ ];
68
+ do {
69
+ indexesToProcess = indexesToProcess.filter((index)=>!processedElementIndexes.includes(index));
70
+ if (indexesToProcess.length > 0) {
71
+ for (const [index, element] of flowElements.entries()){
72
+ if (indexesToProcess.includes(index)) {
73
+ const references = [];
74
+ if (element.connectors && element.connectors.length > 0) {
75
+ for (const connector of element.connectors){
76
+ if (connector.reference) {
77
+ references.push(connector.reference);
80
78
  }
81
79
  }
82
- dmlFlag = this.flagDML(element, dmlFlag);
83
- if (references.length > 0) {
84
- const elementsByReferences = flowElements.filter((el)=>references.includes(el.name));
85
- for (const nextElement of elementsByReferences){
86
- const nextIndex = flowElements.findIndex((el)=>nextElement.name === el.name);
87
- if (nextElement.subtype === "screens") {
88
- if (dmlFlag && nextElement.element["allowBack"] === "true" && nextElement.element["showFooter"] === "true") {
89
- if (!suppSet.has(nextElement.name)) {
90
- DuplicateDMLOperations.push(nextElement);
91
- }
80
+ }
81
+ dmlFlag = this.flagDML(element, dmlFlag);
82
+ if (references.length > 0) {
83
+ const elementsByReferences = flowElements.filter((el)=>references.includes(el.name));
84
+ for (const nextElement of elementsByReferences){
85
+ const nextIndex = flowElements.findIndex((el)=>nextElement.name === el.name);
86
+ if (nextElement.subtype === "screens") {
87
+ if (dmlFlag && nextElement.element["allowBack"] === "true" && nextElement.element["showFooter"] === "true") {
88
+ if (!suppressions.has(nextElement.name)) {
89
+ DuplicateDMLOperations.push(nextElement);
92
90
  }
93
91
  }
94
- if (!processedElementIndexes.includes(nextIndex)) {
95
- indexesToProcess.push(nextIndex);
96
- }
92
+ }
93
+ if (!processedElementIndexes.includes(nextIndex)) {
94
+ indexesToProcess.push(nextIndex);
97
95
  }
98
96
  }
99
- processedElementIndexes.push(index);
100
97
  }
98
+ processedElementIndexes.push(index);
101
99
  }
102
- } else {
103
- for (const index of flowElements.keys()){
104
- if (!processedElementIndexes.includes(index)) {
105
- unconnectedElementIndexes.push(index);
106
- }
100
+ }
101
+ } else {
102
+ for (const index of flowElements.keys()){
103
+ if (!processedElementIndexes.includes(index)) {
104
+ unconnectedElementIndexes.push(index);
107
105
  }
108
106
  }
109
- }while (processedElementIndexes.length + unconnectedElementIndexes.length < flowElements.length)
110
- const results = DuplicateDMLOperations.map((det)=>new _internals.ResultDetails(det));
111
- return new _internals.RuleResult(this, results);
112
- });
107
+ }
108
+ }while (processedElementIndexes.length + unconnectedElementIndexes.length < flowElements.length)
109
+ return DuplicateDMLOperations.map((det)=>new _internals.Violation(det));
110
+ }
111
+ findStart(flow) {
112
+ const flowElements = flow.elements.filter((node)=>node instanceof _internals.FlowNode);
113
+ if (flow.startElementReference) {
114
+ return flowElements.findIndex((n)=>n.name === flow.startElementReference);
115
+ } else {
116
+ return flowElements.findIndex((n)=>n.subtype === "start");
117
+ }
113
118
  }
114
119
  flagDML(element, dmlFlag) {
115
120
  const dmlStatementTypes = [
@@ -125,14 +130,6 @@ let DuplicateDMLOperation = class DuplicateDMLOperation extends _RuleCommon.Rule
125
130
  return dmlFlag;
126
131
  }
127
132
  }
128
- findStart(flow) {
129
- const flowElements = flow.elements.filter((node)=>node instanceof _internals.FlowNode);
130
- if (flow.startElementReference) {
131
- return flowElements.findIndex((n)=>n.name === flow.startElementReference);
132
- } else {
133
- return flowElements.findIndex((n)=>n.subtype === "start");
134
- }
135
- }
136
133
  constructor(){
137
134
  super({
138
135
  name: "DuplicateDMLOperation",
@@ -3,5 +3,5 @@ import { RuleCommon } from "../models/RuleCommon";
3
3
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
4
  export declare class FlowDescription extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
+ protected check(flow: core.Flow, _options: object | undefined, _suppressions: Set<string>): core.Violation[];
7
7
  }
@@ -52,18 +52,14 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
52
  return newObj;
53
53
  }
54
54
  let FlowDescription = class FlowDescription extends _RuleCommon.RuleCommon {
55
- execute(flow, options, suppressions = []) {
56
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
57
- var _flow_xmldata;
58
- const missingFlowDescription = !((_flow_xmldata = flow.xmldata) === null || _flow_xmldata === void 0 ? void 0 : _flow_xmldata.description);
59
- if (!missingFlowDescription || suppSet.has("FlowDescription")) {
60
- return new _internals.RuleResult(this, []);
61
- }
62
- const detail = new _internals.ResultDetails(new _internals.FlowAttribute("undefined", "description", "!==null"));
63
- return new _internals.RuleResult(this, [
64
- detail
65
- ]);
66
- });
55
+ check(flow, _options, _suppressions) {
56
+ var _flow_xmldata;
57
+ if ((_flow_xmldata = flow.xmldata) === null || _flow_xmldata === void 0 ? void 0 : _flow_xmldata.description) {
58
+ return [];
59
+ }
60
+ return [
61
+ new _internals.Violation(new _internals.FlowAttribute("undefined", "description", "!==null"))
62
+ ];
67
63
  }
68
64
  constructor(){
69
65
  super({
@@ -3,7 +3,7 @@ import { RuleCommon } from "../models/RuleCommon";
3
3
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
4
  export declare class FlowName extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: core.Flow, options?: {
6
+ protected check(flow: core.Flow, options: {
7
7
  expression?: string;
8
- }, suppressions?: string[]): core.RuleResult;
8
+ } | undefined, _suppressions: Set<string>): core.Violation[];
9
9
  }
@@ -52,23 +52,17 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
52
  return newObj;
53
53
  }
54
54
  let FlowName = class FlowName extends _RuleCommon.RuleCommon {
55
- execute(flow, options, suppressions = []) {
56
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
57
- var _options_expression;
58
- const rawRegexp = (_options_expression = options === null || options === void 0 ? void 0 : options.expression) !== null && _options_expression !== void 0 ? _options_expression : "[A-Za-z0-9]+_[A-Za-z0-9]+";
59
- const flowName = flow.name;
60
- const conventionApplied = new RegExp(rawRegexp).test(flowName);
61
- if (conventionApplied) {
62
- return new _internals.RuleResult(this, []);
63
- }
64
- const detail = new _internals.ResultDetails(new _internals.FlowAttribute(flowName, "name", rawRegexp));
65
- if (suppSet.has(detail.name)) {
66
- return new _internals.RuleResult(this, []);
67
- }
68
- return new _internals.RuleResult(this, [
69
- detail
70
- ]);
71
- });
55
+ check(flow, options, _suppressions) {
56
+ var _options_expression;
57
+ const rawRegexp = (_options_expression = options === null || options === void 0 ? void 0 : options.expression) !== null && _options_expression !== void 0 ? _options_expression : "[A-Za-z0-9]+_[A-Za-z0-9]+";
58
+ var _flow_name;
59
+ const flowName = (_flow_name = flow.name) !== null && _flow_name !== void 0 ? _flow_name : "";
60
+ if (new RegExp(rawRegexp).test(flowName)) {
61
+ return [];
62
+ }
63
+ return [
64
+ new _internals.Violation(new _internals.FlowAttribute(flowName, "name", rawRegexp))
65
+ ];
72
66
  }
73
67
  constructor(){
74
68
  super({
@@ -77,7 +71,7 @@ let FlowName = class FlowName extends _RuleCommon.RuleCommon {
77
71
  docRefs: [
78
72
  {
79
73
  label: "Naming your Flows is more critical than ever. By Stephen Church",
80
- path: "https://www.linkedin.com/posts/stephen-n-church_naming-your-flows-this-is-more-critical-activity-7099733198175158274-1sPx?utm_source=share&utm_medium=member_desktop"
74
+ path: "https://www.linkedin.com/posts/stephen-n-church_naming-your-flows-this-is-more-critical-activity-7099733198175158274-1sPx"
81
75
  }
82
76
  ],
83
77
  isConfigurable: true,
@@ -3,5 +3,5 @@ import { RuleCommon } from "../models/RuleCommon";
3
3
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
4
  export declare class GetRecordAllFields extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
+ protected check(flow: core.Flow, _options: object | undefined, _suppressions: Set<string>): core.Violation[];
7
7
  }
@@ -52,27 +52,17 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
52
  return newObj;
53
53
  }
54
54
  let GetRecordAllFields = class GetRecordAllFields extends _RuleCommon.RuleCommon {
55
- execute(flow, options, suppressions = []) {
56
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
57
- var _flow_elements;
58
- const results = [];
59
- const getElementNodes = (_flow_elements = flow.elements) === null || _flow_elements === void 0 ? void 0 : _flow_elements.filter((element)=>element.subtype === "recordLookups");
60
- if (!getElementNodes || getElementNodes.length === 0) {
61
- return new _internals.RuleResult(this, results);
62
- }
63
- const errorNodes = getElementNodes.filter((element)=>{
64
- const getRecordElement = element;
65
- const hasQualifiedElementDefinition = typeof getRecordElement.element === "object";
66
- if (!hasQualifiedElementDefinition) return false;
67
- const concreteChildElement = getRecordElement.element;
68
- const storeAllFields = "storeOutputAutomatically" in concreteChildElement && concreteChildElement["storeOutputAutomatically"];
69
- const hasQueriedFields = "queriedFields" in concreteChildElement && Array.isArray(concreteChildElement["queriedFields"]) && concreteChildElement["queriedFields"].length > 0;
70
- const isViolation = storeAllFields && !hasQueriedFields;
71
- return isViolation && !suppSet.has(getRecordElement.name);
72
- }).map((element)=>new _internals.ResultDetails(element));
73
- results.push(...errorNodes);
74
- return new _internals.RuleResult(this, results);
75
- });
55
+ check(flow, _options, _suppressions) {
56
+ var _flow_elements;
57
+ var _flow_elements_filter;
58
+ const lookupNodes = (_flow_elements_filter = (_flow_elements = flow.elements) === null || _flow_elements === void 0 ? void 0 : _flow_elements.filter((e)=>e.subtype === "recordLookups")) !== null && _flow_elements_filter !== void 0 ? _flow_elements_filter : [];
59
+ const violations = lookupNodes.filter((node)=>{
60
+ const el = node.element;
61
+ const storeAllFields = typeof el === "object" && "storeOutputAutomatically" in el && el.storeOutputAutomatically;
62
+ const hasQueriedFields = typeof el === "object" && Array.isArray(el.queriedFields) && el.queriedFields.length > 0;
63
+ return storeAllFields && !hasQueriedFields;
64
+ }).map((node)=>new _internals.Violation(node));
65
+ return violations;
76
66
  }
77
67
  constructor(){
78
68
  super({
@@ -3,5 +3,5 @@ import { RuleCommon } from "../models/RuleCommon";
3
3
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
4
  export declare class HardcodedId extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
+ protected check(flow: core.Flow, _options: object | undefined, _suppressions: Set<string>): core.Violation[];
7
7
  }
@@ -52,20 +52,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
52
  return newObj;
53
53
  }
54
54
  let HardcodedId = class HardcodedId extends _RuleCommon.RuleCommon {
55
- execute(flow, options, suppressions = []) {
56
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
57
- const salesforceIdRegex = /\b[a-zA-Z0-9]{5}0[a-zA-Z0-9]{9}([a-zA-Z0-9]{3})?\b/g;
58
- const results = [];
59
- for (const node of flow.elements){
60
- const nodeString = JSON.stringify(node);
61
- if (salesforceIdRegex.test(nodeString)) {
62
- if (!suppSet.has(node.name)) {
63
- results.push(new _internals.ResultDetails(node));
64
- }
65
- }
66
- }
67
- return new _internals.RuleResult(this, results);
68
- });
55
+ check(flow, _options, _suppressions) {
56
+ const salesforceIdRegex = /\b[a-zA-Z0-9]{5}0[a-zA-Z0-9]{9}(?:[a-zA-Z0-9]{3})?\b/g;
57
+ return flow.elements.filter((node)=>salesforceIdRegex.test(JSON.stringify(node))).map((node)=>new _internals.Violation(node));
69
58
  }
70
59
  constructor(){
71
60
  super({
@@ -80,7 +69,7 @@ let HardcodedId = class HardcodedId extends _RuleCommon.RuleCommon {
80
69
  },
81
70
  {
82
71
  label: "Don't hard code Record Type IDs in Flow. By Stephen Church.",
83
- path: "https://www.linkedin.com/feed/update/urn:li:activity:6947530300012826624/?updateEntityUrn=urn%3Ali%3Afs_feedUpdate%3A%28V2%2Curn%3Ali%3Aactivity%3A6947530300012826624%29"
72
+ path: "https://www.linkedin.com/feed/update/urn:li:activity:6947530300012826624/"
84
73
  }
85
74
  ],
86
75
  isConfigurable: false,
@@ -1,7 +1,7 @@
1
- import { Flow, RuleResult } from "../internals/internals";
1
+ import { Flow, Violation } from "../internals/internals";
2
2
  import { RuleCommon } from "../models/RuleCommon";
3
3
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
4
  export declare class HardcodedUrl extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: Flow, options?: object, suppressions?: string[]): RuleResult;
6
+ protected check(flow: Flow, _options: object | undefined, _suppressions: Set<string>): Violation[];
7
7
  }
@@ -11,23 +11,10 @@ Object.defineProperty(exports, "HardcodedUrl", {
11
11
  const _internals = require("../internals/internals");
12
12
  const _RuleCommon = require("../models/RuleCommon");
13
13
  let HardcodedUrl = class HardcodedUrl extends _RuleCommon.RuleCommon {
14
- execute(flow, options, suppressions = []) {
15
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
16
- const results = [];
17
- if (!flow.elements || flow.elements.length === 0) {
18
- return new _internals.RuleResult(this, results);
19
- }
20
- const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}force\.com/g;
21
- for (const element of flow.elements){
22
- const nodeString = JSON.stringify(element);
23
- if (urlRegex.test(nodeString)) {
24
- if (!suppSet.has(element.name)) {
25
- results.push(new _internals.ResultDetails(element));
26
- }
27
- }
28
- }
29
- return new _internals.RuleResult(this, results);
30
- });
14
+ check(flow, _options, _suppressions) {
15
+ if (!flow.elements || flow.elements.length === 0) return [];
16
+ const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}force\.com/g;
17
+ return flow.elements.filter((element)=>urlRegex.test(JSON.stringify(element))).map((element)=>new _internals.Violation(element));
31
18
  }
32
19
  constructor(){
33
20
  super({
@@ -3,5 +3,5 @@ import { RuleCommon } from "../models/RuleCommon";
3
3
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
4
  export declare class InactiveFlow extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
+ protected check(flow: core.Flow, _options: object | undefined, _suppressions: Set<string>): core.Violation[];
7
7
  }
@@ -52,16 +52,13 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
52
  return newObj;
53
53
  }
54
54
  let InactiveFlow = class InactiveFlow extends _RuleCommon.RuleCommon {
55
- execute(flow, options, suppressions = []) {
56
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
57
- const results = [];
58
- if (flow.status !== "Active") {
59
- if (!suppSet.has("InactiveFlow")) {
60
- results.push(new _internals.ResultDetails(new _internals.FlowAttribute(flow.status, "status", "!= Active")));
61
- }
62
- }
63
- return new _internals.RuleResult(this, results);
64
- });
55
+ check(flow, _options, _suppressions) {
56
+ if (flow.status !== "Active") {
57
+ return [
58
+ new _internals.Violation(new _internals.FlowAttribute(flow.status, "status", "!= Active"))
59
+ ];
60
+ }
61
+ return [];
65
62
  }
66
63
  constructor(){
67
64
  super({
@@ -5,6 +5,6 @@ export declare class MissingFaultPath extends RuleCommon implements IRuleDefinit
5
5
  protected applicableElements: string[];
6
6
  constructor();
7
7
  private isValidSubtype;
8
- execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
8
+ protected check(flow: core.Flow, _options: object | undefined, suppressions: Set<string>): core.Violation[];
9
9
  private isPartOfFaultHandlingFlow;
10
10
  }
@@ -80,32 +80,30 @@ let MissingFaultPath = class MissingFaultPath extends _RuleCommon.RuleCommon {
80
80
  }
81
81
  return true;
82
82
  }
83
- execute(flow, options, suppressions = []) {
84
- return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
85
- var _flow_elements;
86
- const compiler = new _internals.Compiler();
87
- const results = [];
88
- const elementsWhereFaultPathIsApplicable = ((_flow_elements = flow.elements) === null || _flow_elements === void 0 ? void 0 : _flow_elements.filter((node)=>{
89
- const proxyNode = node;
90
- return this.isValidSubtype(proxyNode);
91
- })).map((e)=>e.name);
92
- const isRecordBeforeSave = flow.start.triggerType === "RecordBeforeSave";
93
- const visitCallback = (element)=>{
94
- var _element_connectors;
95
- if (!(element === null || element === void 0 ? void 0 : (_element_connectors = element.connectors) === null || _element_connectors === void 0 ? void 0 : _element_connectors.find((connector)=>connector.type === "faultConnector")) && elementsWhereFaultPathIsApplicable.includes(element.name)) {
96
- if (isRecordBeforeSave && element.subtype === "recordUpdates") {
97
- return;
98
- }
99
- if (!this.isPartOfFaultHandlingFlow(element, flow)) {
100
- if (!suppSet.has(element.name)) {
101
- results.push(new _internals.ResultDetails(element));
102
- }
83
+ check(flow, _options, suppressions) {
84
+ var _flow_elements;
85
+ const compiler = new _internals.Compiler();
86
+ const results = [];
87
+ const elementsWhereFaultPathIsApplicable = ((_flow_elements = flow.elements) === null || _flow_elements === void 0 ? void 0 : _flow_elements.filter((node)=>{
88
+ const proxyNode = node;
89
+ return this.isValidSubtype(proxyNode);
90
+ })).map((e)=>e.name);
91
+ const isRecordBeforeSave = flow.start.triggerType === "RecordBeforeSave";
92
+ const visitCallback = (element)=>{
93
+ var _element_connectors;
94
+ if (!(element === null || element === void 0 ? void 0 : (_element_connectors = element.connectors) === null || _element_connectors === void 0 ? void 0 : _element_connectors.find((connector)=>connector.type === "faultConnector")) && elementsWhereFaultPathIsApplicable.includes(element.name)) {
95
+ if (isRecordBeforeSave && element.subtype === "recordUpdates") {
96
+ return;
97
+ }
98
+ if (!this.isPartOfFaultHandlingFlow(element, flow)) {
99
+ if (!suppressions.has(element.name)) {
100
+ results.push(new _internals.Violation(element));
103
101
  }
104
102
  }
105
- };
106
- compiler.traverseFlow(flow, flow.startReference, visitCallback);
107
- return new _internals.RuleResult(this, results);
108
- });
103
+ }
104
+ };
105
+ compiler.traverseFlow(flow, flow.startReference, visitCallback);
106
+ return results;
109
107
  }
110
108
  isPartOfFaultHandlingFlow(element, flow) {
111
109
  var _flow_elements;
@@ -3,5 +3,5 @@ import { RuleCommon } from "../models/RuleCommon";
3
3
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
4
  export declare class MissingNullHandler extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
+ protected check(flow: core.Flow, _options: object | undefined, suppressions: Set<string>): core.Violation[];
7
7
  }