You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to the Lightning Flow Scanner Demo Repository! Get up and running and try the Lightning Flow Scanner now using our Demo Flows. We've prepared a set of example flows that showcase various types of violations, as well as flows that demonstrate how to resolve them. This repository is designed to provide you with practical examples of best practices, ensuring you have valuable resources at your fingertips to improve your code scanning and development process. Explore, learn, and enhance your Salesforce Flow scanning capabilities with our curated test data and sample flows. Happy flow building! 🚀🌟
3
+
This directory contains sample Salesforce Flows used to test Lightning Flow Scanner rules.
4
+
5
+
You can:
6
+
7
+
- Add new flows that trigger specific rules
8
+
- Use these flows to demo scanner output
4
9
5
10
## Getting Started
6
11
7
-
Follow these steps to get up and running with the Lightning Flow Scanner Demo Repository and try out our demo flows:
12
+
Follow these steps to get up and running with the Lightning Flow Scanner Example Flows:
8
13
9
14
### Step 1: Clone the Repository
10
-
To clone the repository, press Ctrl+Shift+P on Windows or Shift+⌘+P on macOS to open the command palette and use the Git Clone command. Alternatively, you can click the link below to clone the repository:
11
15
12
-

16
+
To clone the repository, press Ctrl+Shift+P on Windows or Shift+⌘+P on macOS to open the command palette and use the Git Clone command.
13
17
14
18
### Step 2: Open in Editor
15
-
When prompted, select to open the repository. This will open the cloned repository in your preferred code editor. You can also click the link below for direct access:
16
-
17
-

