@flow-scanner/lightning-flow-scanner-core 6.3.1 → 6.4.1

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 (65) hide show
  1. package/CONTRIBUTING.md +11 -11
  2. package/LICENSE.md +2 -2
  3. package/README.md +23 -10
  4. package/index.d.ts +1 -2
  5. package/index.js +0 -4
  6. package/main/interfaces/IRuleDefinition.d.ts +2 -3
  7. package/main/interfaces/IRulesConfig.d.ts +1 -2
  8. package/main/libs/DynamicRule.d.ts +1 -2
  9. package/main/libs/ScanFlows.js +22 -51
  10. package/main/models/LoopRuleCommon.d.ts +6 -3
  11. package/main/models/LoopRuleCommon.js +15 -12
  12. package/main/models/RuleCommon.d.ts +6 -4
  13. package/main/models/RuleCommon.js +50 -0
  14. package/main/rules/APIVersion.d.ts +4 -3
  15. package/main/rules/APIVersion.js +26 -20
  16. package/main/rules/ActionCallsInLoop.js +0 -2
  17. package/main/rules/AutoLayout.d.ts +4 -3
  18. package/main/rules/AutoLayout.js +20 -11
  19. package/main/rules/CopyAPIName.d.ts +4 -3
  20. package/main/rules/CopyAPIName.js +14 -16
  21. package/main/rules/CyclomaticComplexity.d.ts +4 -3
  22. package/main/rules/CyclomaticComplexity.js +28 -25
  23. package/main/rules/DuplicateDMLOperation.d.ts +4 -3
  24. package/main/rules/DuplicateDMLOperation.js +54 -60
  25. package/main/rules/FlowDescription.d.ts +4 -3
  26. package/main/rules/FlowDescription.js +14 -8
  27. package/main/rules/FlowName.d.ts +6 -4
  28. package/main/rules/FlowName.js +19 -10
  29. package/main/rules/GetRecordAllFields.d.ts +4 -3
  30. package/main/rules/GetRecordAllFields.js +21 -23
  31. package/main/rules/HardcodedId.d.ts +4 -3
  32. package/main/rules/HardcodedId.js +15 -12
  33. package/main/rules/HardcodedUrl.d.ts +5 -4
  34. package/main/rules/HardcodedUrl.js +18 -14
  35. package/main/rules/InactiveFlow.d.ts +4 -3
  36. package/main/rules/InactiveFlow.js +12 -8
  37. package/main/rules/MissingFaultPath.d.ts +4 -6
  38. package/main/rules/MissingFaultPath.js +28 -40
  39. package/main/rules/MissingNullHandler.d.ts +4 -3
  40. package/main/rules/MissingNullHandler.js +69 -73
  41. package/main/rules/ProcessBuilder.d.ts +4 -3
  42. package/main/rules/ProcessBuilder.js +7 -4
  43. package/main/rules/RecursiveAfterUpdate.d.ts +4 -3
  44. package/main/rules/RecursiveAfterUpdate.js +35 -31
  45. package/main/rules/SameRecordFieldUpdates.d.ts +4 -3
  46. package/main/rules/SameRecordFieldUpdates.js +23 -19
  47. package/main/rules/TriggerOrder.d.ts +4 -3
  48. package/main/rules/TriggerOrder.js +14 -10
  49. package/main/rules/UnconnectedElement.d.ts +4 -3
  50. package/main/rules/UnconnectedElement.js +17 -20
  51. package/main/rules/UnsafeRunningContext.d.ts +4 -3
  52. package/main/rules/UnsafeRunningContext.js +15 -11
  53. package/main/rules/UnusedVariable.d.ts +4 -3
  54. package/main/rules/UnusedVariable.js +27 -29
  55. package/package.json +7 -9
  56. package/main/interfaces/AdvancedRuleConfig.d.ts +0 -11
  57. package/main/interfaces/AdvancedRuleConfig.js +0 -4
  58. package/main/interfaces/AdvancedRuleDefintion.d.ts +0 -5
  59. package/main/interfaces/AdvancedRuleDefintion.js +0 -4
  60. package/main/interfaces/AdvancedSuppression.d.ts +0 -21
  61. package/main/interfaces/AdvancedSuppression.js +0 -4
  62. package/main/libs/Scan2.d.ts +0 -3
  63. package/main/libs/Scan2.js +0 -124
  64. package/main/models/AdvancedRule.d.ts +0 -44
  65. package/main/models/AdvancedRule.js +0 -84
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "CopyAPIName", {
9
9
  }
10
10
  });
11
11
  const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
