@flow-scanner/lightning-flow-scanner-core 6.3.0 → 6.4.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 (64) hide show
  1. package/README.md +30 -13
  2. package/SECURITY.md +1 -1
  3. package/index.d.ts +1 -2
  4. package/index.js +0 -4
  5. package/main/interfaces/IRuleDefinition.d.ts +2 -3
  6. package/main/interfaces/IRulesConfig.d.ts +1 -2
  7. package/main/libs/DynamicRule.d.ts +1 -2
  8. package/main/libs/ScanFlows.js +22 -51
  9. package/main/models/LoopRuleCommon.d.ts +6 -3
  10. package/main/models/LoopRuleCommon.js +15 -12
  11. package/main/models/RuleCommon.d.ts +6 -4
  12. package/main/models/RuleCommon.js +50 -0
  13. package/main/rules/APIVersion.d.ts +4 -3
  14. package/main/rules/APIVersion.js +26 -20
  15. package/main/rules/ActionCallsInLoop.js +0 -2
  16. package/main/rules/AutoLayout.d.ts +4 -3
  17. package/main/rules/AutoLayout.js +20 -11
  18. package/main/rules/CopyAPIName.d.ts +4 -3
  19. package/main/rules/CopyAPIName.js +14 -16
  20. package/main/rules/CyclomaticComplexity.d.ts +4 -3
  21. package/main/rules/CyclomaticComplexity.js +28 -25
  22. package/main/rules/DuplicateDMLOperation.d.ts +4 -3
  23. package/main/rules/DuplicateDMLOperation.js +54 -60
  24. package/main/rules/FlowDescription.d.ts +4 -3
  25. package/main/rules/FlowDescription.js +14 -8
  26. package/main/rules/FlowName.d.ts +6 -4
  27. package/main/rules/FlowName.js +19 -10
  28. package/main/rules/GetRecordAllFields.d.ts +4 -3
  29. package/main/rules/GetRecordAllFields.js +21 -23
  30. package/main/rules/HardcodedId.d.ts +4 -3
  31. package/main/rules/HardcodedId.js +15 -12
  32. package/main/rules/HardcodedUrl.d.ts +5 -4
  33. package/main/rules/HardcodedUrl.js +18 -14
  34. package/main/rules/InactiveFlow.d.ts +4 -3
  35. package/main/rules/InactiveFlow.js +12 -8
  36. package/main/rules/MissingFaultPath.d.ts +4 -6
  37. package/main/rules/MissingFaultPath.js +28 -40
  38. package/main/rules/MissingNullHandler.d.ts +4 -3
  39. package/main/rules/MissingNullHandler.js +69 -73
  40. package/main/rules/ProcessBuilder.d.ts +4 -3
  41. package/main/rules/ProcessBuilder.js +7 -4
  42. package/main/rules/RecursiveAfterUpdate.d.ts +4 -3
  43. package/main/rules/RecursiveAfterUpdate.js +35 -31
  44. package/main/rules/SameRecordFieldUpdates.d.ts +4 -3
  45. package/main/rules/SameRecordFieldUpdates.js +23 -19
  46. package/main/rules/TriggerOrder.d.ts +4 -3
  47. package/main/rules/TriggerOrder.js +14 -10
  48. package/main/rules/UnconnectedElement.d.ts +4 -3
  49. package/main/rules/UnconnectedElement.js +17 -20
  50. package/main/rules/UnsafeRunningContext.d.ts +4 -3
  51. package/main/rules/UnsafeRunningContext.js +15 -11
  52. package/main/rules/UnusedVariable.d.ts +4 -3
  53. package/main/rules/UnusedVariable.js +27 -29
  54. package/package.json +5 -6
  55. package/main/interfaces/AdvancedRuleConfig.d.ts +0 -11
  56. package/main/interfaces/AdvancedRuleConfig.js +0 -4
  57. package/main/interfaces/AdvancedRuleDefintion.d.ts +0 -5
  58. package/main/interfaces/AdvancedRuleDefintion.js +0 -4
  59. package/main/interfaces/AdvancedSuppression.d.ts +0 -21
  60. package/main/interfaces/AdvancedSuppression.js +0 -4
  61. package/main/libs/Scan2.d.ts +0 -3
  62. package/main/libs/Scan2.js +0 -124
  63. package/main/models/AdvancedRule.d.ts +0 -44
  64. package/main/models/AdvancedRule.js +0 -84