18
-
19
-
### Step 3: Install Recommended Extensions
20
-
Upon opening the repository, you may be prompted to install recommended extensions. It's essential to do this to ensure a smooth experience when working with the Lightning Flow Scanner. Click the link below for reference:
When prompted, select to open the repository. This will open the cloned repository in your preferred code editor. You can also click the link below
23
21
24
-
### Step 4: Run Flow Commands
25
-
Press Ctrl+Shift+P on Windows or Shift+⌘+P on macOS to open the command palette and type `Flow` to see the available commands from Lightning Flow Scanner. Examples of how the commands run can be found in the [Readme of the Extension repository](https://github.com/Force-Config-Control/lightning-flow-scanner-vsce).
Press Ctrl+Shift+P on Windows or Shift+⌘+P on macOS to open the command palette and type `Flow` to see the available commands from Lightning Flow Scanner. From here you can run the scanning functionality.
_An Extensible Rule Engine capable of conducting static analysis on the metadata associated with Salesforce Lightning Flows, Process Builders, and Workflows. Used by the Lightning Flow Scanner [Salesforce CLI Plugin](https://www.npmjs.com/package/lightning-flow-scanner) and [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ForceConfigControl.lightningflowscanner&ssr=false#review-details)._
4
4
@@ -12,8 +12,8 @@ _An Extensible Rule Engine capable of conducting static analysis on the metadata
|**Auto Layout** ([`AutoLayout`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/AutoLayout.ts)) | With Canvas Mode set to Auto-Layout, Elements are spaced, connected, and aligned automatically, keeping your Flow neatly organized thus saving you time. |
18
18
|**Outdated API Version** ([`APIVersion`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/APIVersion.ts)) | 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. |
19
19
|**Copy API Name** ([`CopyAPIName`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/CopyAPIName.ts)) | 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, it's crucial to remember to update the API name of the newly created copy. |
@@ -30,7 +30,7 @@ _An Extensible Rule Engine capable of conducting static analysis on the metadata
30
30
|**Unconnected Element** ([`UnconnectedElement`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/UnconnectedElement.ts)) | Unconnected elements which are not being used by the Flow should be avoided to keep Flows efficient and maintainable. |
31
31
|**Unused Variable** ([`UnusedVariable`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/UnusedVariable.ts)) | To maintain the efficiency and manageability of your Flow, it's advisable to avoid including unconnected variables that are not in use. |
32
32
|**Unsafe Running Context** ([`UnsafeRunningContext`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/UnsafeRunningContext.ts)) | 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. |
33
-
|**Same Record Field Updates** ([`SameRecordFieldUpdates`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/SameRecordFieldUpdates.ts)) | Much like triggers, before contexts can update the same record by accessing the trigger variables `$Record` without needing to invoke a DML. |
33
+
|**Same Record Field Updates** ([`SameRecordFieldUpdates`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/SameRecordFieldUpdates.ts)) | Much like triggers, before contexts can update the same record by accessing the trigger variables `$Record` without needing to invoke a DML. |
34
34
|**Trigger Order** ([`TriggerOrder`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/TriggerOrder.ts)) | Guarantee your flow execution order with the Trigger Order property introduced in Spring '22 |
35
35
|**Cyclomatic Complexity** ([`CyclomaticComplexity`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/CyclomaticComplexity.ts)) | 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. |
36
36
|**Recursive After Update** ([`RecursiveAfterUpdate`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/RecursiveAfterUpdate.ts)) | After updates are meant to be used for record modifications that are not the same record that triggered the flow. Using after updates on the same record can lead to recursion and unexpected behavior. Consider using before save flows for same record updates. |
@@ -62,17 +62,17 @@ The `fix` function attempts to automatically fix certain issues identified durin
62
62
63
63
### Rule Configuration
64
64
65
-
Using the rules section of your configurations, you can specify the list of rules to be run and provide custom rules. Furthermore, you can define the severity of violating specific rules and configure relevant attributes for some rules. Below is a breakdown of the available attributes of rule configuration:
65
+
Using the rules section of your configurations, you can specify the list of rules to be run and provide custom rules. Furthermore, you can define the severity of violating specific rules and configure relevant attributes for some rules. Below is a breakdown of the available attributes of rule configuration:
66
66
67
67
```json
68
68
{
69
-
"rules": {
70
-
"<RuleName>": {
71
-
"severity": "<Severity>",
72
-
"expression": "<Expression>",
73
-
"path": "<Path>"
74
-
}
69
+
"rules": {
70
+
"<RuleName>": {
71
+
"severity": "<Severity>",
72
+
"expression": "<Expression>",
73
+
"path": "<Path>"
75
74
}
75
+
}
76
76
}
77
77
```
78
78
@@ -113,13 +113,15 @@ rules:
113
113
114
114
- Optional values for severity are "error", "warning", and "note".
115
115
- If severity is provided, it overwrites the default severity, which is "error".
116
+
116
117
- **Expression:**
117
118
118
119
- Expression is used to overwrite standard values in configurable rules.
120
+
119
121
- **Path:**
120
122
121
123
- If a path is provided, it can either replace an existing rule with a new rule definition or load a custom rule.
122
-
- Ensure that the rule name used in the path matches the exported class name of the rule.
124
+
- Ensure that the rule name used in the path matches the exported class name of the rule.
123
125
124
126
### Custom Rule Interface
125
127
@@ -147,9 +149,11 @@ Specifying exceptions allows you to exclude specific scenarios from rule enforce
147
149
-**FlowName:**
148
150
149
151
- The name of the flow where exceptions apply.
152
+
150
153
-**RuleName:**
151
154
152
155
- The name of the rule for which exceptions are defined.
156
+
153
157
-**ResultName:**
154
158
155
159
- The specific result or condition within the rule for which exceptions are specified.
@@ -158,32 +162,39 @@ Specifying exceptions allows you to exclude specific scenarios from rule enforce
158
162
159
163
Follow these steps to set up your development environment:
160
164
161
-
0.**Demo Flows:** test the rules against real flow metadata with a set of [example flows](./example-flows/force-app/main/default/flows) for demonstration purposes.
165
+
0.**Deploy Flows(Optional):** test the rules against real flow metadata with a set of [example flows](./example-flows/force-app/main/default/flows) for demonstration purposes.
162
166
163
167
```bash
164
168
npm run deploy:flows -- -o <your-org-alias>
165
169
```
170
+
166
171
1.**Clone Repository**: Begin by cloning the Lightning Flow Scanner Core repository to your local machine:
2.**Install Dependencies**: Navigate into the cloned repository directory and install the necessary dependencies using Yarn:
172
178
173
179
```bash
174
180
cd lightning-flow-scanner-core
175
181
npm install
176
182
```
183
+
177
184
3.**Build**: Compile the TypeScript source files into JavaScript using the TypeScript compiler:
178
185
179
186
```bash
180
187
npm run build
181
188
```
189
+
182
190
This command generates the compiled JavaScript files in the `out` directory.
191
+
183
192
4.**Run Tests**: Ensure the module functions correctly by running the test suites:
184
193
185
194
```bash
186
195
npm run test
187
196
```
197
+
188
198
This command uses Mocha to run tests located in the `tests` directory and provides feedback on the module's functionality.
199
+
189
200
5.**Debugging in IDE**: If needed, set up your integrated development environment (IDE) for debugging TypeScript code. Configure breakpoints, inspect variables, and step through the code to identify and resolve issues efficiently.
0 commit comments