- const _AdvancedRule = require("../models/AdvancedRule");
12
+ const _RuleCommon = require("../models/RuleCommon");
13
13
  function _getRequireWildcardCache(nodeInterop) {
14
14
  if (typeof WeakMap !== "function") return null;
15
15
  var cacheBabelInterop = new WeakMap();
@@ -51,22 +51,20 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  }
52
52
  return newObj;
53
53
  }
54
- let CopyAPIName = class CopyAPIName extends _AdvancedRule.AdvancedRule {
55
- execute(flow) {
56
- const flowElements = flow.elements.filter((node)=>node instanceof _internals.FlowNode);
57
- const copyOfElements = [];
58
- for (const element of flowElements){
59
- // eslint-disable-next-line sonarjs/concise-regex
60
- const copyOf = new RegExp("Copy_[0-9]+_of_[A-Za-z0-9]+").test(element.name);
61
- if (copyOf) {
62
- copyOfElements.push(element);
54
+ let CopyAPIName = class CopyAPIName 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 copyOfElements = [];
59
+ for (const element of flowElements){
60
+ const copyOf = new RegExp("Copy_[0-9]+_of_[A-Za-z0-9]+").test(element.name);
61
+ if (copyOf && !suppSet.has(element.name)) {
62
+ copyOfElements.push(element);
63
+ }
63
64
  }
64
- }
65
- const results = [];
66
- for (const det of copyOfElements){
67
- results.push(new _internals.ResultDetails(det));
68
- }
69
- return new _internals.RuleResult(this, results);
65
+ const results = copyOfElements.map((det)=>new _internals.ResultDetails(det));
66
+ return new _internals.RuleResult(this, results);
67
+ });
70
68
  }
71
69
  constructor(){
72
70
  super({
@@ -1,10 +1,11 @@
1
- import { AdvancedRule } from "../models/AdvancedRule";
2
1
  import * as core from "../internals/internals";
3
- export declare class CyclomaticComplexity extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class CyclomaticComplexity extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
6
  private defaultThreshold;
6
7
  private cyclomaticComplexityUnit;
7
8
  execute(flow: core.Flow, options?: {
8
9
  threshold: number;
9
- }): core.RuleResult;
10
+ }, suppressions?: string[]): core.RuleResult;
10
11
  }
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "CyclomaticComplexity", {
8
8
  return CyclomaticComplexity;
9
9
  }
10
10
  });
11
- const _AdvancedRule = require("../models/AdvancedRule");
12
11
  const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
+ const _RuleCommon = require("../models/RuleCommon");
13
13
  function _define_property(obj, key, value) {
14
14
  if (key in obj) {
15
15
  Object.defineProperty(obj, key, {
@@ -64,31 +64,34 @@ function _interop_require_wildcard(obj, nodeInterop) {
64
64
  }
65
65
  return newObj;
66
66
  }
67
- let CyclomaticComplexity = class CyclomaticComplexity extends _AdvancedRule.AdvancedRule {
68
- execute(flow, options) {
69
- var _flow_elements, _flow_elements1;
70
- // Set Threshold
71
- const threshold = (options === null || options === void 0 ? void 0 : options.threshold) || this.defaultThreshold;
72
- // Calculate Cyclomatic Complexity based on the number of decision rules and loops, adding the number of decisions plus 1.
73
- let cyclomaticComplexity = 1;
74
- 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");
75
- 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");
76
- for (const decision of flowDecisions || []){
77
- const rules = decision.element["rules"];
78
- if (Array.isArray(rules)) {
79
- cyclomaticComplexity += rules.length + 1;
80
- } else {
81
- cyclomaticComplexity += 1;
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
82
  }
83
- }
84
- var _flowLoops_length;
85
- cyclomaticComplexity += (_flowLoops_length = flowLoops === null || flowLoops === void 0 ? void 0 : flowLoops.length) !== null && _flowLoops_length !== void 0 ? _flowLoops_length : 0;
86
- this.cyclomaticComplexityUnit = cyclomaticComplexity; // for unit testing
87
- const results = [];
88
- if (cyclomaticComplexity > threshold) {
89
- results.push(new _internals.ResultDetails(new _internals.FlowAttribute(`${cyclomaticComplexity}`, "CyclomaticComplexity", `>${threshold}`)));
90
- }
91
- return new _internals.RuleResult(this, results);
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
+ });
92
95
  }
93
96
  constructor(){
94
97
  super({
@@ -1,8 +1,9 @@
1
- import { AdvancedRule } from "../models/AdvancedRule";
2
1
  import * as core from "../internals/internals";
3
- export declare class DuplicateDMLOperation extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class DuplicateDMLOperation extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
- execute(flow: core.Flow): core.RuleResult;
6
+ execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
7
  private flagDML;
7
8
  private findStart;
8
9
  }
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "DuplicateDMLOperation", {
8
8
  return DuplicateDMLOperation;
9
9
  }
10
10
  });
11
- const _AdvancedRule = require("../models/AdvancedRule");
12
11
  const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
+ const _RuleCommon = require("../models/RuleCommon");
13
13
  function _getRequireWildcardCache(nodeInterop) {
14
14
  if (typeof WeakMap !== "function") return null;
15
15
  var cacheBabelInterop = new WeakMap();
@@ -51,65 +51,65 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  }
52
52
  return newObj;
53
53
  }
54
- let DuplicateDMLOperation = class DuplicateDMLOperation extends _AdvancedRule.AdvancedRule {
55
- execute(flow) {
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 || startingNode === -1) {
62
- throw "Can not find starting element";
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);
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
+ }
78
80
  }
