Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 0 additions & 144 deletions docs/defaultrules.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightning-flow-scanner-core",
"version": "3.7.0",
"version": "3.8.0",
"main": "out/**",
"types": "index.d.ts",
"scripts": {
Expand Down
32 changes: 16 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ _An Extensible Rule Engine for Salesforce Flows used by the Lightning Flow Scann

## Default Rules

| Rule | Description |
|--------------|:-----------|
| **Outdated API Version** | 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. |
| **Copy API Name** | 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. |
| **DML Statement In A Loop** | To prevent exceeding Apex governor limits, it is advisable to consolidate all your database operations, including record creation, updates, or deletions, at the conclusion of the flow. |
| **Duplicate DML Operation** | When the flow executes database changes or actions between two screens, it's important to prevent users from navigating back between screens. Failure to do so may result in duplicate database operations being performed within the flow. |
| **Hardcoded Id** | Avoid hard-coding IDs as they are org-specific. Instead, pass them into variables at the start of the flow. You can achieve this by utilizing merge fields in URL parameters or employing a Get Records element. |
| **Flow Naming Convention** | The readability of a flow is of utmost importance. Establishing a naming convention for the Flow Name significantly enhances findability, searchability, and maintains overall consistency. It is advisable to include at least a domain and a brief description of the actions carried out in the flow, for instance, 'Service_OrderFulfillment'. |
| **Missing Flow Description** | Descriptions play a vital role in documentation. We highly recommend including details about where they are used and their intended purpose. |
| **Missing Fault Path** | At times, a flow may fail to execute a configured operation as intended. By default, the flow displays an error message to the user and notifies the admin who created the flow via email. However, you can customize this behavior by incorporating a Fault Path. |
| **Missing Null Handler** | When a Get Records operation doesn't find any data, it returns null. To ensure data validation, utilize a decision element on the operation result variable to check for a non-null result. |
| **SOQL Query In A Loop** | To prevent exceeding Apex governor limits, it is advisable to consolidate all your SOQL queries at the conclusion of the flow. |
| **Unconnected Element** | Unconnected elements which are not being used by the Flow should be avoided to keep Flows efficient and maintainable. |
| **Unused Variable** | To maintain the efficiency and manageability of your Flow, it's advisable to avoid including unconnected variables that are not in use. |

For more details on the ruleset and its configurability see _[Default Rule Definitions](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/docs/defaultrules.md)_
| Rule (Configuration ID) | Description |
|--------------------------|-------------|
| **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. |
| **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. |
| **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. |
| **DML Statement In A Loop** ([`DMLStatementInLoop`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/DMLStatementInLoop.ts)) | To prevent exceeding Apex governor limits, it is advisable to consolidate all your database operations, including record creation, updates, or deletions, at the conclusion of the flow. |
| **Duplicate DML Operation** ([`DuplicateDMLOperation`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/DuplicateDMLOperation.ts)) | When the flow executes database changes or actions between two screens, it's important to prevent users from navigating back between screens. Failure to do so may result in duplicate database operations being performed within the flow. |
| **Hardcoded Id** ([`HardcodedId`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/HardcodedId.ts)) | Avoid hard-coding IDs as they are org-specific. Instead, pass them into variables at the start of the flow. You can achieve this by utilizing merge fields in URL parameters or employing a Get Records element. |
| **Flow Naming Convention** ([`FlowName`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/FlowName.ts)) | The readability of a flow is of utmost importance. Establishing a naming convention for the Flow Name significantly enhances findability, searchability, and maintains overall consistency. It is advisable to include at least a domain and a brief description of the actions carried out in the flow, for instance, 'Service_OrderFulfillment'. |
| **Missing Flow Description** ([`FlowDescription`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/FlowDescription.ts)) | Descriptions play a vital role in documentation. We highly recommend including details about where they are used and their intended purpose. |
| **Missing Fault Path** ([`MissingFaultPath`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/MissingFaultPath.ts)) | At times, a flow may fail to execute a configured operation as intended. By default, the flow displays an error message to the user and notifies the admin who created the flow via email. However, you can customize this behavior by incorporating a Fault Path. |
| **Missing Null Handler** ([`MissingNullHandler`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/MissingNullHandler.ts)) | When a Get Records operation doesn't find any data, it returns null. To ensure data validation, utilize a decision element on the operation result variable to check for a non-null result. |
| **SOQL Query In A Loop** ([`SOQLQueryInLoop`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/SOQLQueryInLoop.ts)) | To prevent exceeding Apex governor limits, it is advisable to consolidate all your SOQL queries at the conclusion of the flow. |
| **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. |
| **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. |
| **Process Builder** ([`ProcessBuilder`](https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/master/src/main/rules/ProcessBuilder.ts)) | Salesforce is transitioning away from Workflow Rules and Process Builder in favor of Flow. Ensure you're prepared for this transition by migrating your organization's automation to Flow. Refer to official documentation for more information on the transition process and tools available. |

## Configurations

Expand Down
1 change: 0 additions & 1 deletion src/main/interfaces/IRuleDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface IRuleDefinition {
label: string;
description: string;
supportedTypes: string[];
type: string;
docRefs: { label: string, path: string }[];
isConfigurable: boolean;
autoFixable: boolean;
Expand Down
2 changes: 0 additions & 2 deletions src/main/models/RuleCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export class RuleCommon {
public docRefs: { label: string, path: string }[] = [];
public description: string;
public supportedTypes: string[];
public type: string;
public isConfigurable: boolean;
public autoFixable: boolean;

Expand All @@ -20,7 +19,6 @@ export class RuleCommon {
}
) {
this.name = info.name;
this.type = info.type;
this.supportedTypes = info.supportedTypes;
this.label = info.label;
this.description = info.description;
Expand Down
1 change: 0 additions & 1 deletion src/main/models/RuleInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export class RuleInfo {
public name: string;
public label: string;
public description: string;
public type: string;
public supportedTypes: string[];
public docRefs: {label: string, path: string}[];
public isConfigurable: boolean;
Expand Down
1 change: 0 additions & 1 deletion src/main/rules/APIVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class APIVersion extends RuleCommon implements core.IRuleDefinition {
name: 'APIVersion',
label: 'Outdated API Version',
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.",
type: 'flow',
supportedTypes: core.FlowType.allTypes(),
docRefs: [],
isConfigurable: true,
Expand Down
29 changes: 29 additions & 0 deletions src/main/rules/AutoLayout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as core from '../internals/internals';
import { RuleCommon } from '../models/RuleCommon';

export class AutoLayout extends RuleCommon implements core.IRuleDefinition {

constructor() {
super({
name: 'AutoLayout',
label: 'Use Auto-Layout Mode',
description: "With Canvas Mode set to Auto-Layout, Elements are spaced, connected, and aligned automatically, keeping your Flow neatly organized thus saving you time.",
supportedTypes: core.FlowType.allTypes(),
docRefs: [],
isConfigurable: true,
autoFixable: false
});
}

public execute(flow: core.Flow, options?: { expression: string }): core.RuleResult {

if (flow.xmldata.processMetadataValues && flow.xmldata.processMetadataValues[0]) {

const CanvasMode = flow.xmldata.processMetadataValues.find(mdv => mdv.name[0] === 'CanvasMode');
const AutoLayout = CanvasMode.value[0] && typeof CanvasMode.value[0] === 'object' && 'stringValue' in CanvasMode.value[0] && Array.isArray(CanvasMode.value[0].stringValue) && CanvasMode.value[0].stringValue[0] === "AUTO_LAYOUT_CANVAS";
return (!AutoLayout ?
new core.RuleResult(this, [new core.ResultDetails(new core.FlowAttribute(CanvasMode.value[0]?.stringValue[0], "CanvasMode", '!== AUTO_LAYOUT_CANVAS'))]) :
new core.RuleResult(this, []));
}
}
}
1 change: 0 additions & 1 deletion src/main/rules/CopyAPIName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class CopyAPIName extends RuleCommon implements core.IRuleDefinition {
name: 'CopyAPIName',
label: 'Copy API Name',
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, it's crucial to remember to update the API name of the newly created copy.",
type: 'pattern',
supportedTypes: core.FlowType.allTypes(),
docRefs: [],
isConfigurable: false,
Expand Down
1 change: 0 additions & 1 deletion src/main/rules/DMLStatementInLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class DMLStatementInLoop extends RuleCommon implements core.IRuleDefiniti
name: 'DMLStatementInLoop',
label: 'DML Statement In A Loop',
description: "To prevent exceeding Apex governor limits, it is advisable to consolidate all your database operations, including record creation, updates, or deletions, at the conclusion of the flow.",
type: 'pattern',
supportedTypes: core.FlowType.backEndTypes,
docRefs: [{ 'label': 'Flow Best Practices', 'path': 'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5' }],
isConfigurable: false,
Expand Down
1 change: 0 additions & 1 deletion src/main/rules/DuplicateDMLOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class DuplicateDMLOperation extends RuleCommon implements core.IRuleDefin
name: 'DuplicateDMLOperation',
label: 'Duplicate DML Operation',
description: "When the flow executes database changes or actions between two screens, it's important to prevent users from navigating back between screens. Failure to do so may result in duplicate database operations being performed within the flow.",
type: 'pattern',
supportedTypes: core.FlowType.visualTypes,
docRefs: [],
isConfigurable: false,
Expand Down
Loading