@flow-scanner/lightning-flow-scanner-core 6.3.1 → 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.
- package/README.md +23 -10
- package/index.d.ts +1 -2
- package/index.js +0 -4
- package/main/interfaces/IRuleDefinition.d.ts +2 -3
- package/main/interfaces/IRulesConfig.d.ts +1 -2
- package/main/libs/DynamicRule.d.ts +1 -2
- package/main/libs/ScanFlows.js +22 -51
- package/main/models/LoopRuleCommon.d.ts +6 -3
- package/main/models/LoopRuleCommon.js +15 -12
- package/main/models/RuleCommon.d.ts +6 -4
- package/main/models/RuleCommon.js +50 -0
- package/main/rules/APIVersion.d.ts +4 -3
- package/main/rules/APIVersion.js +26 -20
- package/main/rules/ActionCallsInLoop.js +0 -2
- package/main/rules/AutoLayout.d.ts +4 -3
- package/main/rules/AutoLayout.js +20 -11
- package/main/rules/CopyAPIName.d.ts +4 -3
- package/main/rules/CopyAPIName.js +14 -16
- package/main/rules/CyclomaticComplexity.d.ts +4 -3
- package/main/rules/CyclomaticComplexity.js +28 -25
- package/main/rules/DuplicateDMLOperation.d.ts +4 -3
- package/main/rules/DuplicateDMLOperation.js +54 -60
- package/main/rules/FlowDescription.d.ts +4 -3
- package/main/rules/FlowDescription.js +14 -8
- package/main/rules/FlowName.d.ts +6 -4
- package/main/rules/FlowName.js +19 -10
- package/main/rules/GetRecordAllFields.d.ts +4 -3
- package/main/rules/GetRecordAllFields.js +21 -23
- package/main/rules/HardcodedId.d.ts +4 -3
- package/main/rules/HardcodedId.js +15 -12
- package/main/rules/HardcodedUrl.d.ts +5 -4
- package/main/rules/HardcodedUrl.js +18 -14
- package/main/rules/InactiveFlow.d.ts +4 -3
- package/main/rules/InactiveFlow.js +12 -8
- package/main/rules/MissingFaultPath.d.ts +4 -6
- package/main/rules/MissingFaultPath.js +28 -40
- package/main/rules/MissingNullHandler.d.ts +4 -3
- package/main/rules/MissingNullHandler.js +69 -73
- package/main/rules/ProcessBuilder.d.ts +4 -3
- package/main/rules/ProcessBuilder.js +7 -4
- package/main/rules/RecursiveAfterUpdate.d.ts +4 -3
- package/main/rules/RecursiveAfterUpdate.js +35 -31
- package/main/rules/SameRecordFieldUpdates.d.ts +4 -3
- package/main/rules/SameRecordFieldUpdates.js +23 -19
- package/main/rules/TriggerOrder.d.ts +4 -3
- package/main/rules/TriggerOrder.js +14 -10
- package/main/rules/UnconnectedElement.d.ts +4 -3
- package/main/rules/UnconnectedElement.js +17 -20
- package/main/rules/UnsafeRunningContext.d.ts +4 -3
- package/main/rules/UnsafeRunningContext.js +15 -11
- package/main/rules/UnusedVariable.d.ts +4 -3
- package/main/rules/UnusedVariable.js +27 -29
- package/package.json +1 -1
- package/main/interfaces/AdvancedRuleConfig.d.ts +0 -11
- package/main/interfaces/AdvancedRuleConfig.js +0 -4
- package/main/interfaces/AdvancedRuleDefintion.d.ts +0 -5
- package/main/interfaces/AdvancedRuleDefintion.js +0 -4
- package/main/interfaces/AdvancedSuppression.d.ts +0 -21
- package/main/interfaces/AdvancedSuppression.js +0 -4
- package/main/libs/Scan2.d.ts +0 -3
- package/main/libs/Scan2.js +0 -124
- package/main/models/AdvancedRule.d.ts +0 -44
- 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
|
-
"
|
|
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:
|
|
@@ -279,11 +292,11 @@ _Runs all enabled rules and returns detailed violations._
|
|
|
279
292
|
|
|
280
293
|
_Automatically applies available fixes(removing variables and unconnected elements)._
|
|
281
294
|
|
|
282
|
-
#### [`exportDetails(results: ScanResult[]): FlatViolation[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/
|
|
295
|
+
#### [`exportDetails(results: ScanResult[]): FlatViolation[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/exportAsDetails.ts)
|
|
283
296
|
|
|
284
|
-
_Get
|
|
297
|
+
_Get output of violations only(Reserved for future use)._
|
|
285
298
|
|
|
286
|
-
#### [`exportSarif(results: ScanResult[]): string`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/
|
|
299
|
+
#### [`exportSarif(results: ScanResult[]): string`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/exportAsSarif.ts)
|
|
287
300
|
|
|
288
301
|
_Get SARIF output including exact line numbers of violations._
|
|
289
302
|
|
|
@@ -294,7 +307,7 @@ _Get SARIF output including exact line numbers of violations._
|
|
|
294
307
|
[](https://img.shields.io/github/stars/Flow-Scanner/lightning-flow-scanner-core)
|
|
295
308
|
[](https://gitHub.com/Flow-Scanner/lightning-flow-scanner-core/graphs/contributors/)
|
|
296
309
|
[](https://github.com/Flow-Scanner/lightning-flow-scanner-core/raw/main/LICENSE.md)
|
|
297
|
-
[](https://www.npmjs.com/package/lightning-flow-scanner)
|
|
310
|
+
[](https://www.npmjs.com/package/@flow-scanner/lightning-flow-scanner-core)
|
|
298
311
|
[](https://snyk.io/test/github/Flow-Scanner/lightning-flow-scanner-core)
|
|
299
312
|
|
|
300
313
|
**To install with npm:**
|
|
@@ -315,7 +328,7 @@ npm install @flow-scanner/lightning-flow-scanner-core
|
|
|
315
328
|
>
|
|
316
329
|
> Volta will automatically use the Node.js version defined in `package.json`.
|
|
317
330
|
|
|
318
|
-
1. Clone the
|
|
331
|
+
1. Clone the repository
|
|
319
332
|
|
|
320
333
|
```bash
|
|
321
334
|
git clone https://github.com/Flow-Scanner/lightning-flow-scanner-core.git
|
|
@@ -327,7 +340,7 @@ npm install @flow-scanner/lightning-flow-scanner-core
|
|
|
327
340
|
npm install
|
|
328
341
|
```
|
|
329
342
|
|
|
330
|
-
3.
|
|
343
|
+
3. Compile a new version:
|
|
331
344
|
|
|
332
345
|
```bash
|
|
333
346
|
npm run build
|
|
@@ -340,13 +353,13 @@ npm install @flow-scanner/lightning-flow-scanner-core
|
|
|
340
353
|
```
|
|
341
354
|
|
|
342
355
|
5. Test as local dependency(Optional):
|
|
343
|
-
|
|
356
|
+
a. run:
|
|
344
357
|
|
|
345
358
|
```bash
|
|
346
359
|
npm run link
|
|
347
360
|
```
|
|
348
361
|
|
|
349
|
-
b
|
|
362
|
+
b. Go to the dependent project (e.g. VSX or CLI) and use:
|
|
350
363
|
|
|
351
364
|
```bash
|
|
352
365
|
npm link @flow-scanner/lightning-flow-scanner-core
|
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 {
|
|
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 "../
|
|
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,
|
|
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?:
|
|
6
|
+
rules?: IRuleOptions;
|
|
8
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IRuleDefinition } from "../interfaces/IRuleDefinition";
|
|
2
|
-
|
|
3
|
-
export declare class DynamicRule<T extends AdvancedRule | IRuleDefinition> {
|
|
2
|
+
export declare class DynamicRule<T extends IRuleDefinition> {
|
|
4
3
|
constructor(className: string);
|
|
5
4
|
}
|
package/main/libs/ScanFlows.js
CHANGED
|
@@ -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
|
-
|
|
35
|
-
|
|
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,
|
|
49
|
-
ruleMap.set(ruleName,
|
|
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
|
-
|
|
60
|
-
|
|
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 {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
13
|
-
let LoopRuleCommon = class LoopRuleCommon extends
|
|
14
|
-
execute(flow) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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:
|
|
11
|
-
name:
|
|
12
|
-
severity?:
|
|
11
|
+
label: string;
|
|
12
|
+
name: string;
|
|
13
|
+
severity?: string;
|
|
13
14
|
supportedTypes: string[];
|
|
14
15
|
suppressionElement?: string;
|
|
15
|
-
uri
|
|
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 {
|
|
3
|
-
|
|
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
|
}
|
package/main/rules/APIVersion.js
CHANGED
|
@@ -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
|
|
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
|
|
55
|
-
execute(flow, options) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as core from "../internals/internals";
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
}
|
package/main/rules/AutoLayout.js
CHANGED
|
@@ -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
|
|
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
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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 {
|
|
3
|
-
|
|
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
|
}
|
|
@@ -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
|
|
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
|
|
55
|
-
execute(flow) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
66
|
-
|
|
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
|
-
|
|
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
|
}
|