79
81
  }
80
- }
81
- dmlFlag = this.flagDML(element, dmlFlag);
82
- if (references.length > 0) {
83
- const elementsByReferences = flowElements.filter((element)=>references.includes(element.name));
84
- for (const nextElement of elementsByReferences){
85
- const nextIndex = flowElements.findIndex((element)=>nextElement.name === element.name);
86
- if ("screens" === nextElement.subtype) {
87
- if (dmlFlag && nextElement.element["allowBack"] && nextElement.element["allowBack"] == "true" && nextElement.element["showFooter"] == "true") {
88
- DuplicateDMLOperations.push(nextElement);
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
+ }
92
+ }
93
+ }
94
+ if (!processedElementIndexes.includes(nextIndex)) {
95
+ indexesToProcess.push(nextIndex);
89
96
  }
90
- }
91
- if (!processedElementIndexes.includes(nextIndex)) {
92
- indexesToProcess.push(nextIndex);
93
97
  }
94
98
  }
99
+ processedElementIndexes.push(index);
95
100
  }
96
- processedElementIndexes.push(index);
97
101
  }
98
- }
99
- } else {
100
- // skip unconnected elements
101
- for (const index of flowElements.keys()){
102
- if (!processedElementIndexes.includes(index)) {
103
- unconnectedElementIndexes.push(index);
102
+ } else {
103
+ for (const index of flowElements.keys()){
104
+ if (!processedElementIndexes.includes(index)) {
105
+ unconnectedElementIndexes.push(index);
106
+ }
104
107
  }
105
108
  }
106
- }
107
- }while (processedElementIndexes.length + unconnectedElementIndexes.length < flowElements.length)
108
- const results = [];
109
- for (const det of DuplicateDMLOperations){
110
- results.push(new _internals.ResultDetails(det));
111
- }
112
- return new _internals.RuleResult(this, results);
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
+ });
113
113
  }
114
114
  flagDML(element, dmlFlag) {
115
115
  const dmlStatementTypes = [
@@ -119,7 +119,7 @@ let DuplicateDMLOperation = class DuplicateDMLOperation extends _AdvancedRule.Ad
119
119
  ];
120
120
  if (dmlStatementTypes.includes(element.subtype)) {
121
121
  return true;
122
- } else if (dmlFlag === true && element.subtype === "screens" && element.element["allowBack"] && element.element["allowBack"] == "true") {
122
+ } else if (dmlFlag === true && element.subtype === "screens" && element.element["allowBack"] === "true") {
123
123
  return false;
124
124
  } else {
125
125
  return dmlFlag;
@@ -127,17 +127,11 @@ let DuplicateDMLOperation = class DuplicateDMLOperation extends _AdvancedRule.Ad
127
127
  }
128
128
  findStart(flow) {
129
129
  const flowElements = flow.elements.filter((node)=>node instanceof _internals.FlowNode);
130
- let start;
131
130
  if (flow.startElementReference) {
132
- start = flowElements.findIndex((n)=>{
133
- return n.name == flow.startElementReference;
134
- });
131
+ return flowElements.findIndex((n)=>n.name === flow.startElementReference);
135
132
  } else {
136
- start = flowElements.findIndex((n)=>{
137
- return n.subtype === "start";
138
- });
133
+ return flowElements.findIndex((n)=>n.subtype === "start");
139
134
  }
140
- return start;
141
135
  }
142
136
  constructor(){
143
137
  super({
@@ -1,6 +1,7 @@
1
1
  import * as core from "../internals/internals";
2
- import { AdvancedRule } from "../models/AdvancedRule";
3
- export declare class FlowDescription extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class FlowDescription extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
- execute(flow: core.Flow): core.RuleResult;
6
+ execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
7
  }
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "FlowDescription", {
9
9
  }
10
10
  });
11
11
  const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
- const _AdvancedRule = require("../models/AdvancedRule");
12
+ const _RuleCommon = require("../models/RuleCommon");
13
13
  function _getRequireWildcardCache(nodeInterop) {
14
14
  if (typeof WeakMap !== "function") return null;
15
15
  var cacheBabelInterop = new WeakMap();
@@ -51,13 +51,19 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  }
52
52
  return newObj;
53
53
  }