package/README.md CHANGED
@@ -201,8 +201,8 @@ Specifying exceptions allows you to exclude specific scenarios from rule enforce
201
201
  "exceptions": {
202
202
  "<FlowName>": {
203
203
  "<RuleName>": [
204
- "<ResultName>",
205
- "<ResultName>",
204
+ "<ResultName>", // Suppress specific result
205
+ "*", // Suppress ALL results of this rule
206
206
  ...
207
207
  ]
208
208
  },
@@ -211,6 +211,19 @@ Specifying exceptions allows you to exclude specific scenarios from rule enforce
211
211
  }
212
212
  ```
213
213
 
214
+ _Example_
215
+
216
+ ```json
217
+ {
218
+ "exceptions": {
219
+ "MyFlow": {
220
+ "MissingNullHandler": ["*"],
221
+ "HardcodedId": ["Old_Lookup_1"]
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
214
227
  ### Include Beta Rules
215
228
 
216
229
  New rules are introduced in Beta mode before being added to the default ruleset. To include current Beta rules, enable the optional betamode parameter in your configuration:
@@ -259,6 +272,8 @@ const results = scan(
259
272
  );
260
273
  ```
261
274
 
275
+ **Privacy:** Zero user data collected. All processing is client-side. → See our [Security Policy](https://github.com/Flow-Scanner/lightning-flow-scanner-core?tab=security-ov-file).
276
+
262
277
  ### Functions
263
278
 
264
279
  #### [`getRules(ruleNames?: string[]): IRuleDefinition[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/GetRuleDefinitions.ts)
@@ -277,11 +292,11 @@ _Runs all enabled rules and returns detailed violations._
277
292
 
278
293
  _Automatically applies available fixes(removing variables and unconnected elements)._
279
294
 
280
- #### [`exportDetails(results: ScanResult[]): FlatViolation[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/exportDetails.ts)
295
+ #### [`exportDetails(results: ScanResult[]): FlatViolation[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/exportAsDetails.ts)
281
296
 
282
- _Get flattened output of violations only._
297
+ _Get output of violations only(Reserved for future use)._
283
298
 
284
- #### [`exportSarif(results: ScanResult[]): string`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/exportSarif.ts)
299
+ #### [`exportSarif(results: ScanResult[]): string`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/exportAsSarif.ts)
285
300
 
286
301
  _Get SARIF output including exact line numbers of violations._
287
302
 
@@ -289,9 +304,11 @@ _Get SARIF output including exact line numbers of violations._
289
304
 
290
305
  ## Installation
291
306
 
292
- `lightning-flow-scanner-core` is [scanned with Snyk](https://github.com/Flow-Scanner/lightning-flow-scanner-core?tab=security-ov-file) prior to publication on **npm**.
293
-
294
- [![npm version](https://img.shields.io/npm/v/@flow-scanner/lightning-flow-scanner-core?label=npm)](https://www.npmjs.com/package/@flow-scanner/lightning-flow-scanner-core) [![Known Vulnerabilities](https://snyk.io/test/github/Flow-Scanner/lightning-flow-scanner-core/badge.svg)](https://snyk.io/test/github/Flow-Scanner/lightning-flow-scanner-core)
307
+ [![GitHub stars](https://img.shields.io/github/stars/Flow-Scanner/lightning-flow-scanner-core)](https://img.shields.io/github/stars/Flow-Scanner/lightning-flow-scanner-core)
308
+ [![GitHub contributors](https://img.shields.io/github/contributors/Flow-Scanner/lightning-flow-scanner-core.svg)](https://gitHub.com/Flow-Scanner/lightning-flow-scanner-core/graphs/contributors/)
309
+ [![License](https://img.shields.io/npm/l/lightning-flow-scanner-core.svg)](https://github.com/Flow-Scanner/lightning-flow-scanner-core/raw/main/LICENSE.md)
310
+ [![npm version](https://img.shields.io/npm/v/Flow-Scanner/lightning-flow-scanner-core?label=npm)](https://www.npmjs.com/package/@flow-scanner/lightning-flow-scanner-core)
311
+ [![Known Vulnerabilities](https://snyk.io/test/github/Flow-Scanner/lightning-flow-scanner-core/badge.svg)](https://snyk.io/test/github/Flow-Scanner/lightning-flow-scanner-core)
295
312
 
296
313
  **To install with npm:**
297
314
 
@@ -311,7 +328,7 @@ npm install @flow-scanner/lightning-flow-scanner-core
311
328
  >
312
329
  > Volta will automatically use the Node.js version defined in `package.json`.
313
330
 
314
- 1. Clone the repo:
331
+ 1. Clone the repository
315
332
 
316
333
  ```bash
317
334
  git clone https://github.com/Flow-Scanner/lightning-flow-scanner-core.git
@@ -323,7 +340,7 @@ npm install @flow-scanner/lightning-flow-scanner-core
323
340
  npm install
324
341
  ```
325
342
 
326
- 3. Build the project:
343
+ 3. Compile a new version:
327
344
 
328
345
  ```bash
329
346
  npm run build
@@ -336,13 +353,13 @@ npm install @flow-scanner/lightning-flow-scanner-core
336
353
  ```
337
354
 
338
355
  5. Test as local dependency(Optional):
339
- To test changes to the core module locally, run:
356
+ a. run:
340
357
 
341
358
  ```bash
342
359
  npm run link
343
360
  ```
344
361
 
345
- b) Go to the dependent project (e.g. VSX or CLI) and use:
362
+ b. Go to the dependent project (e.g. VSX or CLI) and use:
346
363
 
347
364
  ```bash
348
365
  npm link @flow-scanner/lightning-flow-scanner-core
@@ -356,4 +373,4 @@ npm install @flow-scanner/lightning-flow-scanner-core
356
373
  npm run vite:dist // creates UMD at`dist/lightning-flow-scanner-core.umd.js`.
357
374
  ```
358
375
 
359
- ###### Want to help improve Lightning Flow Scanner? See our [Contributing Guidelines](https://github.com/Flow-Scanner/lightning-flow-scanner-core/blob/main/CONTRIBUTING.md).
376
+ <p><strong>Want to help improve Lightning Flow Scanner? See our <a href="https://github.com/Flow-Scanner/lightning-flow-scanner-core?tab=contributing-ov-file">Contributing Guidelines</a></strong></p>
package/SECURITY.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  - Code is open-source and peer-reviewed by the community.
6
6
  - Vulnerabilities can be reported privately via [GitHub vulnerability reporting](https://github.com/Flow-Scanner/lightning-flow-scanner-core/security).
7
- - All changes are **scanned with Snyk** and reviewed before merging.
7
+ - All changes are scanned with [Snyk](https://github.com/snyk/cli) prior to publication.
8
8
  - Releases are published to npm using **GitHub Actions Trusted Publishing (OIDC)**.
9
9
  - Tags (`v*`) trigger automated `npm publish`, providing a full audit trail.
10
10
 
package/index.d.ts CHANGED
@@ -7,7 +7,6 @@ import { fix } from "./main/libs/FixFlows";
7
7
  import { getBetaRules, getRules } from "./main/libs/GetRuleDefinitions";
8
8
  import { parse } from "./main/libs/ParseFlows";
9
9
  import { scan } from "./main/libs/ScanFlows";
10
- import { AdvancedRule } from "./main/models/AdvancedRule";
11
10
  import { Flow } from "./main/models/Flow";
12
11
  import { FlowAttribute } from "./main/models/FlowAttribute";
13
12
  import { FlowElement } from "./main/models/FlowElement";
@@ -19,5 +18,5 @@ import { ParsedFlow } from "./main/models/ParsedFlow";
19
18
  import { ResultDetails } from "./main/models/ResultDetails";
20
19
  import { RuleResult } from "./main/models/RuleResult";
21
20
  import { ScanResult } from "./main/models/ScanResult";
22
- export { AdvancedRule, Compiler, exportDetails, exportSarif, fix, Flow, FlowAttribute, FlowElement, FlowNode, FlowResource, FlowType, FlowVariable, getBetaRules, getRules, parse, ParsedFlow, ResultDetails, RuleResult, scan, ScanResult, };
21
+ export { Compiler, exportDetails, exportSarif, fix, Flow, FlowAttribute, FlowElement, FlowNode, FlowResource, FlowType, FlowVariable, getBetaRules, getRules, parse, ParsedFlow, ResultDetails, RuleResult, scan, ScanResult, };
23
22
  export type { IRuleDefinition, IRulesConfig };
package/index.js CHANGED
@@ -9,9 +9,6 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- get AdvancedRule () {
13
- return _AdvancedRule.AdvancedRule;
14
- },
15
12
  get Compiler () {
16
13
  return _Compiler.Compiler;
17
14
  },
@@ -77,7 +74,6 @@ const _FixFlows = require("./main/libs/FixFlows");
77
74
  const _GetRuleDefinitions = require("./main/libs/GetRuleDefinitions");
78
75
  const _ParseFlows = require("./main/libs/ParseFlows");
79
76
  const _ScanFlows = require("./main/libs/ScanFlows");
80
- const _AdvancedRule = require("./main/models/AdvancedRule");
81
77
  const _Flow = require("./main/models/Flow");
82
78
  const _FlowAttribute = require("./main/models/FlowAttribute");
83
79
  const _FlowElement = require("./main/models/FlowElement");
@@ -1,5 +1,4 @@
1
- import { Flow } from "../models/Flow";
2
- import { RuleResult } from "../models/RuleResult";
1
+ import { Flow, RuleResult } from "../internals/internals";
3
2
  export interface IRuleDefinition {
4
3
  autoFixable: boolean;
5
4
  description: string;
@@ -7,7 +6,7 @@ export interface IRuleDefinition {
7
6
  label: string;
8
7
  path: string;
9
8
  }>;
10
- execute(flow: Flow, ruleOptions?: {}): RuleResult;
9
+ execute(flow: Flow, options?: object, suppressions?: string[]): RuleResult;
11
10
  isConfigurable: boolean;
12
11
  label: string;
13
12
  name: string;
@@ -1,8 +1,7 @@
1
- import { AdvancedRuleConfig } from "./AdvancedRuleConfig";
2
1
  import { IExceptions } from "./IExceptions";
3
2
  import { IRuleOptions } from "./IRuleOptions";
4
3
  export interface IRulesConfig {
5
4
  betamode?: boolean;
6
5
  exceptions?: IExceptions;
7
- rules?: AdvancedRuleConfig | IRuleOptions;
6
+ rules?: IRuleOptions;
8
7
  }
@@ -1,5 +1,4 @@
1
1
  import { IRuleDefinition } from "../interfaces/IRuleDefinition";
2
- import { AdvancedRule } from "../models/AdvancedRule";
3
- export declare class DynamicRule<T extends AdvancedRule | IRuleDefinition> {
2
+ export declare class DynamicRule<T extends IRuleDefinition> {
4
3
  constructor(className: string);
5
4
  }
@@ -18,35 +18,23 @@ _export(exports, {
18
18
  });
19
19
  const _internals = require("../../main/internals/internals");
20
20
  const _GetRuleDefinitions = require("./GetRuleDefinitions");
21
- const _Scan2 = require("./Scan2");
22
- const { IS_NEW_SCAN_ENABLED: isNewScanEnabled, OVERRIDE_CONFIG: overrideConfig } = process.env;
23
21
  function scan(parsedFlows, ruleOptions) {
24
- // TD see jest.env-setup.ts for testing scan2
25
- if (isNewScanEnabled === "true" && overrideConfig !== null && overrideConfig !== undefined) {
26
- return (0, _Scan2.scan2)(parsedFlows, ruleOptions);
27
- }
28
22
  const flows = [];
29
23
  for (const flow of parsedFlows){
30
24
  if (!flow.errorMessage && flow.flow) {
31
25
  flows.push(flow.flow);
32
26
  }
33
27
  }
34
- let scanResults;
35
- if ((ruleOptions === null || ruleOptions === void 0 ? void 0 : ruleOptions.rules) && Object.entries(ruleOptions.rules).length > 0) {
36
- scanResults = ScanFlows(flows, ruleOptions);
37
- } else {
38
- scanResults = ScanFlows(flows);
39
- }
40
- generalSuppressions(scanResults, ruleOptions);
41
- return scanResults;
28
+ const scanResults = ScanFlows(flows, ruleOptions);
29
+ return scanResults; // generalSuppressions removed suppression now inline
42
30
  }
43
31
  function ScanFlows(flows, ruleOptions) {
44
32
  const flowResults = [];
45
33
  let selectedRules = [];
46
- if (ruleOptions && ruleOptions.rules) {
34
+ if ((ruleOptions === null || ruleOptions === void 0 ? void 0 : ruleOptions.rules) && Object.keys(ruleOptions.rules).length > 0) {
47
35
  const ruleMap = new Map();
48
- for (const [ruleName, rule] of Object.entries(ruleOptions.rules)){
49
- ruleMap.set(ruleName, rule);
36
+ for (const [ruleName, config] of Object.entries(ruleOptions.rules)){
37
+ ruleMap.set(ruleName, config);
50
38
  }
51
39
  selectedRules = (0, _GetRuleDefinitions.GetRuleDefinitions)(ruleMap);
52
40
  } else {
@@ -56,19 +44,25 @@ function ScanFlows(flows, ruleOptions) {
56
44
  const ruleResults = [];
57
45
  for (const rule of selectedRules){
58
46
  try {
59
- if (rule.supportedTypes.includes(flow.type)) {
60
- let config = undefined;
61
- if (ruleOptions && ruleOptions["rules"] && ruleOptions["rules"][rule.name]) {
62
- config = ruleOptions["rules"][rule.name];
63
- }
64
- const result = config && Object.keys(config).length > 0 ? rule.execute(flow, config) : rule.execute(flow);
65
- if (result.severity !== rule.severity) {
66
- result.severity = rule.severity;
67
- }
68
- ruleResults.push(result);
69
- } else {
47
+ var _ruleOptions_rules, _ruleOptions_exceptions_flow_name, _ruleOptions_exceptions;
48
+ if (!rule.supportedTypes.includes(flow.type)) {
70
49
  ruleResults.push(new _internals.RuleResult(rule, []));
50
+ continue;
71
51
  }
52
+ let config = undefined;
53
+ if (ruleOptions === null || ruleOptions === void 0 ? void 0 : (_ruleOptions_rules = ruleOptions.rules) === null || _ruleOptions_rules === void 0 ? void 0 : _ruleOptions_rules[rule.name]) {
54
+ config = ruleOptions.rules[rule.name];
55
+ }
56
+ // WILDCARD SUPPORT: "*" = suppress all
57
+ const rawSuppressions = ruleOptions === null || ruleOptions === void 0 ? void 0 : (_ruleOptions_exceptions = ruleOptions.exceptions) === null || _ruleOptions_exceptions === void 0 ? void 0 : (_ruleOptions_exceptions_flow_name = _ruleOptions_exceptions[flow.name]) === null || _ruleOptions_exceptions_flow_name === void 0 ? void 0 : _ruleOptions_exceptions_flow_name[rule.name];
58
+ const suppressions = (rawSuppressions === null || rawSuppressions === void 0 ? void 0 : rawSuppressions.includes("*")) ? [
59
+ "*"
60
+ ] : rawSuppressions !== null && rawSuppressions !== void 0 ? rawSuppressions : [];
61
+ const result = config && Object.keys(config).length > 0 ? rule.execute(flow, config, suppressions) : rule.execute(flow, undefined, suppressions);
62
+ if (result.severity !== rule.severity) {
63
+ result.severity = rule.severity;
64
+ }
65
+ ruleResults.push(result);
72
66
  } catch (error) {
73
67
  const message = `Something went wrong while executing ${rule.name} in the Flow: ${flow.name} with error ${error}`;
74
68
  ruleResults.push(new _internals.RuleResult(rule, [], message));
@@ -78,26 +72,3 @@ function ScanFlows(flows, ruleOptions) {
78
72
  }
79
73
  return flowResults;
80
74
  }
81
- function generalSuppressions(scanResults, ruleOptions) {
82
- if (!(ruleOptions === null || ruleOptions === void 0 ? void 0 : ruleOptions.exceptions)) {
83
- return;
84
- }
85
- const applyExceptionToResults = (ruleResult, exceptions)=>{
86
- const filteredDetails = ruleResult.details.filter((detail)=>!exceptions.includes(detail.name));
87
- ruleResult.details = filteredDetails;
88
- ruleResult.occurs = filteredDetails.length > 0;
89
- };
90
- for (const [flowName, exceptionElements] of Object.entries(ruleOptions.exceptions)){
91
- const matchingScanResult = scanResults.find((result)=>result.flow.name === flowName);
92
- if (!matchingScanResult) {
93
- continue;
94
- }
95
- for (const ruleResult of matchingScanResult.ruleResults){
96
- const exceptions = exceptionElements[ruleResult.ruleName];
97
- if (!exceptions) {
98
- continue;
99
- }
100
- applyExceptionToResults(ruleResult, exceptions);
101
- }
102
- }
103
- }
@@ -1,7 +1,10 @@
1
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
1
2
  import { Flow, RuleResult } from "../internals/internals";
2
- import { AdvancedRule } from "./AdvancedRule";
3
- export declare abstract class LoopRuleCommon extends AdvancedRule {
4
- execute(flow: Flow): RuleResult;
3
+ import { RuleCommon } from "./RuleCommon";
4
+ import { RuleInfo } from "./RuleInfo";
5
+ export declare abstract class LoopRuleCommon extends RuleCommon implements IRuleDefinition {
6
+ constructor(info: RuleInfo);
7
+ execute(flow: Flow, options?: object, suppressions?: string[]): RuleResult;
5
8
  protected abstract getStatementTypes(): string[];
6
9
  private findLoopElements;
7
10
  private findLoopEnd;
@@ -9,16 +9,18 @@ Object.defineProperty(exports, "LoopRuleCommon", {
9
9
  }
10
10
  });
11
11
  const _internals = require("../internals/internals");
12
- const _AdvancedRule = require("./AdvancedRule");
13
- let LoopRuleCommon = class LoopRuleCommon extends _AdvancedRule.AdvancedRule {
14
- execute(flow) {
15
- const loopElements = this.findLoopElements(flow);
16
- if (!loopElements.length) {
17
- return new _internals.RuleResult(this, []);
18
- }
19
- const statementsInLoops = this.findStatementsInLoops(flow, loopElements);
20
- const results = statementsInLoops.map((det)=>new _internals.ResultDetails(det));
21
- return new _internals.RuleResult(this, results);
12
+ const _RuleCommon = require("./RuleCommon");
13
+ let LoopRuleCommon = class LoopRuleCommon extends _RuleCommon.RuleCommon {
14
+ execute(flow, options, suppressions = []) {
15
+ return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
16
+ const loopElements = this.findLoopElements(flow);
17
+ if (!loopElements.length) {
18
+ return new _internals.RuleResult(this, []);
19
+ }
20
+ const statementsInLoops = this.findStatementsInLoops(flow, loopElements);
21
+ const results = statementsInLoops.filter((det)=>!suppSet.has(det.name)).map((det)=>new _internals.ResultDetails(det));
22
+ return new _internals.RuleResult(this, results);
23
+ });
22
24
  }
23
25
  findLoopElements(flow) {
24
26
  var _flow_elements;
@@ -39,10 +41,11 @@ let LoopRuleCommon = class LoopRuleCommon extends _AdvancedRule.AdvancedRule {
39
41
  };
40
42
  for (const element of loopElements){
41
43
  const loopEnd = this.findLoopEnd(element);
42
- // decide if we should count fault connectors as a violation
43
- // if (typeof element.element === "object" && "faultConnector" in (element.element as object)) {}
44
44
  new _internals.Compiler().traverseFlow(flow, element.name, findStatement, loopEnd);
45
45
  }
46
46
  return statementsInLoops;
47
47
  }
48
+ constructor(info){
49
+ super(info);
50
+ }
48
51
  };
@@ -1,4 +1,5 @@
1
1
  import { RuleInfo } from "./RuleInfo";
2
+ import * as core from "../internals/internals";
2
3
  export declare class RuleCommon {
3
4
  autoFixable: boolean;
4
5
  description: string;
@@ -7,13 +8,14 @@ export declare class RuleCommon {
7
8
  path: string;
8
9
  }>;
9
10
  isConfigurable: boolean;
10
- label: any;
11
- name: any;
12
- severity?: any;
11
+ label: string;
12
+ name: string;
13
+ severity?: string;
13
14
  supportedTypes: string[];
14
15
  suppressionElement?: string;
15
- uri: any;
16
+ uri?: string;
16
17
  constructor(info: RuleInfo, optional?: {
17
18
  severity?: string;
18
19
  });
20
+ protected executeWithSuppression<T extends any[]>(flow: core.Flow, options: object | undefined, suppressions: string[], executeLogic: (suppSet: Set<string>) => core.RuleResult): core.RuleResult;
19
21
  }
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "RuleCommon", {
8
8
  return RuleCommon;
9
9
  }
10
10
  });
11
+ const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
11
12
  function _define_property(obj, key, value) {
12
13
  if (key in obj) {
13
14
  Object.defineProperty(obj, key, {
@@ -21,7 +22,56 @@ function _define_property(obj, key, value) {
21
22
  }
22
23
  return obj;
23
24
  }
25
+ function _getRequireWildcardCache(nodeInterop) {
26
+ if (typeof WeakMap !== "function") return null;
27
+ var cacheBabelInterop = new WeakMap();
28
+ var cacheNodeInterop = new WeakMap();
29
+ return (_getRequireWildcardCache = function(nodeInterop) {
30
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
31
+ })(nodeInterop);
32
+ }
33
+ function _interop_require_wildcard(obj, nodeInterop) {
34
+ if (!nodeInterop && obj && obj.__esModule) {
35
+ return obj;
36
+ }
37
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
38
+ return {
39
+ default: obj
40
+ };
41
+ }
42
+ var cache = _getRequireWildcardCache(nodeInterop);
43
+ if (cache && cache.has(obj)) {
44
+ return cache.get(obj);
45
+ }
46
+ var newObj = {
47
+ __proto__: null
48
+ };
49
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
50
+ for(var key in obj){
51
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
52
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
53
+ if (desc && (desc.get || desc.set)) {
54
+ Object.defineProperty(newObj, key, desc);
55
+ } else {
56
+ newObj[key] = obj[key];
57
+ }
58
+ }
59
+ }
60
+ newObj.default = obj;
61
+ if (cache) {
62
+ cache.set(obj, newObj);
63
+ }
64
+ return newObj;
65
+ }
24
66
  let RuleCommon = class RuleCommon {
67
+ // NEW: Centralized suppression logic
68
+ executeWithSuppression(flow, options, suppressions, executeLogic) {
69
+ if (suppressions.includes("*")) {
70
+ return new _internals.RuleResult(this, []);
71
+ }
72
+ const suppSet = new Set(suppressions);
73
+ return executeLogic(suppSet);
74
+ }
25
75
  constructor(info, optional){
26
76
  _define_property(this, "autoFixable", void 0);
27
77
  _define_property(this, "description", void 0);
@@ -1,8 +1,9 @@
1
1
  import * as core from "../internals/internals";
2
- import { AdvancedRule } from "../models/AdvancedRule";
3
- export declare class APIVersion extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class APIVersion extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
6
  execute(flow: core.Flow, options?: {
6
7
  expression: string;
7
- }): core.RuleResult;
8
+ }, suppressions?: string[]): core.RuleResult;
8
9
  }
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "APIVersion", {
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,26 +51,32 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  }
52
52
  return newObj;
53
53
  }
54
- let APIVersion = class APIVersion extends _AdvancedRule.AdvancedRule {
55
- execute(flow, options) {
56
- let flowAPIVersionNumber = null;
57
- if (flow.xmldata.apiVersion) {
58
- const flowAPIVersion = flow.xmldata.apiVersion;
59
- flowAPIVersionNumber = +flowAPIVersion;
60
- }
61
- const results = [];
62
- if (!flowAPIVersionNumber) {
63
- results.push(new _internals.ResultDetails(new _internals.FlowAttribute("API Version <49", "apiVersion", "<49")));
64
- return new _internals.RuleResult(this, results);
65
- }
66
- if (options && options.expression) {
67
- // eslint-disable-next-line sonarjs/code-eval
68
- const isApiNumberMoreThanConfiguredExpression = new Function(`return ${flowAPIVersionNumber}${options.expression};`);
69
- if (!isApiNumberMoreThanConfiguredExpression()) {
70
- results.push(new _internals.ResultDetails(new _internals.FlowAttribute(`${flowAPIVersionNumber}`, "apiVersion", options.expression)));
54
+ let APIVersion = class APIVersion extends _RuleCommon.RuleCommon {
55
+ execute(flow, options, suppressions = []) {
56
+ return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
57
+ let flowAPIVersionNumber = null;
58
+ if (flow.xmldata.apiVersion) {
59
+ flowAPIVersionNumber = +flow.xmldata.apiVersion;
71
60
  }
72
- }
73
- return new _internals.RuleResult(this, results);
61
+ const results = [];
62
+ if (!flowAPIVersionNumber) {
63
+ const detail = new _internals.ResultDetails(new _internals.FlowAttribute("API Version <49", "apiVersion", "<49"));
64
+ if (!suppSet.has(detail.name)) {
65
+ results.push(detail);
66
+ }
67
+ return new _internals.RuleResult(this, results);
68
+ }
69
+ if (options === null || options === void 0 ? void 0 : options.expression) {
70
+ const isValid = new Function(`return ${flowAPIVersionNumber}${options.expression};`)();
71
+ if (!isValid) {
72
+ const detail = new _internals.ResultDetails(new _internals.FlowAttribute(`${flowAPIVersionNumber}`, "apiVersion", options.expression));
73
+ if (!suppSet.has(detail.name)) {
74
+ results.push(detail);
75
+ }
76
+ }
77
+ }
78
+ return new _internals.RuleResult(this, results);
79
+ });
74
80
  }
75
81
  constructor(){
76
82
  super({
@@ -31,8 +31,6 @@ let ActionCallsInLoop = class ActionCallsInLoop extends _LoopRuleCommon.LoopRule
31
31
  label: "**Beta** Action Calls In Loop",
32
32
  name: "ActionCallsInLoop",
33
33
  supportedTypes: _internals.FlowType.backEndTypes
34
- }, {
35
- severity: "warning"
36
34
  });
37
35
  }
38
36
  };
@@ -1,8 +1,9 @@
1
1
  import * as core from "../internals/internals";
2
- import { AdvancedRule } from "../models/AdvancedRule";
3
- export declare class AutoLayout extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class AutoLayout extends RuleCommon implements IRuleDefinition {
4
5
  constructor();
5
6
  execute(flow: core.Flow, options?: {
6
7
  expression: string;
7
- }): core.RuleResult;
8
+ }, suppressions?: string[]): core.RuleResult;
8
9
  }
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "AutoLayout", {
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,18 +51,27 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
51
  }
52
52
  return newObj;
53
53
  }
54
- let AutoLayout = class AutoLayout extends _AdvancedRule.AdvancedRule {
55
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
56
- execute(flow, options) {
57
- if (flow.processMetadataValues) {
54
+ let AutoLayout = class AutoLayout extends _RuleCommon.RuleCommon {
55
+ execute(flow, options, suppressions = []) {
56
+ return this.executeWithSuppression(flow, options, suppressions, (suppSet)=>{
58
57
  var _CanvasMode_value;
58
+ if (!flow.processMetadataValues) {
59
+ return new _internals.RuleResult(this, []);
60
+ }
59
61
  const CanvasMode = flow.xmldata.processMetadataValues.find((mdv)=>mdv.name === "CanvasMode");
60
- const autoLayout = CanvasMode.value && typeof CanvasMode.value === "object" && CanvasMode.value.stringValue && CanvasMode.value.stringValue === "AUTO_LAYOUT_CANVAS";
61
- return !autoLayout ? new _internals.RuleResult(this, [
62
- new _internals.ResultDetails(new _internals.FlowAttribute((_CanvasMode_value = CanvasMode.value) === null || _CanvasMode_value === void 0 ? void 0 : _CanvasMode_value.stringValue, "CanvasMode", "!== AUTO_LAYOUT_CANVAS"))
63
- ]) : new _internals.RuleResult(this, []);
64
- }
65
- return new _internals.RuleResult(this, []);
62
+ const autoLayout = (CanvasMode === null || CanvasMode === void 0 ? void 0 : CanvasMode.value) && typeof CanvasMode.value === "object" && CanvasMode.value.stringValue === "AUTO_LAYOUT_CANVAS";
63
+ if (autoLayout) {
64
+ return new _internals.RuleResult(this, []);
65
+ }
66
+ var _CanvasMode_value_stringValue;
67
+ const detail = new _internals.ResultDetails(new _internals.FlowAttribute((_CanvasMode_value_stringValue = CanvasMode === null || CanvasMode === void 0 ? void 0 : (_CanvasMode_value = CanvasMode.value) === null || _CanvasMode_value === void 0 ? void 0 : _CanvasMode_value.stringValue) !== null && _CanvasMode_value_stringValue !== void 0 ? _CanvasMode_value_stringValue : "undefined", "CanvasMode", "!== AUTO_LAYOUT_CANVAS"));
68
+ if (suppSet.has(detail.name)) {
69
+ return new _internals.RuleResult(this, []);
70
+ }
71
+ return new _internals.RuleResult(this, [
72
+ detail
73
+ ]);
74
+ });
66
75
  }
67
76
  constructor(){
68
77
  super({
@@ -1,6 +1,7 @@
1
1
  import * as core from "../internals/internals";
2
- import { AdvancedRule } from "../models/AdvancedRule";
3
- export declare class CopyAPIName extends AdvancedRule implements core.IRuleDefinition {
2
+ import { RuleCommon } from "../models/RuleCommon";
3
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
4
+ export declare class CopyAPIName 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
  }