lightning-flow-scanner-core
Advanced tools
Comparing version 1.0.1 to 1.0.2
import { IRuleDefinition } from './main/interfaces/IRuleDefinition'; | ||
import { Flow } from './main/models/Flow'; | ||
import { ScanResult } from './main/models/ScanResult'; | ||
import { RuleOptions } from "./main/models/RuleOptions"; | ||
export declare function getRuleDefinitions(ruleNames?: string[]): IRuleDefinition[]; | ||
export declare function scan(flows: Flow[], ruleNames?: string[]): ScanResult[]; | ||
export declare function scan(flows: Flow[], ruleNames?: string[], ruleOptions?: RuleOptions): ScanResult[]; | ||
export declare function fix(flows: Flow[]): ScanResult[]; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const ScanFlows_1 = require("./main/libs/ScanFlows"); | ||
const FilterUsingIgnoreOptions_1 = require("./main/libs/FilterUsingIgnoreOptions"); | ||
function getRuleDefinitions(ruleNames) { | ||
@@ -17,9 +18,14 @@ if (ruleNames) { | ||
exports.getRuleDefinitions = getRuleDefinitions; | ||
function scan(flows, ruleNames) { | ||
function scan(flows, ruleNames, ruleOptions) { | ||
let scanResults; | ||
if (ruleNames) { | ||
return ScanFlows_1.ScanFlows(flows, ruleNames); | ||
scanResults = ScanFlows_1.ScanFlows(flows, ruleNames); | ||
} | ||
else { | ||
return ScanFlows_1.ScanFlows(flows); | ||
scanResults = ScanFlows_1.ScanFlows(flows); | ||
} | ||
if (ruleOptions) { | ||
scanResults = FilterUsingIgnoreOptions_1.FilterUsingIgnoreOptions(scanResults, ruleOptions); | ||
} | ||
return scanResults; | ||
} | ||
@@ -26,0 +32,0 @@ exports.scan = scan; |
@@ -16,7 +16,7 @@ "use strict"; | ||
for (const flow of flows) { | ||
const scanResults = []; | ||
const ruleResults = []; | ||
for (const rule of selectedRules) { | ||
scanResults.push(rule.execute(flow)); | ||
ruleResults.push(rule.execute(flow)); | ||
} | ||
flowResults.push(new ScanResult_1.ScanResult(flow, scanResults)); | ||
flowResults.push(new ScanResult_1.ScanResult(flow, ruleResults)); | ||
} | ||
@@ -23,0 +23,0 @@ return flowResults; |
@@ -10,3 +10,3 @@ "use strict"; | ||
label: 'DML statements in a loop', | ||
text: 'To avoid hitting Apex governor limits, we recommend bunching all your database changes together at the end of the flow, whether those changes create, update, or delete records.' | ||
text: 'To avoid hitting Apex governor limits, we recommend grouping all of your database changes together at the end of the flow, whether those changes create, update, or delete records.' | ||
}; | ||
@@ -16,3 +16,3 @@ case RuleDefinitions_1.RuleDefinitions.DuplicateDMLOperationsByNavigation: | ||
label: 'Duplicate DML operations', | ||
text: "If the flow commits changes to the database or performs actions between two screens, don't let users navigate from the later screen to the previous screen. Otherwise, the flow can make duplicate changes to the database." | ||
text: "If the flow commits changes to the database or performs actions between two screens, don't let users navigate back between screen. Otherwise, the flow may perform duplicate database operations." | ||
}; | ||
@@ -27,3 +27,3 @@ case RuleDefinitions_1.RuleDefinitions.HardcodedIds: | ||
label: 'Missing flow description', | ||
text: 'Flow Descriptions are the closed thing to documentation. It is recommended to provide information about where it is used and what it will do.' | ||
text: 'Flow descriptions are the closest thing to documentation. It is recommended to provide information about where it is used and what it will do.' | ||
}; | ||
@@ -38,3 +38,3 @@ case RuleDefinitions_1.RuleDefinitions.MissingFaultPath: | ||
label: 'Missing null handlers', | ||
text: 'If a Get Records operation does not find any data it will return null. You should use decision element on that variable to check if the result is not null.' | ||
text: 'If a Get Records operation does not find any data it will return null. You should use a decision element on that variable to check if the result is not null.' | ||
}; | ||
@@ -44,3 +44,3 @@ case RuleDefinitions_1.RuleDefinitions.UnconnectedElements: | ||
label: 'Unconnected elements', | ||
text: 'Removing unconnected elements which are not being used by the Flow, will make your Flow more performant and maintainable.' | ||
text: 'Removing unconnected elements which are not being used by the Flow makes your Flow more performant and maintainable.' | ||
}; | ||
@@ -50,3 +50,3 @@ case RuleDefinitions_1.RuleDefinitions.UnusedVariables: | ||
label: 'Unused variables', | ||
text: 'Removing unconnected variables which are not being used by the Flow, will make your Flow more performant and maintainable.' | ||
text: 'Removing unconnected variables which are not being used by the Flow makes your Flow more performant and maintainable.' | ||
}; | ||
@@ -53,0 +53,0 @@ } |
{ | ||
"name": "lightning-flow-scanner-core", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "out/**", | ||
@@ -5,0 +5,0 @@ "types": "out/index.d.ts", |
@@ -1,19 +0,15 @@ | ||
# Lightning Flow Scan(Core) | ||
### _Find bugs and optimise Salesforce Lightning Flows._ | ||
# Lightning Flow Scanner(Core) | ||
### _Used in both the VSCode extension as well as SFDX plugin with the same name._ | ||
## Core module | ||
## Rules Included: | ||
Used in both the VSCode extension as well as SFDX plugin with the same name. | ||
DML statements in a loop, | ||
Duplicate DML operations, | ||
Hardcoded Ids, | ||
Missing flow description, | ||
Missing error handlers, | ||
Missing null handlers, | ||
Unconnected elements(auto-fix), | ||
Unused variables(auto-fix) | ||
## Rules(Currently included): | ||
"DML statements in a loop", | ||
"Duplicate DML operations", | ||
"Hardcoded Ids", | ||
"Missing flow description", | ||
"Missing error handlers", | ||
"Missing null handlers", | ||
"Unconnected elements", | ||
"Unused variables" | ||
## Functions | ||
@@ -29,5 +25,5 @@ | ||
`fix(flows :Flow[]): Flow[];` | ||
`fix(flows :Flow[]): ScanResult[];` | ||
Removes unused variables and unconnected elements from all selected flows. | ||
import {FixFlows} from './main/libs/FixFlows'; | ||
import { GetRuleDefinitions } from './main/libs/GetRuleDefinitions'; | ||
import {GetRuleDefinitions} from './main/libs/GetRuleDefinitions'; | ||
import {IRuleDefinition} from './main/interfaces/IRuleDefinition'; | ||
@@ -7,5 +7,7 @@ import {ScanFlows} from './main/libs/ScanFlows'; | ||
import {ScanResult} from './main/models/ScanResult'; | ||
import {RuleOptions} from "./main/models/RuleOptions"; | ||
import {FilterUsingIgnoreOptions} from "./main/libs/FilterUsingIgnoreOptions"; | ||
export function getRuleDefinitions(ruleNames? : string[]): IRuleDefinition[] { | ||
if(ruleNames){ | ||
export function getRuleDefinitions(ruleNames?: string[]): IRuleDefinition[] { | ||
if (ruleNames) { | ||
return GetRuleDefinitions(ruleNames); | ||
@@ -17,12 +19,19 @@ } else { | ||
export function scan(flows :Flow[], ruleNames? : string[]): ScanResult[] { | ||
if(ruleNames){ | ||
return ScanFlows(flows, ruleNames); | ||
export function scan(flows: Flow[], ruleNames?: string[], ruleOptions?: RuleOptions): ScanResult[] { | ||
let scanResults: ScanResult[]; | ||
if (ruleNames) { | ||
scanResults = ScanFlows(flows, ruleNames); | ||
} else { | ||
return ScanFlows(flows); | ||
scanResults = ScanFlows(flows); | ||
} | ||
if(ruleOptions){ | ||
scanResults = FilterUsingIgnoreOptions(scanResults, ruleOptions); | ||
} | ||
return scanResults; | ||
} | ||
export function fix(flows :Flow[]): ScanResult[] { | ||
export function fix(flows: Flow[]): ScanResult[] { | ||
return FixFlows(flows); | ||
} |
@@ -7,7 +7,7 @@ import {Flow} from '../models/Flow'; | ||
export function ScanFlows(flows: Flow[], ruleNames? : string[]) : ScanResult[] { | ||
const flowResults : ScanResult[] = []; | ||
export function ScanFlows(flows: Flow[], ruleNames?: string[]): ScanResult[] { | ||
let selectedRules : IRuleDefinition[]; | ||
if(ruleNames){ | ||
const flowResults: ScanResult[] = []; | ||
let selectedRules: IRuleDefinition[]; | ||
if (ruleNames) { | ||
selectedRules = GetRuleDefinitions(ruleNames); | ||
@@ -17,11 +17,10 @@ } else { | ||
} | ||
for (const flow of flows) { | ||
const scanResults: RuleResult[] = []; | ||
for (const rule of selectedRules){ | ||
scanResults.push(rule.execute(flow)); | ||
const ruleResults: RuleResult[] = []; | ||
for (const rule of selectedRules) { | ||
ruleResults.push(rule.execute(flow)); | ||
} | ||
flowResults.push(new ScanResult(flow, scanResults)); | ||
flowResults.push(new ScanResult(flow, ruleResults)); | ||
} | ||
return flowResults; | ||
} |
@@ -9,2 +9,3 @@ import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
constructor(ruleName: string, type: string, results?: (FlowElement[] | FlowVariable[] | [boolean])) { | ||
this.results = results; | ||
@@ -11,0 +12,0 @@ this.ruleName = ruleName; |
@@ -8,3 +8,3 @@ import { RuleDefinitions } from './RuleDefinitions'; | ||
label: 'DML statements in a loop', | ||
text: 'To avoid hitting Apex governor limits, we recommend bunching all your database changes together at the end of the flow, whether those changes create, update, or delete records.' | ||
text: 'To avoid hitting Apex governor limits, we recommend grouping all of your database changes together at the end of the flow, whether those changes create, update, or delete records.' | ||
}; | ||
@@ -14,3 +14,3 @@ case RuleDefinitions.DuplicateDMLOperationsByNavigation: | ||
label: 'Duplicate DML operations', | ||
text: "If the flow commits changes to the database or performs actions between two screens, don't let users navigate from the later screen to the previous screen. Otherwise, the flow can make duplicate changes to the database." | ||
text: "If the flow commits changes to the database or performs actions between two screens, don't let users navigate back between screen. Otherwise, the flow may perform duplicate database operations." | ||
}; | ||
@@ -26,3 +26,3 @@ | ||
label: 'Missing flow description', | ||
text: 'Flow Descriptions are the closed thing to documentation. It is recommended to provide information about where it is used and what it will do.' | ||
text: 'Flow descriptions are the closest thing to documentation. It is recommended to provide information about where it is used and what it will do.' | ||
}; | ||
@@ -37,3 +37,3 @@ case RuleDefinitions.MissingFaultPath: | ||
label: 'Missing null handlers', | ||
text: 'If a Get Records operation does not find any data it will return null. You should use decision element on that variable to check if the result is not null.' | ||
text: 'If a Get Records operation does not find any data it will return null. You should use a decision element on that variable to check if the result is not null.' | ||
}; | ||
@@ -43,3 +43,3 @@ case RuleDefinitions.UnconnectedElements: | ||
label: 'Unconnected elements', | ||
text: 'Removing unconnected elements which are not being used by the Flow, will make your Flow more performant and maintainable.' | ||
text: 'Removing unconnected elements which are not being used by the Flow makes your Flow more performant and maintainable.' | ||
}; | ||
@@ -49,5 +49,5 @@ case RuleDefinitions.UnusedVariables: | ||
label: 'Unused variables', | ||
text: 'Removing unconnected variables which are not being used by the Flow, will make your Flow more performant and maintainable.' | ||
text: 'Removing unconnected variables which are not being used by the Flow makes your Flow more performant and maintainable.' | ||
}; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
677284
137
25865
29