54
- let FlowDescription = class FlowDescription extends _AdvancedRule.AdvancedRule {
55
- execute(flow) {
56
- var _flow_xmldata;
57
- const missingFlowDescription = !((_flow_xmldata = flow.xmldata) === null || _flow_xmldata === void 0 ? void 0 : _flow_xmldata.description);
58
- return missingFlowDescription ? new _internals.RuleResult(this, [
59
- new _internals.ResultDetails(new _internals.FlowAttribute("undefined", "description", "!==null"))
60
- ]) : new _internals.RuleResult(this, []);
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
+ });
61
67
  }
62
68
  constructor(){
63
69
  super({
@@ -1,7 +1,9 @@
1
- import { AdvancedConfig } from "../interfaces/AdvancedRuleConfig";
2
1
  import * as core from "../internals/internals";
3
- import { AdvancedRule } from "../models/AdvancedRule";
4
- export declare class FlowName extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class FlowName extends RuleCommon implements IRuleDefinition {
5
5
  constructor();
6
- execute(flow: core.Flow, advancedConfig?: AdvancedConfig): core.RuleResult;
6
+ execute(flow: core.Flow, options?: {
7
+ expression?: string;
8
+ }, suppressions?: string[]): core.RuleResult;
7
9
  }
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "FlowName", {
9
9
  }
10
10
  });
11
11
  const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
- const _AdvancedRule = require("../models/AdvancedRule");
12
+ const _RuleCommon = require("../models/RuleCommon");
13
13
  function _getRequireWildcardCache(nodeInterop) {
14
14
  if (typeof WeakMap !== "function") return null;
15
15
  var cacheBabelInterop = new WeakMap();
@@ -51,15 +51,24 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  }
52
52
  return newObj;
53
53
  }
54
- let FlowName = class FlowName extends _AdvancedRule.AdvancedRule {
55
- execute(flow, advancedConfig) {
56
- const rawRegexp = advancedConfig && advancedConfig.expression ? advancedConfig.expression : "[A-Za-z0-9]+_[A-Za-z0-9]+";
57
- const regexExp = rawRegexp;
58
- const flowName = flow.name;
59
- const conventionApplied = new RegExp(regexExp).test(flowName);
60
- return !conventionApplied ? new _internals.RuleResult(this, [
61
- new _internals.ResultDetails(new _internals.FlowAttribute(flowName, "name", regexExp))
62
- ]) : new _internals.RuleResult(this, []);
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
+ });
63
72
  }
64
73
  constructor(){
65
74
  super({
@@ -1,6 +1,7 @@
1
1
  import * as core from "../internals/internals";
2
- import { AdvancedRule } from "../models/AdvancedRule";
3
- export declare class GetRecordAllFields extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class GetRecordAllFields extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
- execute(flow: core.Flow): core.RuleResult;
6
+ execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
7
  }
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "GetRecordAllFields", {
9
9
  }
10
10
  });
11
11
  const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
- const _AdvancedRule = require("../models/AdvancedRule");
12
+ const _RuleCommon = require("../models/RuleCommon");
13
13
  function _getRequireWildcardCache(nodeInterop) {
14
14
  if (typeof WeakMap !== "function") return null;
15
15
  var cacheBabelInterop = new WeakMap();
@@ -51,30 +51,28 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  }
52
52
  return newObj;
53
53
  }
