@flow-scanner/lightning-flow-scanner-core 6.0.3
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/CONTRIBUTING.md +30 -0
- package/LICENSE.md +21 -0
- package/README.md +314 -0
- package/SECURITY.md +26 -0
- package/assets/media/bannerslim.png +0 -0
- package/index.d.ts +21 -0
- package/index.js +83 -0
- package/main/interfaces/AdvancedRuleConfig.d.ts +11 -0
- package/main/interfaces/AdvancedRuleConfig.js +4 -0
- package/main/interfaces/AdvancedRuleDefintion.d.ts +5 -0
- package/main/interfaces/AdvancedRuleDefintion.js +4 -0
- package/main/interfaces/AdvancedSuppression.d.ts +21 -0
- package/main/interfaces/AdvancedSuppression.js +4 -0
- package/main/interfaces/AutoFixable.d.ts +10 -0
- package/main/interfaces/AutoFixable.js +4 -0
- package/main/interfaces/IExceptions.d.ts +5 -0
- package/main/interfaces/IExceptions.js +4 -0
- package/main/interfaces/IRuleConfig.d.ts +3 -0
- package/main/interfaces/IRuleConfig.js +4 -0
- package/main/interfaces/IRuleDefinition.d.ts +17 -0
- package/main/interfaces/IRuleDefinition.js +4 -0
- package/main/interfaces/IRuleOptions.d.ts +4 -0
- package/main/interfaces/IRuleOptions.js +4 -0
- package/main/interfaces/IRulesConfig.d.ts +8 -0
- package/main/interfaces/IRulesConfig.js +4 -0
- package/main/internals/internals.d.ts +17 -0
- package/main/internals/internals.js +64 -0
- package/main/libs/BuildFlow.d.ts +1 -0
- package/main/libs/BuildFlow.js +20 -0
- package/main/libs/Compiler.d.ts +8 -0
- package/main/libs/Compiler.js +70 -0
- package/main/libs/ConvertFlowNodes.d.ts +1 -0
- package/main/libs/ConvertFlowNodes.js +14 -0
- package/main/libs/DynamicRule.d.ts +5 -0
- package/main/libs/DynamicRule.js +19 -0
- package/main/libs/FixFlows.d.ts +3 -0
- package/main/libs/FixFlows.js +110 -0
- package/main/libs/GetRuleDefinitions.d.ts +5 -0
- package/main/libs/GetRuleDefinitions.js +81 -0
- package/main/libs/ParseFlows.d.ts +2 -0
- package/main/libs/ParseFlows.js +111 -0
- package/main/libs/Scan2.d.ts +3 -0
- package/main/libs/Scan2.js +124 -0
- package/main/libs/ScanFlows.d.ts +4 -0
- package/main/libs/ScanFlows.js +103 -0
- package/main/models/AdvancedRule.d.ts +44 -0
- package/main/models/AdvancedRule.js +84 -0
- package/main/models/Flow.d.ts +33 -0
- package/main/models/Flow.js +277 -0
- package/main/models/FlowAttribute.d.ts +7 -0
- package/main/models/FlowAttribute.js +34 -0
- package/main/models/FlowElement.d.ts +10 -0
- package/main/models/FlowElement.js +37 -0
- package/main/models/FlowElementConnector.d.ts +15 -0
- package/main/models/FlowElementConnector.js +50 -0
- package/main/models/FlowMetadata.d.ts +4 -0
- package/main/models/FlowMetadata.js +16 -0
- package/main/models/FlowNode.d.ts +10 -0
- package/main/models/FlowNode.js +169 -0
- package/main/models/FlowResource.d.ts +5 -0
- package/main/models/FlowResource.js +30 -0
- package/main/models/FlowType.d.ts +23 -0
- package/main/models/FlowType.js +80 -0
- package/main/models/FlowVariable.d.ts +6 -0
- package/main/models/FlowVariable.js +31 -0
- package/main/models/LoopRuleCommon.d.ts +9 -0
- package/main/models/LoopRuleCommon.js +48 -0
- package/main/models/ParsedFlow.d.ts +7 -0
- package/main/models/ParsedFlow.js +35 -0
- package/main/models/ResultDetails.d.ts +10 -0
- package/main/models/ResultDetails.js +57 -0
- package/main/models/RuleCommon.d.ts +19 -0
- package/main/models/RuleCommon.js +48 -0
- package/main/models/RuleInfo.d.ts +55 -0
- package/main/models/RuleInfo.js +61 -0
- package/main/models/RuleResult.d.ts +11 -0
- package/main/models/RuleResult.js +44 -0
- package/main/models/ScanResult.d.ts +7 -0
- package/main/models/ScanResult.js +31 -0
- package/main/rules/APIVersion.d.ts +8 -0
- package/main/rules/APIVersion.js +86 -0
- package/main/rules/ActionCallsInLoop.d.ts +6 -0
- package/main/rules/ActionCallsInLoop.js +38 -0
- package/main/rules/AutoLayout.d.ts +8 -0
- package/main/rules/AutoLayout.js +78 -0
- package/main/rules/CopyAPIName.d.ts +6 -0
- package/main/rules/CopyAPIName.js +82 -0
- package/main/rules/CyclomaticComplexity.d.ts +10 -0
- package/main/rules/CyclomaticComplexity.js +111 -0
- package/main/rules/DMLStatementInLoop.d.ts +6 -0
- package/main/rules/DMLStatementInLoop.js +37 -0
- package/main/rules/DuplicateDMLOperation.d.ts +8 -0
- package/main/rules/DuplicateDMLOperation.js +153 -0
- package/main/rules/FlowDescription.d.ts +6 -0
- package/main/rules/FlowDescription.js +76 -0
- package/main/rules/FlowName.d.ts +7 -0
- package/main/rules/FlowName.js +80 -0
- package/main/rules/GetRecordAllFields.d.ts +6 -0
- package/main/rules/GetRecordAllFields.js +101 -0
- package/main/rules/HardcodedId.d.ts +6 -0
- package/main/rules/HardcodedId.js +87 -0
- package/main/rules/HardcodedUrl.d.ts +6 -0
- package/main/rules/HardcodedUrl.js +50 -0
- package/main/rules/InactiveFlow.d.ts +6 -0
- package/main/rules/InactiveFlow.js +73 -0
- package/main/rules/MissingFaultPath.d.ts +12 -0
- package/main/rules/MissingFaultPath.js +161 -0
- package/main/rules/MissingNullHandler.d.ts +6 -0
- package/main/rules/MissingNullHandler.js +152 -0
- package/main/rules/ProcessBuilder.d.ts +8 -0
- package/main/rules/ProcessBuilder.js +77 -0
- package/main/rules/RecursiveAfterUpdate.d.ts +7 -0
- package/main/rules/RecursiveAfterUpdate.js +124 -0
- package/main/rules/SOQLQueryInLoop.d.ts +6 -0
- package/main/rules/SOQLQueryInLoop.js +35 -0
- package/main/rules/SameRecordFieldUpdates.d.ts +7 -0
- package/main/rules/SameRecordFieldUpdates.js +111 -0
- package/main/rules/TriggerOrder.d.ts +7 -0
- package/main/rules/TriggerOrder.js +101 -0
- package/main/rules/UnconnectedElement.d.ts +7 -0
- package/main/rules/UnconnectedElement.js +93 -0
- package/main/rules/UnsafeRunningContext.d.ts +6 -0
- package/main/rules/UnsafeRunningContext.js +86 -0
- package/main/rules/UnusedVariable.d.ts +6 -0
- package/main/rules/UnusedVariable.js +100 -0
- package/main/store/DefaultRuleStore.d.ts +2 -0
- package/main/store/DefaultRuleStore.js +68 -0
- package/package.json +88 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "UnusedVariable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return UnusedVariable;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _AdvancedRule = require("../models/AdvancedRule");
|
|
12
|
+
const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
14
|
+
if (typeof WeakMap !== "function") return null;
|
|
15
|
+
var cacheBabelInterop = new WeakMap();
|
|
16
|
+
var cacheNodeInterop = new WeakMap();
|
|
17
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
18
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
19
|
+
})(nodeInterop);
|
|
20
|
+
}
|
|
21
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
22
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
26
|
+
return {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
31
|
+
if (cache && cache.has(obj)) {
|
|
32
|
+
return cache.get(obj);
|
|
33
|
+
}
|
|
34
|
+
var newObj = {
|
|
35
|
+
__proto__: null
|
|
36
|
+
};
|
|
37
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
+
for(var key in obj){
|
|
39
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
41
|
+
if (desc && (desc.get || desc.set)) {
|
|
42
|
+
Object.defineProperty(newObj, key, desc);
|
|
43
|
+
} else {
|
|
44
|
+
newObj[key] = obj[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
newObj.default = obj;
|
|
49
|
+
if (cache) {
|
|
50
|
+
cache.set(obj, newObj);
|
|
51
|
+
}
|
|
52
|
+
return newObj;
|
|
53
|
+
}
|
|
54
|
+
let UnusedVariable = class UnusedVariable extends _AdvancedRule.AdvancedRule {
|
|
55
|
+
execute(flow) {
|
|
56
|
+
const unusedVariables = [];
|
|
57
|
+
for (const variable of flow.elements.filter((node)=>node instanceof _internals.FlowVariable)){
|
|
58
|
+
const variableName = variable.name;
|
|
59
|
+
if ([
|
|
60
|
+
...JSON.stringify(flow.elements.filter((node)=>node instanceof _internals.FlowNode)).matchAll(new RegExp(variableName, "gi"))
|
|
61
|
+
].map((a)=>a.index).length === 0) {
|
|
62
|
+
// if not found in any inside of flow elements
|
|
63
|
+
if ([
|
|
64
|
+
...JSON.stringify(flow.elements.filter((node)=>node instanceof _internals.FlowResource)).matchAll(new RegExp(variableName, "gi"))
|
|
65
|
+
].map((a)=>a.index).length === 0) {
|
|
66
|
+
const insideCounter = [
|
|
67
|
+
...JSON.stringify(variable).matchAll(new RegExp(variable.name, "gi"))
|
|
68
|
+
].map((a)=>a.index);
|
|
69
|
+
const variableUsage = [
|
|
70
|
+
...JSON.stringify(flow.elements.filter((node)=>node instanceof _internals.FlowVariable)).matchAll(new RegExp(variableName, "gi"))
|
|
71
|
+
].map((a)=>a.index);
|
|
72
|
+
// finally also checks indexes where name occurs in the variable itself and where name occurs in all variables
|
|
73
|
+
// when this is the same, variable must be unused.
|
|
74
|
+
if (variableUsage.length === insideCounter.length) {
|
|
75
|
+
unusedVariables.push(variable);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const results = [];
|
|
81
|
+
for (const det of unusedVariables){
|
|
82
|
+
results.push(new _internals.ResultDetails(det));
|
|
83
|
+
}
|
|
84
|
+
return new _internals.RuleResult(this, results);
|
|
85
|
+
}
|
|
86
|
+
constructor(){
|
|
87
|
+
super({
|
|
88
|
+
name: "UnusedVariable",
|
|
89
|
+
label: "Unused Variable",
|
|
90
|
+
description: "To maintain the efficiency and manageability of your Flow, it's advisable to avoid including unconnected variables that are not in use.",
|
|
91
|
+
supportedTypes: [
|
|
92
|
+
..._internals.FlowType.backEndTypes,
|
|
93
|
+
..._internals.FlowType.visualTypes
|
|
94
|
+
],
|
|
95
|
+
docRefs: [],
|
|
96
|
+
isConfigurable: false,
|
|
97
|
+
autoFixable: true
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get BetaRuleStore () {
|
|
13
|
+
return BetaRuleStore;
|
|
14
|
+
},
|
|
15
|
+
get DefaultRuleStore () {
|
|
16
|
+
return DefaultRuleStore;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _ActionCallsInLoop = require("../rules/ActionCallsInLoop");
|
|
20
|
+
const _APIVersion = require("../rules/APIVersion");
|
|
21
|
+
const _AutoLayout = require("../rules/AutoLayout");
|
|
22
|
+
const _CopyAPIName = require("../rules/CopyAPIName");
|
|
23
|
+
const _CyclomaticComplexity = require("../rules/CyclomaticComplexity");
|
|
24
|
+
const _DMLStatementInLoop = require("../rules/DMLStatementInLoop");
|
|
25
|
+
const _DuplicateDMLOperation = require("../rules/DuplicateDMLOperation");
|
|
26
|
+
const _FlowDescription = require("../rules/FlowDescription");
|
|
27
|
+
const _FlowName = require("../rules/FlowName");
|
|
28
|
+
const _GetRecordAllFields = require("../rules/GetRecordAllFields");
|
|
29
|
+
const _HardcodedId = require("../rules/HardcodedId");
|
|
30
|
+
const _HardcodedUrl = require("../rules/HardcodedUrl");
|
|
31
|
+
const _InactiveFlow = require("../rules/InactiveFlow");
|
|
32
|
+
const _MissingFaultPath = require("../rules/MissingFaultPath");
|
|
33
|
+
const _MissingNullHandler = require("../rules/MissingNullHandler");
|
|
34
|
+
const _ProcessBuilder = require("../rules/ProcessBuilder");
|
|
35
|
+
const _RecursiveAfterUpdate = require("../rules/RecursiveAfterUpdate");
|
|
36
|
+
const _SameRecordFieldUpdates = require("../rules/SameRecordFieldUpdates");
|
|
37
|
+
const _SOQLQueryInLoop = require("../rules/SOQLQueryInLoop");
|
|
38
|
+
const _TriggerOrder = require("../rules/TriggerOrder");
|
|
39
|
+
const _UnconnectedElement = require("../rules/UnconnectedElement");
|
|
40
|
+
const _UnsafeRunningContext = require("../rules/UnsafeRunningContext");
|
|
41
|
+
const _UnusedVariable = require("../rules/UnusedVariable");
|
|
42
|
+
const DefaultRuleStore = {
|
|
43
|
+
APIVersion: _APIVersion.APIVersion,
|
|
44
|
+
AutoLayout: _AutoLayout.AutoLayout,
|
|
45
|
+
CopyAPIName: _CopyAPIName.CopyAPIName,
|
|
46
|
+
CyclomaticComplexity: _CyclomaticComplexity.CyclomaticComplexity,
|
|
47
|
+
DMLStatementInLoop: _DMLStatementInLoop.DMLStatementInLoop,
|
|
48
|
+
DuplicateDMLOperation: _DuplicateDMLOperation.DuplicateDMLOperation,
|
|
49
|
+
FlowDescription: _FlowDescription.FlowDescription,
|
|
50
|
+
FlowName: _FlowName.FlowName,
|
|
51
|
+
GetRecordAllFields: _GetRecordAllFields.GetRecordAllFields,
|
|
52
|
+
HardcodedId: _HardcodedId.HardcodedId,
|
|
53
|
+
HardcodedUrl: _HardcodedUrl.HardcodedUrl,
|
|
54
|
+
InactiveFlow: _InactiveFlow.InactiveFlow,
|
|
55
|
+
MissingFaultPath: _MissingFaultPath.MissingFaultPath,
|
|
56
|
+
MissingNullHandler: _MissingNullHandler.MissingNullHandler,
|
|
57
|
+
ProcessBuilder: _ProcessBuilder.ProcessBuilder,
|
|
58
|
+
RecursiveAfterUpdate: _RecursiveAfterUpdate.RecursiveAfterUpdate,
|
|
59
|
+
SameRecordFieldUpdates: _SameRecordFieldUpdates.SameRecordFieldUpdates,
|
|
60
|
+
SOQLQueryInLoop: _SOQLQueryInLoop.SOQLQueryInLoop,
|
|
61
|
+
TriggerOrder: _TriggerOrder.TriggerOrder,
|
|
62
|
+
UnconnectedElement: _UnconnectedElement.UnconnectedElement,
|
|
63
|
+
UnsafeRunningContext: _UnsafeRunningContext.UnsafeRunningContext,
|
|
64
|
+
UnusedVariable: _UnusedVariable.UnusedVariable
|
|
65
|
+
};
|
|
66
|
+
const BetaRuleStore = {
|
|
67
|
+
ActionCallsInLoop: _ActionCallsInLoop.ActionCallsInLoop
|
|
68
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flow-scanner/lightning-flow-scanner-core",
|
|
3
|
+
"description": "A purpose-built engine for Flow metadata in Node.js and browser environments. Assess and enhance Salesforce Flow automations for best practices, security, governor limits, and performance issues.",
|
|
4
|
+
"version": "6.0.3",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": "^18 || ^20 || ^22 || ^23"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"clean": "rm -rf out",
|
|
12
|
+
"build:js": "swc src --out-dir out --copy-files --strip-leading-paths --config-file .swcrc",
|
|
13
|
+
"build:types": "tsc -p tsconfig.types.json --declaration --emitDeclarationOnly --outDir out",
|
|
14
|
+
"copy:index": "cp out/main/index.js out/index.js || true",
|
|
15
|
+
"copy:media": "mkdir -p out/assets/media && cp -r assets/media/* out/assets/media/ || true",
|
|
16
|
+
"copy:root-files:out": "cp README.md LICENSE.md SECURITY.md CONTRIBUTING.md package.json out/ || true",
|
|
17
|
+
"copy:root-files:dist": "cp LICENSE.md dist/ || true",
|
|
18
|
+
"____main____": "__DEVELOPER COMMANDS__",
|
|
19
|
+
"build": "npm run clean && npm run build:js && npm run build:types && npm run copy:index && npm run copy:media && npm run copy:root-files:out",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"lint": "eslint src tests",
|
|
22
|
+
"link": "npm run build && npm link ./out",
|
|
23
|
+
"____pack____": "PACKAGING COMMANDS__",
|
|
24
|
+
"swc:sim:pack": "npm run build",
|
|
25
|
+
"vite:dist": "npm run build:js && vite build && npm run copy:root-files:dist",
|
|
26
|
+
"test:vite": "vitest",
|
|
27
|
+
"prepare": "husky",
|
|
28
|
+
"precommit": "lint-staged",
|
|
29
|
+
"prepush": "npm run build && npm test",
|
|
30
|
+
"stryker": "npm i -g @stryker-mutator/core @stryker-mutator/jest-runner && stryker run"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/Flow-Scanner/lightning-flow-scanner-core.git"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"fast-xml-parser": "^5.3.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@jest/types": "30.0.1",
|
|
42
|
+
"@swc-node/jest": "1.9.1",
|
|
43
|
+
"@swc/cli": "0.7.7",
|
|
44
|
+
"@swc/core": "1.13.5",
|
|
45
|
+
"@swc/helpers": "0.5.17",
|
|
46
|
+
"@types/jest": "29.5.14",
|
|
47
|
+
"@types/node": "22.15.30",
|
|
48
|
+
"@types/semantic-release": "20.0.6",
|
|
49
|
+
"eslint": "9.30.0",
|
|
50
|
+
"eslint-plugin-de-morgan": "1.3.0",
|
|
51
|
+
"eslint-plugin-github": "6.0.0",
|
|
52
|
+
"eslint-plugin-jest": "29.0.1",
|
|
53
|
+
"eslint-plugin-perfectionist": "4.15.0",
|
|
54
|
+
"eslint-plugin-sonarjs": "3.0.4",
|
|
55
|
+
"husky": "9.1.7",
|
|
56
|
+
"jest": "30.0.3",
|
|
57
|
+
"lint-staged": "^16.1.2",
|
|
58
|
+
"prettier": "3.6.2",
|
|
59
|
+
"ts-node": "10.9.2",
|
|
60
|
+
"typescript": "5.8.3",
|
|
61
|
+
"typescript-eslint": "8.35.0",
|
|
62
|
+
"vite": "6.4.1",
|
|
63
|
+
"vite-plugin-node-polyfills": "0.23.0",
|
|
64
|
+
"vitest": "3.2.4"
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://flow-scanner.github.io/lightning-flow-scanner-core",
|
|
67
|
+
"author": {
|
|
68
|
+
"name": "Ruben Halman",
|
|
69
|
+
"url": "https://github.com/RubenHalman"
|
|
70
|
+
},
|
|
71
|
+
"volta": {
|
|
72
|
+
"node": "20.13.1"
|
|
73
|
+
},
|
|
74
|
+
"keywords": [
|
|
75
|
+
"salesforce",
|
|
76
|
+
"flow",
|
|
77
|
+
"linter",
|
|
78
|
+
"salesforce-flow",
|
|
79
|
+
"flow-linter",
|
|
80
|
+
"flow-scanner",
|
|
81
|
+
"static-analysis",
|
|
82
|
+
"code-quality",
|
|
83
|
+
"security-scanner",
|
|
84
|
+
"flow-builder",
|
|
85
|
+
"salesforce-devops",
|
|
86
|
+
"best-practices"
|
|
87
|
+
]
|
|
88
|
+
}
|