@flow-scanner/lightning-flow-scanner-core 6.13.0 → 6.13.2
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 +200 -142
- package/main/libs/ScanFlows.js +0 -3
- package/main/models/RuleCommon.js +1 -1
- package/main/models/RuleResult.js +1 -1
- package/main/rules/APIVersion.js +1 -1
- package/main/rules/ActionCallsInLoop.js +3 -3
- package/main/rules/AutoLayout.js +2 -2
- package/main/rules/CopyAPIName.js +1 -1
- package/main/rules/DMLStatementInLoop.js +1 -1
- package/main/rules/DuplicateDMLOperation.js +1 -1
- package/main/rules/FlowDescription.js +1 -1
- package/main/rules/FlowName.js +1 -1
- package/main/rules/GetRecordAllFields.js +2 -2
- package/main/rules/HardcodedId.js +1 -1
- package/main/rules/HardcodedUrl.js +1 -1
- package/main/rules/InactiveFlow.js +1 -1
- package/main/rules/MissingFaultPath.js +1 -1
- package/main/rules/MissingMetadataDescription.js +1 -1
- package/main/rules/MissingNullHandler.js +1 -1
- package/main/rules/MissingRecordTriggerFilter.js +4 -2
- package/main/rules/ProcessBuilder.js +2 -2
- package/main/rules/RecordIdAsString.js +2 -2
- package/main/rules/RecursiveAfterUpdate.js +1 -1
- package/main/rules/SOQLQueryInLoop.js +1 -1
- package/main/rules/SameRecordFieldUpdates.js +1 -1
- package/main/rules/TransformInsteadOfLoop.js +1 -1
- package/main/rules/TriggerOrder.js +2 -2
- package/main/rules/UnconnectedElement.js +1 -1
- package/main/rules/UnusedVariable.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,140 +52,196 @@
|
|
|
52
52
|
|
|
53
53
|
> Want to code a new rule? → See [How to Write a Rule](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/docs/write-a-rule.md)
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
**
|
|
68
|
-
**Severity:**
|
|
69
|
-
|
|
70
|
-
###
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
_[
|
|
82
|
-
**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
**Rule ID:** `invalid-naming-convention`
|
|
88
|
-
**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
**
|
|
103
|
-
**Severity:** 🔴 *Error*
|
|
104
|
-
|
|
105
|
-
###
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
_[
|
|
117
|
-
**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
**Rule ID:** `
|
|
123
|
-
**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
**
|
|
138
|
-
**Severity:** 🟡 *Warning*
|
|
139
|
-
|
|
140
|
-
### Missing Trigger
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
_[
|
|
152
|
-
**
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
**Rule ID:** `
|
|
158
|
-
**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
**
|
|
173
|
-
**Severity:** 🔵 *Note*
|
|
174
|
-
|
|
175
|
-
###
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
_[
|
|
187
|
-
**
|
|
188
|
-
|
|
55
|
+
<!-- START GENERATED_RULES -->
|
|
56
|
+
### Action Call In A Loop
|
|
57
|
+
To prevent exceeding Apex governor limits, it is advisable to consolidate and bulkify your apex calls, utilizing a single action call containing a collection variable at the end of the loop.
|
|
58
|
+
|
|
59
|
+
**Rule ID:** `action-call-in-loop`
|
|
60
|
+
**Class Name:** _[ActionCallsInLoop](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/ActionCallsInLoop.ts)_
|
|
61
|
+
**Severity:** 🔴 *Error*
|
|
62
|
+
|
|
63
|
+
### DML Statement In A Loop
|
|
64
|
+
To prevent exceeding Apex governor limits, consolidate all your database operations—record creation, updates, or deletions—at the conclusion of the flow.
|
|
65
|
+
|
|
66
|
+
**Rule ID:** `dml-in-loop`
|
|
67
|
+
**Class Name:** _[DMLStatementInLoop](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/DMLStatementInLoop.ts)_
|
|
68
|
+
**Severity:** 🔴 *Error*
|
|
69
|
+
|
|
70
|
+
### Duplicate DML Operation
|
|
71
|
+
When a flow executes database changes or actions between two screens, prevent users from navigating backward between screens; otherwise, duplicate database operations may be performed.
|
|
72
|
+
|
|
73
|
+
**Rule ID:** `duplicate-dml`
|
|
74
|
+
**Class Name:** _[DuplicateDMLOperation](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/DuplicateDMLOperation.ts)_
|
|
75
|
+
**Severity:** 🟡 *Warning*
|
|
76
|
+
|
|
77
|
+
### Excessive Cyclomatic Complexity
|
|
78
|
+
The number of loops and decision rules, plus the number of decisions. Use a combination of 1) subflows and 2) breaking flows into multiple concise trigger ordered flows, to reduce the cyclomatic complexity within a single flow, ensuring maintainability and simplicity.
|
|
79
|
+
|
|
80
|
+
**Rule ID:** `excessive-cyclomatic-complexity`
|
|
81
|
+
**Class Name:** _[CyclomaticComplexity](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/CyclomaticComplexity.ts)_
|
|
82
|
+
**Severity:** 🔵 *Note*
|
|
83
|
+
|
|
84
|
+
### Flow Naming Convention
|
|
85
|
+
The readability of a flow is paramount. Establishing a naming convention significantly enhances findability, searchability, and overall consistency. Include at least a domain and a brief description of the flow’s actions, for example `Service_OrderFulfillment`.
|
|
86
|
+
|
|
87
|
+
**Rule ID:** `invalid-naming-convention`
|
|
88
|
+
**Class Name:** _[FlowName](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/FlowName.ts)_
|
|
89
|
+
**Severity:** 🔴 *Error*
|
|
90
|
+
|
|
91
|
+
### Get Record All Fields
|
|
92
|
+
Following the principle of least privilege (PoLP), avoid using **Get Records** with “Automatically store all fields” unless necessary.
|
|
93
|
+
|
|
94
|
+
**Rule ID:** `get-record-all-fields`
|
|
95
|
+
**Class Name:** _[GetRecordAllFields](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/GetRecordAllFields.ts)_
|
|
96
|
+
**Severity:** 🟡 *Warning*
|
|
97
|
+
|
|
98
|
+
### Hardcoded Id
|
|
99
|
+
Avoid hard-coding IDs because they are org specific. Instead, pass them into variables at the start of the flow—via merge-field URL parameters or a **Get Records** element.
|
|
100
|
+
|
|
101
|
+
**Rule ID:** `hardcoded-id`
|
|
102
|
+
**Class Name:** _[HardcodedId](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/HardcodedId.ts)_
|
|
103
|
+
**Severity:** 🔴 *Error*
|
|
104
|
+
|
|
105
|
+
### Hardcoded Url
|
|
106
|
+
Avoid hard-coding URLs because they are environment specific. Use an `$API` formula (preferred) or environment-specific sources like custom labels, metadata, or settings.
|
|
107
|
+
|
|
108
|
+
**Rule ID:** `hardcoded-url`
|
|
109
|
+
**Class Name:** _[HardcodedUrl](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/HardcodedUrl.ts)_
|
|
110
|
+
**Severity:** 🔴 *Error*
|
|
111
|
+
|
|
112
|
+
### Inactive Flow
|
|
113
|
+
Like cleaning out your closet: deleting unused flows is essential. Inactive flows can still cause trouble—such as accidentally deleting records during testing, or being activated as subflows.
|
|
114
|
+
|
|
115
|
+
**Rule ID:** `inactive-flow`
|
|
116
|
+
**Class Name:** _[InactiveFlow](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/InactiveFlow.ts)_
|
|
117
|
+
**Severity:** 🟡 *Warning*
|
|
118
|
+
|
|
119
|
+
### Invalid API Version
|
|
120
|
+
Introducing newer API components may lead to unexpected issues with older versions of Flows, as they might not align with the underlying mechanics. Starting from API version 50.0, the **Api Version** attribute has been readily available on the Flow Object. To ensure smooth operation and reduce discrepancies between API versions, it is strongly advised to regularly update and maintain them.
|
|
121
|
+
|
|
122
|
+
**Rule ID:** `invalid-api-version`
|
|
123
|
+
**Class Name:** _[APIVersion](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/APIVersion.ts)_
|
|
124
|
+
**Severity:** 🟡 *Warning*
|
|
125
|
+
|
|
126
|
+
### Missing Auto Layout
|
|
127
|
+
With Canvas Mode set to Auto-Layout, elements are spaced, connected, and aligned automatically, keeping your Flow neatly organized—saving you time.
|
|
128
|
+
|
|
129
|
+
**Rule ID:** `missing-auto-layout`
|
|
130
|
+
**Class Name:** _[AutoLayout](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/AutoLayout.ts)_
|
|
131
|
+
**Severity:** 🔵 *Note*
|
|
132
|
+
|
|
133
|
+
### Missing Fault Path
|
|
134
|
+
A flow may fail to execute an operation as intended. By default, the flow displays an error to the user and emails the creator. Customize this behavior by incorporating a Fault Path.
|
|
135
|
+
|
|
136
|
+
**Rule ID:** `missing-fault-path`
|
|
137
|
+
**Class Name:** _[MissingFaultPath](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/MissingFaultPath.ts)_
|
|
138
|
+
**Severity:** 🟡 *Warning*
|
|
139
|
+
|
|
140
|
+
### Missing Filter Record Trigger 
|
|
141
|
+
Record-triggered flows that lack filters on changed fields or entry conditions can lead to unnecessary executions on every record change. This may degrade system performance, hit governor limits faster, and increase resource consumption in high-volume orgs.
|
|
142
|
+
|
|
143
|
+
**Rule ID:** `missing-record-trigger-filter`
|
|
144
|
+
**Class Name:** _[MissingFilterRecordTrigger](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/MissingFilterRecordTrigger.ts)_
|
|
145
|
+
**Severity:** 🟡 *Warning*
|
|
146
|
+
|
|
147
|
+
### Missing Flow Description
|
|
148
|
+
Descriptions play a vital role in documentation. It is highly recommended to include details about where a flow is used and its intended purpose.
|
|
149
|
+
|
|
150
|
+
**Rule ID:** `missing-flow-description`
|
|
151
|
+
**Class Name:** _[FlowDescription](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/FlowDescription.ts)_
|
|
152
|
+
**Severity:** 🔴 *Error*
|
|
153
|
+
|
|
154
|
+
### Missing Metadata Description 
|
|
155
|
+
Flags Flow elements (Get Records, Assignments, Decisions, Actions, etc.) and metadata components (Variables, Formulas, Constants, Text Templates) that lack a description. Adding concise descriptions greatly improves readability, maintainability, and helps AI tools understand your automation intent.
|
|
156
|
+
|
|
157
|
+
**Rule ID:** `missing-metadata-description`
|
|
158
|
+
**Class Name:** _[MissingMetadataDescription](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/MissingMetadataDescription.ts)_
|
|
159
|
+
**Severity:** 🔴 *Error*
|
|
160
|
+
|
|
161
|
+
### Missing Null Handler
|
|
162
|
+
When a **Get Records** operation finds no data, it returns `null`. Validate data by using a Decision element to check for a non-null result.
|
|
163
|
+
|
|
164
|
+
**Rule ID:** `missing-null-handler`
|
|
165
|
+
**Class Name:** _[MissingNullHandler](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/MissingNullHandler.ts)_
|
|
166
|
+
**Severity:** 🟡 *Warning*
|
|
167
|
+
|
|
168
|
+
### Missing Trigger Order
|
|
169
|
+
Guarantee your flow execution order with the **Trigger Order** property introduced in Spring '22.value to their flows and guarantee their execution order. This priority value is not an absolute value, so the values need not be sequentially numbered as 1, 2, 3, and so on.
|
|
170
|
+
|
|
171
|
+
**Rule ID:** `unspecified-trigger-order`
|
|
172
|
+
**Class Name:** _[TriggerOrder](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/TriggerOrder.ts)_
|
|
173
|
+
**Severity:** 🔵 *Note*
|
|
174
|
+
|
|
175
|
+
### Process Builder
|
|
176
|
+
Salesforce is transitioning away from Workflow Rules and Process Builder in favor of Flow. Begin migrating your organization’s automation to Flow.
|
|
177
|
+
|
|
178
|
+
**Rule ID:** `process-builder-usage`
|
|
179
|
+
**Class Name:** _[ProcessBuilder](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/ProcessBuilder.ts)_
|
|
180
|
+
**Severity:** 🟡 *Warning*
|
|
181
|
+
|
|
182
|
+
### Record ID as String 
|
|
183
|
+
Detects flows using a String variable named `recordId` as input when they could receive the entire record object instead. Since recent Salesforce releases, record pages and quick actions can pass the complete record, eliminating the need for an additional Get Records query and improving performance.
|
|
184
|
+
|
|
185
|
+
**Rule ID:** `record-id-as-string`
|
|
186
|
+
**Class Name:** _[RecordIdAsString](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/RecordIdAsString.ts)_
|
|
187
|
+
**Severity:** 🔴 *Error*
|
|
188
|
+
|
|
189
|
+
### Recursive After Update
|
|
190
|
+
After-update flows are meant for modifying **other** records. Using them on the same record can cause recursion. Consider **before-save** flows for same-record updates.
|
|
191
|
+
|
|
192
|
+
**Rule ID:** `recursive-record-update`
|
|
193
|
+
**Class Name:** _[RecursiveAfterUpdate](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/RecursiveAfterUpdate.ts)_
|
|
194
|
+
**Severity:** 🟡 *Warning*
|
|
195
|
+
|
|
196
|
+
### Same Record Field Updates
|
|
197
|
+
Similar to triggers, **before-save** contexts can update the same record via `$Record` without invoking DML.
|
|
198
|
+
|
|
199
|
+
**Rule ID:** `same-record-field-updates`
|
|
200
|
+
**Class Name:** _[SameRecordFieldUpdates](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/SameRecordFieldUpdates.ts)_
|
|
201
|
+
**Severity:** 🟡 *Warning*
|
|
202
|
+
|
|
203
|
+
### SOQL Query In A Loop
|
|
204
|
+
To prevent exceeding Apex governor limits, consolidate all SOQL queries at the end of the flow.
|
|
205
|
+
|
|
206
|
+
**Rule ID:** `soql-in-loop`
|
|
207
|
+
**Class Name:** _[SOQLQueryInLoop](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/SOQLQueryInLoop.ts)_
|
|
208
|
+
**Severity:** 🔴 *Error*
|
|
209
|
+
|
|
210
|
+
### Transform Instead of Loop 
|
|
211
|
+
Detects Loop elements that directly connect to Assignment elements. Transform elements handle collection manipulation in bulk operations, providing significant performance improvements over iterative loop-assignment patterns.
|
|
212
|
+
|
|
213
|
+
**Rule ID:** `transform-instead-of-loop`
|
|
214
|
+
**Class Name:** _[TransformInsteadOfLoop](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/TransformInsteadOfLoop.ts)_
|
|
215
|
+
**Severity:** 🔵 *Note*
|
|
216
|
+
|
|
217
|
+
### Unclear API Name
|
|
218
|
+
Maintaining multiple elements with a similar name, like `Copy_X_Of_Element`, can diminish the overall readability of your Flow. When copying and pasting these elements, remember to update the API name of the newly created copy.
|
|
219
|
+
|
|
220
|
+
**Rule ID:** `unclear-api-naming`
|
|
221
|
+
**Class Name:** _[CopyAPIName](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/CopyAPIName.ts)_
|
|
222
|
+
**Severity:** 🟡 *Warning*
|
|
223
|
+
|
|
224
|
+
### Unreachable Element
|
|
225
|
+
Avoid unconnected elements that are not used by the flow to keep flows efficient and maintainable.
|
|
226
|
+
|
|
227
|
+
**Rule ID:** `unreachable-element`
|
|
228
|
+
**Class Name:** _[UnconnectedElement](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/UnconnectedElement.ts)_
|
|
229
|
+
**Severity:** 🟡 *Warning*
|
|
230
|
+
|
|
231
|
+
### Unsafe Running Context
|
|
232
|
+
This flow is configured to run in System Mode without Sharing. This system context grants all running users the permission to view and edit all data in your org. Running a flow in System Mode without Sharing can lead to unsafe data access.
|
|
233
|
+
|
|
234
|
+
**Rule ID:** `unsafe-running-context`
|
|
235
|
+
**Class Name:** _[UnsafeRunningContext](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/UnsafeRunningContext.ts)_
|
|
236
|
+
**Severity:** 🔴 *Error*
|
|
237
|
+
|
|
238
|
+
### Unused Variable
|
|
239
|
+
To maintain efficiency and manageability, avoid including variables that are never referenced.
|
|
240
|
+
|
|
241
|
+
**Rule ID:** `unused-variable`
|
|
242
|
+
**Class Name:** _[UnusedVariable](https://github.com/Flow-Scanner/lightning-flow-scanner/blob/main/packages/core/src/main/rules/UnusedVariable.ts)_
|
|
243
|
+
**Severity:** 🟡 *Warning*
|
|
244
|
+
<!-- END GENERATED_RULES -->
|
|
189
245
|
|
|
190
246
|
---
|
|
191
247
|
|
|
@@ -326,7 +382,7 @@ By default, Lightning Flow Scanner runs **all** default rules and merges any cus
|
|
|
326
382
|
**Privacy:** Zero user data collected. All processing is client-side. → See our [Security Policy](https://github.com/Flow-Scanner/lightning-flow-scanner?tab=security-ov-file).
|
|
327
383
|
|
|
328
384
|
### CICD Templates
|
|
329
|
-
Ready-to-use CI/CD templates and a **Copado Plugin**.
|
|
385
|
+
Ready-to-use CI/CD templates and a **Copado Plugin**.
|
|
330
386
|
|
|
331
387
|
| Platform | Type | Link |
|
|
332
388
|
|----------------|-----------------------------------|------|
|
|
@@ -369,6 +425,8 @@ Add a GitHub workflow file `.github/workflows/scan-flows.yml` to detect issues d
|
|
|
369
425
|
- name: Lightning Flow Scan
|
|
370
426
|
id: flowscanner
|
|
371
427
|
uses: Flow-Scanner/lightning-flow-scanner@main
|
|
428
|
+
with:
|
|
429
|
+
sarif-only: true # Strict mode for PRs
|
|
372
430
|
|
|
373
431
|
- name: Upload SARIF to Code Scanning
|
|
374
432
|
uses: github/codeql-action/upload-sarif@v3
|
|
@@ -388,12 +446,12 @@ parse("flows/*.xml").then(scan);
|
|
|
388
446
|
|
|
389
447
|
// Get SARIF output (e.g. for GitHub Code Scanning)
|
|
390
448
|
import { parse, scan, exportSarif } from "@flow-scanner/lightning-flow-scanner-core";
|
|
391
|
-
parse("flows/**/*.flow-meta.xml").then(scan).then(exportSarif)
|
|
449
|
+
parse("flows/**/*.flow-meta.xml").then(scan).then(exportSarif)
|
|
392
450
|
// .then(sarif => fs.writeFile("results.sarif", sarif))
|
|
393
451
|
|
|
394
452
|
// Generate Markdown documentation with Mermaid flow diagrams
|
|
395
453
|
import { parse, exportDiagram } from "@flow-scanner/lightning-flow-scanner-core";
|
|
396
|
-
parse("flows/**/*.flow-meta.xml").then(exportDiagram)
|
|
454
|
+
parse("flows/**/*.flow-meta.xml").then(exportDiagram)
|
|
397
455
|
// .then(md => fs.writeFile("flow-docs.md", md))
|
|
398
456
|
|
|
399
457
|
// Browser Usage (Tooling API)
|
|
@@ -413,13 +471,13 @@ For more on Programmatic API, types, and advanced usage of `@flow-scanner/lightn
|
|
|
413
471
|
|
|
414
472
|
> This project optionally uses [Volta](https://volta.sh) to guarantee the exact same Node.js and tool versions for every contributor.
|
|
415
473
|
>
|
|
416
|
-
> MacOs/Linux:
|
|
474
|
+
> MacOs/Linux:
|
|
417
475
|
> ```sh
|
|
418
476
|
> curl https://get.volta.sh | bash
|
|
419
477
|
> ```
|
|
420
478
|
> Windows:
|
|
421
479
|
> ```sh
|
|
422
|
-
> winget install Volta.Volta
|
|
480
|
+
> winget install Volta.Volta
|
|
423
481
|
> ```
|
|
424
482
|
> Volta will automatically install and lock the tool versions defined in `package.json`.
|
|
425
483
|
|
|
@@ -443,18 +501,18 @@ For more on Programmatic API, types, and advanced usage of `@flow-scanner/lightn
|
|
|
443
501
|
|
|
444
502
|
To compile just the core package::
|
|
445
503
|
```bash
|
|
446
|
-
pnpm build:core
|
|
504
|
+
pnpm build:core
|
|
447
505
|
```
|
|
448
506
|
|
|
449
507
|
4. Run tests:
|
|
450
508
|
|
|
451
509
|
```bash
|
|
452
|
-
pnpm test
|
|
510
|
+
pnpm test
|
|
453
511
|
```
|
|
454
512
|
|
|
455
513
|
Or to test a new version of the core:
|
|
456
514
|
```bash
|
|
457
|
-
pnpm test:core
|
|
515
|
+
pnpm test:core
|
|
458
516
|
```
|
|
459
517
|
|
|
460
518
|
5. Linking the core module locally(Optional):
|
package/main/libs/ScanFlows.js
CHANGED
|
@@ -71,9 +71,6 @@ function ScanFlows(flows, ruleOptions) {
|
|
|
71
71
|
const config = getRuleConfigByIdOrName(rule, ruleOptions === null || ruleOptions === void 0 ? void 0 : ruleOptions.rules);
|
|
72
72
|
const suppressions = getSuppressionsForRule(rule, flow.name, ruleOptions === null || ruleOptions === void 0 ? void 0 : ruleOptions.exceptions);
|
|
73
73
|
const result = config && Object.keys(config).length > 0 ? rule.execute(flow, config, suppressions) : rule.execute(flow, undefined, suppressions);
|
|
74
|
-
if (result.severity !== rule.severity) {
|
|
75
|
-
result.severity = rule.severity;
|
|
76
|
-
}
|
|
77
74
|
if (result.details.length > 0) {
|
|
78
75
|
let flowXml = flowXmlCache.get(flow.name);
|
|
79
76
|
if (!flowXml) {
|
|
@@ -151,6 +151,6 @@ let RuleCommon = class RuleCommon {
|
|
|
151
151
|
this.isConfigurable = false;
|
|
152
152
|
}
|
|
153
153
|
var _optional_severity;
|
|
154
|
-
this.severity = (_optional_severity = optional === null || optional === void 0 ? void 0 : optional.severity) !== null && _optional_severity !== void 0 ? _optional_severity : "
|
|
154
|
+
this.severity = (_optional_severity = optional === null || optional === void 0 ? void 0 : optional.severity) !== null && _optional_severity !== void 0 ? _optional_severity : "warning";
|
|
155
155
|
}
|
|
156
156
|
};
|
|
@@ -31,7 +31,7 @@ let RuleResult = class RuleResult {
|
|
|
31
31
|
_define_property(this, "errorMessage", void 0);
|
|
32
32
|
this.ruleDefinition = info;
|
|
33
33
|
this.ruleName = info.name;
|
|
34
|
-
this.severity = info.severity ? info.severity : "
|
|
34
|
+
this.severity = info.severity ? info.severity : "warning";
|
|
35
35
|
this.occurs = false;
|
|
36
36
|
this.details = details;
|
|
37
37
|
if (details.length > 0) {
|
package/main/rules/APIVersion.js
CHANGED
|
@@ -116,7 +116,7 @@ let APIVersion = class APIVersion extends _RuleCommon.RuleCommon {
|
|
|
116
116
|
ruleId: "invalid-api-version",
|
|
117
117
|
name: "APIVersion",
|
|
118
118
|
label: "Invalid API Version",
|
|
119
|
-
description: "Introducing newer API components may lead to unexpected issues with older versions of Flows, as they might not align with the underlying mechanics. Starting from API version 50.0, the
|
|
119
|
+
description: "Introducing newer API components may lead to unexpected issues with older versions of Flows, as they might not align with the underlying mechanics. Starting from API version 50.0, the **Api Version** attribute has been readily available on the Flow Object. To ensure smooth operation and reduce discrepancies between API versions, it is strongly advised to regularly update and maintain them.",
|
|
120
120
|
supportedTypes: _internals.FlowType.allTypes(),
|
|
121
121
|
docRefs: []
|
|
122
122
|
});
|
|
@@ -20,14 +20,14 @@ let ActionCallsInLoop = class ActionCallsInLoop extends _LoopRuleCommon.LoopRule
|
|
|
20
20
|
constructor(){
|
|
21
21
|
super({
|
|
22
22
|
ruleId: "action-call-in-loop",
|
|
23
|
-
description: "To prevent exceeding Apex governor limits, it is advisable to consolidate and bulkify your apex calls,
|
|
23
|
+
description: "To prevent exceeding Apex governor limits, it is advisable to consolidate and bulkify your apex calls, utilizing a single action call containing a collection variable at the end of the loop.",
|
|
24
24
|
docRefs: [
|
|
25
25
|
{
|
|
26
|
-
label: "
|
|
26
|
+
label: "Action Call In A Loop",
|
|
27
27
|
path: "https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm"
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
|
-
label: "Action Call In Loop",
|
|
30
|
+
label: "Action Call In A Loop",
|
|
31
31
|
name: "ActionCallsInLoop",
|
|
32
32
|
supportedTypes: _internals.FlowType.backEndTypes
|
|
33
33
|
}, {
|
package/main/rules/AutoLayout.js
CHANGED
|
@@ -67,8 +67,8 @@ let AutoLayout = class AutoLayout extends _RuleCommon.RuleCommon {
|
|
|
67
67
|
super({
|
|
68
68
|
ruleId: "missing-auto-layout",
|
|
69
69
|
name: "AutoLayout",
|
|
70
|
-
label: "Auto
|
|
71
|
-
description: "With Canvas Mode set to Auto-Layout,
|
|
70
|
+
label: "Missing Auto Layout",
|
|
71
|
+
description: "With Canvas Mode set to Auto-Layout, elements are spaced, connected, and aligned automatically, keeping your Flow neatly organized—saving you time.",
|
|
72
72
|
supportedTypes: _internals.FlowType.allTypes(),
|
|
73
73
|
docRefs: []
|
|
74
74
|
}, {
|
|
@@ -62,7 +62,7 @@ let CopyAPIName = class CopyAPIName extends _RuleCommon.RuleCommon {
|
|
|
62
62
|
ruleId: "unclear-api-naming",
|
|
63
63
|
name: "CopyAPIName",
|
|
64
64
|
label: "Unclear API Name",
|
|
65
|
-
description: "Maintaining multiple elements with a similar name, like
|
|
65
|
+
description: "Maintaining multiple elements with a similar name, like `Copy_X_Of_Element`, can diminish the overall readability of your Flow. When copying and pasting these elements, remember to update the API name of the newly created copy.",
|
|
66
66
|
supportedTypes: _internals.FlowType.allTypes(),
|
|
67
67
|
docRefs: []
|
|
68
68
|
});
|
|
@@ -21,7 +21,7 @@ let DMLStatementInLoop = class DMLStatementInLoop extends _LoopRuleCommon.LoopRu
|
|
|
21
21
|
constructor(){
|
|
22
22
|
super({
|
|
23
23
|
ruleId: "dml-in-loop",
|
|
24
|
-
description: "To prevent exceeding Apex governor limits,
|
|
24
|
+
description: "To prevent exceeding Apex governor limits, consolidate all your database operations—record creation, updates, or deletions—at the conclusion of the flow.",
|
|
25
25
|
docRefs: [
|
|
26
26
|
{
|
|
27
27
|
label: "Flow Best Practices",
|
|
@@ -97,7 +97,7 @@ let DuplicateDMLOperation = class DuplicateDMLOperation extends _RuleCommon.Rule
|
|
|
97
97
|
ruleId: "duplicate-dml",
|
|
98
98
|
name: "DuplicateDMLOperation",
|
|
99
99
|
label: "Duplicate DML Operation",
|
|
100
|
-
description: "When
|
|
100
|
+
description: "When a flow executes database changes or actions between two screens, prevent users from navigating backward between screens; otherwise, duplicate database operations may be performed.",
|
|
101
101
|
supportedTypes: _internals.FlowType.visualTypes,
|
|
102
102
|
docRefs: []
|
|
103
103
|
});
|
|
@@ -64,7 +64,7 @@ let FlowDescription = class FlowDescription extends _RuleCommon.RuleCommon {
|
|
|
64
64
|
constructor(){
|
|
65
65
|
super({
|
|
66
66
|
ruleId: "missing-flow-description",
|
|
67
|
-
description: "Descriptions play a vital role in documentation.
|
|
67
|
+
description: "Descriptions play a vital role in documentation. It is highly recommended to include details about where a flow is used and its intended purpose.",
|
|
68
68
|
docRefs: [],
|
|
69
69
|
label: "Missing Flow Description",
|
|
70
70
|
name: "FlowDescription",
|
package/main/rules/FlowName.js
CHANGED
|
@@ -67,7 +67,7 @@ let FlowName = class FlowName extends _RuleCommon.RuleCommon {
|
|
|
67
67
|
constructor(){
|
|
68
68
|
super({
|
|
69
69
|
ruleId: "invalid-naming-convention",
|
|
70
|
-
description: "The readability of a flow is
|
|
70
|
+
description: "The readability of a flow is paramount. Establishing a naming convention significantly enhances findability, searchability, and overall consistency. Include at least a domain and a brief description of the flow’s actions, for example `Service_OrderFulfillment`.",
|
|
71
71
|
docRefs: [
|
|
72
72
|
{
|
|
73
73
|
label: "Naming your Flows is more critical than ever. By Stephen Church",
|
|
@@ -69,10 +69,10 @@ let GetRecordAllFields = class GetRecordAllFields extends _RuleCommon.RuleCommon
|
|
|
69
69
|
constructor(){
|
|
70
70
|
super({
|
|
71
71
|
ruleId: "get-record-all-fields",
|
|
72
|
-
description: "Following the principle of least privilege (PoLP), avoid using Get Records with
|
|
72
|
+
description: "Following the principle of least privilege (PoLP), avoid using **Get Records** with “Automatically store all fields” unless necessary.",
|
|
73
73
|
docRefs: [
|
|
74
74
|
{
|
|
75
|
-
label: "
|
|
75
|
+
label: "Get Records Stores All Fields",
|
|
76
76
|
path: "https://developer.salesforce.com/docs/atlas.en-us.salesforce_large_data_volumes_bp.meta/salesforce_large_data_volumes_bp/ldv_deployments_best_practices_soql_and_sosl.htm"
|
|
77
77
|
},
|
|
78
78
|
{
|
|
@@ -61,7 +61,7 @@ let HardcodedId = class HardcodedId extends _RuleCommon.RuleCommon {
|
|
|
61
61
|
ruleId: "hardcoded-id",
|
|
62
62
|
name: "HardcodedId",
|
|
63
63
|
label: "Hardcoded Id",
|
|
64
|
-
description: "Avoid hard-coding IDs
|
|
64
|
+
description: "Avoid hard-coding IDs because they are org specific. Instead, pass them into variables at the start of the flow—via merge-field URL parameters or a **Get Records** element.",
|
|
65
65
|
supportedTypes: _internals.FlowType.allTypes(),
|
|
66
66
|
docRefs: [
|
|
67
67
|
{
|
|
@@ -19,7 +19,7 @@ let HardcodedUrl = class HardcodedUrl extends _RuleCommon.RuleCommon {
|
|
|
19
19
|
constructor(){
|
|
20
20
|
super({
|
|
21
21
|
ruleId: "hardcoded-url",
|
|
22
|
-
description: "Avoid hard-coding URLs
|
|
22
|
+
description: "Avoid hard-coding URLs because they are environment specific. Use an `$API` formula (preferred) or environment-specific sources like custom labels, metadata, or settings.",
|
|
23
23
|
docRefs: [
|
|
24
24
|
{
|
|
25
25
|
label: "The Ultimate Guide to Salesforce Flow Best Practices",
|
|
@@ -65,7 +65,7 @@ let InactiveFlow = class InactiveFlow extends _RuleCommon.RuleCommon {
|
|
|
65
65
|
ruleId: "inactive-flow",
|
|
66
66
|
name: "InactiveFlow",
|
|
67
67
|
label: "Inactive Flow",
|
|
68
|
-
description: "Like cleaning out your closet: deleting unused flows is essential. Inactive flows can still cause trouble
|
|
68
|
+
description: "Like cleaning out your closet: deleting unused flows is essential. Inactive flows can still cause trouble—such as accidentally deleting records during testing, or being activated as subflows.",
|
|
69
69
|
supportedTypes: _internals.FlowType.allTypes(),
|
|
70
70
|
docRefs: []
|
|
71
71
|
});
|
|
@@ -127,7 +127,7 @@ let MissingFaultPath = class MissingFaultPath extends _RuleCommon.RuleCommon {
|
|
|
127
127
|
constructor(){
|
|
128
128
|
super({
|
|
129
129
|
ruleId: "missing-fault-path",
|
|
130
|
-
description: "
|
|
130
|
+
description: "A flow may fail to execute an operation as intended. By default, the flow displays an error to the user and emails the creator. Customize this behavior by incorporating a Fault Path.",
|
|
131
131
|
docRefs: [
|
|
132
132
|
{
|
|
133
133
|
label: "Flow Best Practices",
|
|
@@ -66,7 +66,7 @@ let MissingMetadataDescription = class MissingMetadataDescription extends _RuleC
|
|
|
66
66
|
constructor(){
|
|
67
67
|
super({
|
|
68
68
|
ruleId: "missing-metadata-description",
|
|
69
|
-
description: "
|
|
69
|
+
description: "Flags Flow elements (Get Records, Assignments, Decisions, Actions, etc.) and metadata components (Variables, Formulas, Constants, Text Templates) that lack a description. Adding concise descriptions greatly improves readability, maintainability, and helps AI tools understand your automation intent.",
|
|
70
70
|
docRefs: [],
|
|
71
71
|
label: "Missing Metadata Description",
|
|
72
72
|
name: "MissingMetadataDescription",
|
|
@@ -138,7 +138,7 @@ let MissingNullHandler = class MissingNullHandler extends _RuleCommon.RuleCommon
|
|
|
138
138
|
constructor(){
|
|
139
139
|
super({
|
|
140
140
|
ruleId: "missing-null-handler",
|
|
141
|
-
description: "When a Get Records operation
|
|
141
|
+
description: "When a **Get Records** operation finds no data, it returns `null`. Validate data by using a Decision element to check for a non-null result.",
|
|
142
142
|
docRefs: [],
|
|
143
143
|
label: "Missing Null Handler",
|
|
144
144
|
name: "MissingNullHandler",
|
|
@@ -79,12 +79,14 @@ let MissingRecordTriggerFilter = class MissingRecordTriggerFilter extends _RuleC
|
|
|
79
79
|
super({
|
|
80
80
|
ruleId: "missing-record-trigger-filter",
|
|
81
81
|
name: "MissingRecordTriggerFilter",
|
|
82
|
-
label: "Missing Record Trigger
|
|
83
|
-
description: "
|
|
82
|
+
label: "Missing Filter Record Trigger",
|
|
83
|
+
description: "Record-triggered flows that lack filters on changed fields or entry conditions can lead to unnecessary executions on every record change. This may degrade system performance, hit governor limits faster, and increase resource consumption in high-volume orgs.",
|
|
84
84
|
supportedTypes: [
|
|
85
85
|
_internals.FlowType.autolaunchedType
|
|
86
86
|
],
|
|
87
87
|
docRefs: []
|
|
88
|
+
}, {
|
|
89
|
+
severity: "warning"
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
92
|
};
|
|
@@ -61,8 +61,8 @@ let ProcessBuilder = class ProcessBuilder extends _RuleCommon.RuleCommon {
|
|
|
61
61
|
super({
|
|
62
62
|
ruleId: "process-builder-usage",
|
|
63
63
|
name: "ProcessBuilder",
|
|
64
|
-
label: "Process Builder
|
|
65
|
-
description: "Salesforce is transitioning away from Workflow Rules and Process Builder in favor of Flow.
|
|
64
|
+
label: "Process Builder",
|
|
65
|
+
description: "Salesforce is transitioning away from Workflow Rules and Process Builder in favor of Flow. Begin migrating your organization’s automation to Flow.",
|
|
66
66
|
supportedTypes: _internals.FlowType.processBuilder,
|
|
67
67
|
docRefs: [
|
|
68
68
|
{
|
|
@@ -75,8 +75,8 @@ let RecordIdAsString = class RecordIdAsString extends _RuleCommon.RuleCommon {
|
|
|
75
75
|
super({
|
|
76
76
|
ruleId: "record-id-as-string",
|
|
77
77
|
name: "RecordIdAsString",
|
|
78
|
-
label: "Record ID as String
|
|
79
|
-
description: "Detects flows using a String variable named
|
|
78
|
+
label: "Record ID as String",
|
|
79
|
+
description: "Detects flows using a String variable named `recordId` as input when they could receive the entire record object instead. Since recent Salesforce releases, record pages and quick actions can pass the complete record, eliminating the need for an additional Get Records query and improving performance.",
|
|
80
80
|
supportedTypes: [
|
|
81
81
|
..._internals.FlowType.visualTypes,
|
|
82
82
|
_internals.FlowType.autolaunchedType
|
|
@@ -105,7 +105,7 @@ let RecursiveAfterUpdate = class RecursiveAfterUpdate extends _RuleCommon.RuleCo
|
|
|
105
105
|
constructor(){
|
|
106
106
|
super({
|
|
107
107
|
ruleId: "recursive-record-update",
|
|
108
|
-
description: "After
|
|
108
|
+
description: "After-update flows are meant for modifying **other** records. Using them on the same record can cause recursion. Consider **before-save** flows for same-record updates.",
|
|
109
109
|
docRefs: [
|
|
110
110
|
{
|
|
111
111
|
label: "Learn about same record field updates",
|
|
@@ -19,7 +19,7 @@ let SOQLQueryInLoop = class SOQLQueryInLoop extends _LoopRuleCommon.LoopRuleComm
|
|
|
19
19
|
constructor(){
|
|
20
20
|
super({
|
|
21
21
|
ruleId: "soql-in-loop",
|
|
22
|
-
description: "To prevent exceeding Apex governor limits,
|
|
22
|
+
description: "To prevent exceeding Apex governor limits, consolidate all SOQL queries at the end of the flow.",
|
|
23
23
|
docRefs: [
|
|
24
24
|
{
|
|
25
25
|
label: "Flow Best Practices",
|
|
@@ -89,7 +89,7 @@ let SameRecordFieldUpdates = class SameRecordFieldUpdates extends _RuleCommon.Ru
|
|
|
89
89
|
ruleId: "same-record-field-updates",
|
|
90
90
|
name: "SameRecordFieldUpdates",
|
|
91
91
|
label: "Same Record Field Updates",
|
|
92
|
-
description: "
|
|
92
|
+
description: "Similar to triggers, **before-save** contexts can update the same record via `$Record` without invoking DML.",
|
|
93
93
|
supportedTypes: [
|
|
94
94
|
..._internals.FlowType.backEndTypes
|
|
95
95
|
],
|
|
@@ -79,7 +79,7 @@ let TransformInsteadOfLoop = class TransformInsteadOfLoop extends _RuleCommon.Ru
|
|
|
79
79
|
ruleId: "transform-instead-of-loop",
|
|
80
80
|
name: "TransformInsteadOfLoop",
|
|
81
81
|
label: "Transform Instead of Loop",
|
|
82
|
-
description: "Detects Loop elements that directly connect to Assignment elements.
|
|
82
|
+
description: "Detects Loop elements that directly connect to Assignment elements. Transform elements handle collection manipulation in bulk operations, providing significant performance improvements over iterative loop-assignment patterns.",
|
|
83
83
|
supportedTypes: _internals.FlowType.allTypes(),
|
|
84
84
|
docRefs: [
|
|
85
85
|
{
|
|
@@ -70,8 +70,8 @@ let TriggerOrder = class TriggerOrder extends _RuleCommon.RuleCommon {
|
|
|
70
70
|
super({
|
|
71
71
|
ruleId: "unspecified-trigger-order",
|
|
72
72
|
name: "TriggerOrder",
|
|
73
|
-
label: "Trigger Order",
|
|
74
|
-
description: "
|
|
73
|
+
label: "Missing Trigger Order",
|
|
74
|
+
description: "Guarantee your flow execution order with the **Trigger Order** property introduced in Spring '22." + "value to their flows and guarantee their execution order. This priority value is not an " + "absolute value, so the values need not be sequentially numbered as 1, 2, 3, and so on.",
|
|
75
75
|
supportedTypes: [
|
|
76
76
|
_internals.FlowType.autolaunchedType
|
|
77
77
|
],
|
|
@@ -62,7 +62,7 @@ let UnconnectedElement = class UnconnectedElement extends _RuleCommon.RuleCommon
|
|
|
62
62
|
constructor(){
|
|
63
63
|
super({
|
|
64
64
|
ruleId: "unreachable-element",
|
|
65
|
-
description: "
|
|
65
|
+
description: "Avoid unconnected elements that are not used by the flow to keep flows efficient and maintainable.",
|
|
66
66
|
docRefs: [],
|
|
67
67
|
label: "Unreachable Element",
|
|
68
68
|
name: "UnconnectedElement",
|
|
@@ -82,7 +82,7 @@ let UnusedVariable = class UnusedVariable extends _RuleCommon.RuleCommon {
|
|
|
82
82
|
ruleId: "unused-variable",
|
|
83
83
|
name: "UnusedVariable",
|
|
84
84
|
label: "Unused Variable",
|
|
85
|
-
description: "To maintain
|
|
85
|
+
description: "To maintain efficiency and manageability, avoid including variables that are never referenced.",
|
|
86
86
|
supportedTypes: [
|
|
87
87
|
..._internals.FlowType.backEndTypes,
|
|
88
88
|
..._internals.FlowType.visualTypes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flow-scanner/lightning-flow-scanner-core",
|
|
3
3
|
"description": "A lightweight 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.13.
|
|
4
|
+
"version": "6.13.2",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|