54
- let GetRecordAllFields = class GetRecordAllFields extends _AdvancedRule.AdvancedRule {
55
- execute(flow) {
56
- var _flow_elements;
57
- const results = [];
58
- const getElementNodes = (_flow_elements = flow.elements) === null || _flow_elements === void 0 ? void 0 : _flow_elements.filter((element)=>element.subtype === "recordLookups");
59
- if (getElementNodes == null || getElementNodes.length === 0) {
60
- return new _internals.RuleResult(this, results);
61
- }
62
- const errorNodes = getElementNodes.filter((element)=>{
63
- const getRecordElement = element;
64
- const hasQualifiedElementDefinition = typeof getRecordElement.element === "object";
65
- if (!hasQualifiedElementDefinition) {
66
- return false;
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);
67
62
  }
68
- const concreteChildElement = getRecordElement.element;
69
- const storeAllFields = "storeOutputAutomatically" in concreteChildElement && concreteChildElement["storeOutputAutomatically"];
70
- const hasQueriedFields = "queriedFields" in concreteChildElement && concreteChildElement["queriedFields"].length > 0;
71
- return storeAllFields && !hasQueriedFields;
72
- }).map((element)=>{
73
- const getRecordElement = element;
74
- return new _internals.ResultDetails(getRecordElement);
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
75
  });
76
- results.push(...errorNodes);
77
- return new _internals.RuleResult(this, results);
78
76
  }
79
77
  constructor(){
80
78
  super({
@@ -1,6 +1,7 @@
1
- import { AdvancedRule } from "../models/AdvancedRule";
2
1
  import * as core from "../internals/internals";
3
- export declare class HardcodedId extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class HardcodedId extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
- execute(flow: core.Flow): core.RuleResult;
6
+ execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
7
  }
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "HardcodedId", {
8
8
  return HardcodedId;
9
9
  }
10
10
  });
11
- const _AdvancedRule = require("../models/AdvancedRule");
12
11
  const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
+ const _RuleCommon = require("../models/RuleCommon");
13
13
  function _getRequireWildcardCache(nodeInterop) {
14
14
  if (typeof WeakMap !== "function") return null;
15
15
  var cacheBabelInterop = new WeakMap();
@@ -51,18 +51,21 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  }
52
52
  return newObj;
53
53
  }
54
- let HardcodedId = class HardcodedId extends _AdvancedRule.AdvancedRule {
55
- execute(flow) {
56
- const nodesWithHardcodedIds = [];
57
- const salesforceIdRegex = /\b[a-zA-Z0-9]{5}0[a-zA-Z0-9]{9}([a-zA-Z0-9]{3})?\b/g;
58
- for (const node of flow.elements){
59
- const nodeString = JSON.stringify(node);
60
- if (salesforceIdRegex.test(nodeString)) {
61
- nodesWithHardcodedIds.push(node);
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
+ }
62
66
  }
63
- }
64
- const results = nodesWithHardcodedIds.map((node)=>new _internals.ResultDetails(node));
65
- return new _internals.RuleResult(this, results);
67
+ return new _internals.RuleResult(this, results);
68
+ });
66
69
  }
67
70
  constructor(){
68
71
  super({
@@ -1,6 +1,7 @@
1
- import { Flow, IRuleDefinition, RuleResult } from "../internals/internals";
2
- import { AdvancedRule } from "../models/AdvancedRule";
3
- export declare class HardcodedUrl extends AdvancedRule implements IRuleDefinition {
1
+ import { Flow, RuleResult } from "../internals/internals";
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class HardcodedUrl extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
- execute(flow: Flow): RuleResult;
6
+ execute(flow: Flow, options?: object, suppressions?: string[]): RuleResult;
6
7
  }
@@ -9,21 +9,25 @@ Object.defineProperty(exports, "HardcodedUrl", {
9
9
  }
10
10
  });
11
11
  const _internals = require("../internals/internals");
12
- const _AdvancedRule = require("../models/AdvancedRule");
13
- let HardcodedUrl = class HardcodedUrl extends _AdvancedRule.AdvancedRule {
14
- execute(flow) {
15
- const results = [];
16
- if (!flow.elements || flow.elements.length === 0) {
17
- return new _internals.RuleResult(this, results);
18
- }
19
- const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}force\.com/g;
20
- for (const element of flow.elements){
21
- const nodeString = JSON.stringify(element);
22
- if (urlRegex.test(nodeString)) {
23
- results.push(new _internals.ResultDetails(element));
12
+ const _RuleCommon = require("../models/RuleCommon");
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
+ }
24
28
  }
25
- }
26
- return new _internals.RuleResult(this, results);
29
+ return new _internals.RuleResult(this, results);
30
+ });
27
31
  }
28
32
  constructor(){
29
33
  super({
@@ -1,6 +1,7 @@
1
- import { AdvancedRule } from "../models/AdvancedRule";
2
1
  import * as core from "../internals/internals";
3
- export declare class InactiveFlow extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class InactiveFlow extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
- execute(flow: core.Flow): core.RuleResult;
6
+ execute(flow: core.Flow, options?: object, suppressions?: string[]): core.RuleResult;
6
7
  }