lightning-flow-scanner-core
Advanced tools
Comparing version 1.0.43 to 1.0.45
@@ -8,3 +8,4 @@ import { Flow } from '../models/Flow'; | ||
text: string; | ||
supportedTypes: string[]; | ||
execute(flow: Flow): RuleResult; | ||
} |
@@ -19,9 +19,10 @@ "use strict"; | ||
for (const rule of selectedRules) { | ||
try { | ||
ruleResults.push(rule.execute(flow)); | ||
if (rule.supportedTypes.includes(flow.type[0])) { | ||
try { | ||
ruleResults.push(rule.execute(flow)); | ||
} | ||
catch (error) { | ||
ruleResults.push(new RuleResult_1.RuleResult(true, rule.name, 'error', [error])); | ||
} | ||
} | ||
catch (error) { | ||
// todo push error result | ||
ruleResults.push(new RuleResult_1.RuleResult(rule.name, "error", false, [error])); | ||
} | ||
} | ||
@@ -28,0 +29,0 @@ flowResults.push(new ScanResult_1.ScanResult(flow, ruleResults)); |
import { FlowElement } from './FlowElement'; | ||
import { FlowVariable } from './FlowVariable'; | ||
export declare class RuleResult { | ||
constructor(ruleName: string, type: string, occurs: boolean, details?: (FlowElement[] | FlowVariable[])); | ||
constructor(occurs: boolean, ruleName: string, type: string, details?: (FlowElement[] | FlowVariable[])); | ||
details?: (FlowElement[] | FlowVariable[]); | ||
@@ -6,0 +6,0 @@ occurs: boolean; |
@@ -7,9 +7,9 @@ "use strict"; | ||
class RuleResult { | ||
constructor(ruleName, type, occurs, details) { | ||
constructor(occurs, ruleName, type, details) { | ||
this.occurs = occurs; | ||
this.ruleName = ruleName; | ||
this.type = type; | ||
if (details) { | ||
this.details = details; | ||
} | ||
this.ruleName = ruleName; | ||
this.type = type; | ||
for (const ruleDefinitionName in RuleDefinitions_1.RuleDefinitions) { | ||
@@ -16,0 +16,0 @@ if (ruleDefinitionName === ruleName) { |
@@ -1,2 +0,2 @@ | ||
import { FlowScanOverrides } from "./FlowScanOverrides"; | ||
import { FlowScanOverrides } from './FlowScanOverrides'; | ||
export declare class ScannerOptions { | ||
@@ -3,0 +3,0 @@ activeRules: string[]; |
import { IRuleDefinition } from '../interfaces/IRuleDefinition'; | ||
import { Flow } from '../models/Flow'; | ||
import { RuleResult } from '../models/RuleResult'; | ||
import { RuleCommon } from "./RuleCommon"; | ||
import { RuleCommon } from './RuleCommon'; | ||
export declare class DMLStatementInLoop extends RuleCommon implements IRuleDefinition { | ||
@@ -6,0 +6,0 @@ constructor(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DMLStatementInLoop = void 0; | ||
const FlowType_1 = require("../models/FlowType"); | ||
const RuleResult_1 = require("../models/RuleResult"); | ||
@@ -9,3 +10,3 @@ const RuleDefinitions_1 = require("../ruledefinitions/RuleDefinitions"); | ||
constructor() { | ||
super(RuleDefinitions_1.RuleDefinitions.DMLStatementInLoop, [{ 'label': 'Flow Best Practices', 'path': 'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5' }]); | ||
super(RuleDefinitions_1.RuleDefinitions.DMLStatementInLoop, [...FlowType_1.FlowType.backEndTypes, ...FlowType_1.FlowType.visualTypes], [{ 'label': 'Flow Best Practices', 'path': 'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5' }]); | ||
} | ||
@@ -39,5 +40,5 @@ execute(flow) { | ||
if (connectors.length > 0) { | ||
const elementsByReferences = flowElements.filter(element => connectors.map(c => c.reference).includes(element.name)); | ||
const elementsByReferences = flowElements.filter(anElement => connectors.map(c => c.reference).includes(anElement.name)); | ||
for (const nextElement of elementsByReferences) { | ||
const nextIndex = flowElements.findIndex(element => nextElement.name === element.name); | ||
const nextIndex = flowElements.findIndex(anElement => nextElement.name === anElement.name); | ||
if ('loops' === nextElement.subtype) { | ||
@@ -62,3 +63,3 @@ reachedEndOfLoop = true; | ||
} | ||
return new RuleResult_1.RuleResult('DMLStatementInLoop', 'pattern', dmlStatementsInLoops.length > 0, dmlStatementsInLoops); | ||
return new RuleResult_1.RuleResult(dmlStatementsInLoops.length > 0, this.name, 'pattern', dmlStatementsInLoops); | ||
} | ||
@@ -65,0 +66,0 @@ findStartOfLoopReference(loopElement) { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const FlowElement_1 = require("../models/FlowElement"); | ||
const FlowType_1 = require("../models/FlowType"); | ||
const RuleResult_1 = require("../models/RuleResult"); | ||
@@ -11,3 +12,3 @@ const RuleDefinitions_1 = require("../ruledefinitions/RuleDefinitions"); | ||
constructor() { | ||
super(RuleDefinitions_1.RuleDefinitions.DuplicateDMLOperationsByNavigation); | ||
super(RuleDefinitions_1.RuleDefinitions.DuplicateDMLOperationsByNavigation, FlowType_1.FlowType.visualTypes); | ||
} | ||
@@ -66,3 +67,3 @@ execute(flow) { | ||
} while ((processedElementIndexes.length + unconnectedElementIndexes.length) < flowElements.length); | ||
return new RuleResult_1.RuleResult('DuplicateDMLOperationsByNavigation', 'pattern', duplicateDMLOperationsByNavigation.length > 0, duplicateDMLOperationsByNavigation); | ||
return new RuleResult_1.RuleResult(duplicateDMLOperationsByNavigation.length > 0, this.name, 'pattern', duplicateDMLOperationsByNavigation); | ||
} | ||
@@ -69,0 +70,0 @@ flagDML(element, dmlFlag) { |
import { IRuleDefinition } from '../interfaces/IRuleDefinition'; | ||
import { Flow } from '../models/Flow'; | ||
import { RuleResult } from '../models/RuleResult'; | ||
import { RuleCommon } from "./RuleCommon"; | ||
import { RuleCommon } from './RuleCommon'; | ||
export declare class HardcodedIds extends RuleCommon implements IRuleDefinition { | ||
@@ -6,0 +6,0 @@ constructor(); |
@@ -24,2 +24,3 @@ "use strict"; | ||
const IdPrefixes = __importStar(require("../data/IdPrefixes.json")); | ||
const FlowType_1 = require("../models/FlowType"); | ||
const RuleResult_1 = require("../models/RuleResult"); | ||
@@ -30,3 +31,3 @@ const RuleDefinitions_1 = require("../ruledefinitions/RuleDefinitions"); | ||
constructor() { | ||
super(RuleDefinitions_1.RuleDefinitions.HardcodedIds, [{ 'label': 'Flow Best Practices', 'path': 'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5' }]); | ||
super(RuleDefinitions_1.RuleDefinitions.HardcodedIds, FlowType_1.FlowType.allTypes, [{ 'label': 'Flow Best Practices', 'path': 'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5' }]); | ||
} | ||
@@ -55,3 +56,3 @@ execute(flow) { | ||
} | ||
return new RuleResult_1.RuleResult('HardcodedIds', 'pattern', nodesWithHardcodedIds.length > 0, nodesWithHardcodedIds); | ||
return new RuleResult_1.RuleResult(nodesWithHardcodedIds.length > 0, this.name, 'pattern', nodesWithHardcodedIds); | ||
} | ||
@@ -58,0 +59,0 @@ } |
import { IRuleDefinition } from '../interfaces/IRuleDefinition'; | ||
import { Flow } from '../models/Flow'; | ||
import { RuleResult } from '../models/RuleResult'; | ||
import { RuleCommon } from "./RuleCommon"; | ||
import { RuleCommon } from './RuleCommon'; | ||
export declare class MissingFaultPath extends RuleCommon implements IRuleDefinition { | ||
@@ -6,0 +6,0 @@ constructor(); |
@@ -5,2 +5,3 @@ "use strict"; | ||
const FlowElement_1 = require("../models/FlowElement"); | ||
const FlowType_1 = require("../models/FlowType"); | ||
const RuleResult_1 = require("../models/RuleResult"); | ||
@@ -11,3 +12,3 @@ const RuleDefinitions_1 = require("../ruledefinitions/RuleDefinitions"); | ||
constructor() { | ||
super(RuleDefinitions_1.RuleDefinitions.MissingFaultPath, [{ 'label': 'Flow Best Practices', 'path': 'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5' }]); | ||
super(RuleDefinitions_1.RuleDefinitions.MissingFaultPath, [...FlowType_1.FlowType.backEndTypes, ...FlowType_1.FlowType.visualTypes], [{ label: 'Flow Best Practices', path: 'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5' }]); | ||
} | ||
@@ -23,3 +24,3 @@ execute(flow) { | ||
} | ||
return new RuleResult_1.RuleResult('MissingFaultPath', 'pattern', elementsWithoutFaultPath.length > 0, elementsWithoutFaultPath); | ||
return new RuleResult_1.RuleResult(elementsWithoutFaultPath.length > 0, this.name, 'pattern', elementsWithoutFaultPath); | ||
} | ||
@@ -26,0 +27,0 @@ } |
import { IRuleDefinition } from '../interfaces/IRuleDefinition'; | ||
import { Flow } from '../models/Flow'; | ||
import { RuleResult } from '../models/RuleResult'; | ||
import { RuleCommon } from "./RuleCommon"; | ||
import { RuleCommon } from './RuleCommon'; | ||
export declare class MissingFlowDescription extends RuleCommon implements IRuleDefinition { | ||
@@ -6,0 +6,0 @@ constructor(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MissingFlowDescription = void 0; | ||
const FlowType_1 = require("../models/FlowType"); | ||
const RuleResult_1 = require("../models/RuleResult"); | ||
@@ -9,7 +10,7 @@ const RuleDefinitions_1 = require("../ruledefinitions/RuleDefinitions"); | ||
constructor() { | ||
super(RuleDefinitions_1.RuleDefinitions.MissingFlowDescription); | ||
super(RuleDefinitions_1.RuleDefinitions.MissingFlowDescription, FlowType_1.FlowType.allTypes); | ||
} | ||
execute(flow) { | ||
let missingFlowDescription = !flow.xmldata.description; | ||
return new RuleResult_1.RuleResult(RuleDefinitions_1.RuleDefinitions.MissingFlowDescription, 'flow', missingFlowDescription); | ||
const missingFlowDescription = !flow.xmldata.description; | ||
return new RuleResult_1.RuleResult(missingFlowDescription, this.name, 'flow'); | ||
} | ||
@@ -16,0 +17,0 @@ } |
import { IRuleDefinition } from '../interfaces/IRuleDefinition'; | ||
import { Flow } from '../models/Flow'; | ||
import { RuleResult } from '../models/RuleResult'; | ||
import { RuleCommon } from "./RuleCommon"; | ||
import { RuleCommon } from './RuleCommon'; | ||
export declare class MissingNullHandler extends RuleCommon implements IRuleDefinition { | ||
@@ -6,0 +6,0 @@ constructor(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MissingNullHandler = void 0; | ||
const FlowType_1 = require("../models/FlowType"); | ||
const RuleResult_1 = require("../models/RuleResult"); | ||
@@ -9,3 +10,3 @@ const RuleDefinitions_1 = require("../ruledefinitions/RuleDefinitions"); | ||
constructor() { | ||
super(RuleDefinitions_1.RuleDefinitions.MissingNullHandler); | ||
super(RuleDefinitions_1.RuleDefinitions.MissingNullHandler, [...FlowType_1.FlowType.backEndTypes, ...FlowType_1.FlowType.visualTypes]); | ||
} | ||
@@ -44,3 +45,3 @@ execute(flow) { | ||
} | ||
return new RuleResult_1.RuleResult('MissingNullHandler', 'pattern', getOperationsWithoutNullHandler.length > 0, getOperationsWithoutNullHandler); | ||
return new RuleResult_1.RuleResult(getOperationsWithoutNullHandler.length > 0, this.name, 'pattern', getOperationsWithoutNullHandler); | ||
} | ||
@@ -47,0 +48,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { RuleDefinitions } from "../ruledefinitions/RuleDefinitions"; | ||
import { RuleDefinitions } from '../ruledefinitions/RuleDefinitions'; | ||
export declare class RuleCommon { | ||
@@ -11,3 +11,4 @@ label: any; | ||
text: string; | ||
constructor(name: RuleDefinitions, docRefs?: { | ||
supportedTypes: string[]; | ||
constructor(name: RuleDefinitions, supportedTypes: string[], docRefs?: { | ||
label: string; | ||
@@ -14,0 +15,0 @@ path: string; |
@@ -6,3 +6,3 @@ "use strict"; | ||
class RuleCommon { | ||
constructor(name, docRefs) { | ||
constructor(name, supportedTypes, docRefs) { | ||
this.docRefs = []; | ||
@@ -12,2 +12,3 @@ if (docRefs) { | ||
} | ||
this.supportedTypes = supportedTypes; | ||
this.name = name; | ||
@@ -14,0 +15,0 @@ const rule = RuleInfo_1.RuleInfo(name); |
import { IRuleDefinition } from '../interfaces/IRuleDefinition'; | ||
import { Flow } from '../models/Flow'; | ||
import { RuleResult } from '../models/RuleResult'; | ||
import { RuleCommon } from "./RuleCommon"; | ||
import { RuleCommon } from './RuleCommon'; | ||
export declare class UnconnectedElements extends RuleCommon implements IRuleDefinition { | ||
@@ -6,0 +6,0 @@ constructor(); |
@@ -5,2 +5,3 @@ "use strict"; | ||
const FlowElement_1 = require("../models/FlowElement"); | ||
const FlowType_1 = require("../models/FlowType"); | ||
const RuleResult_1 = require("../models/RuleResult"); | ||
@@ -11,3 +12,3 @@ const RuleDefinitions_1 = require("../ruledefinitions/RuleDefinitions"); | ||
constructor() { | ||
super(RuleDefinitions_1.RuleDefinitions.UnconnectedElements); | ||
super(RuleDefinitions_1.RuleDefinitions.UnconnectedElements, [...FlowType_1.FlowType.backEndTypes, ...FlowType_1.FlowType.visualTypes]); | ||
} | ||
@@ -43,5 +44,5 @@ execute(flow) { | ||
if (references.length > 0) { | ||
const elementsByReferences = flowElements.filter(element => references.includes(element.name)); | ||
const elementsByReferences = flowElements.filter(anElement => references.includes(anElement.name)); | ||
for (const nextElement of elementsByReferences) { | ||
const nextIndex = flowElements.findIndex(element => nextElement.name === element.name); | ||
const nextIndex = flowElements.findIndex(anElement => nextElement.name === anElement.name); | ||
if (!processedElementIndexes.includes(nextIndex)) { | ||
@@ -60,3 +61,2 @@ indexesToProcess.push(nextIndex); | ||
unconnectedElementIndexes.push(index); | ||
unconnectedElementIndexes.push(index); | ||
} | ||
@@ -76,3 +76,3 @@ } | ||
} | ||
return new RuleResult_1.RuleResult('UnconnectedElements', 'pattern', unconnectedElements.length > 0, unconnectedElements); | ||
return new RuleResult_1.RuleResult(unconnectedElements.length > 0, this.name, 'pattern', unconnectedElements); | ||
} | ||
@@ -79,0 +79,0 @@ findStart(nodes) { |
import { IRuleDefinition } from '../interfaces/IRuleDefinition'; | ||
import { Flow } from '../models/Flow'; | ||
import { RuleResult } from '../models/RuleResult'; | ||
import { RuleCommon } from "./RuleCommon"; | ||
import { RuleCommon } from './RuleCommon'; | ||
export declare class UnusedVariables extends RuleCommon implements IRuleDefinition { | ||
@@ -6,0 +6,0 @@ constructor(); |
@@ -5,2 +5,3 @@ "use strict"; | ||
const FlowElement_1 = require("../models/FlowElement"); | ||
const FlowType_1 = require("../models/FlowType"); | ||
const FlowVariable_1 = require("../models/FlowVariable"); | ||
@@ -12,3 +13,3 @@ const RuleResult_1 = require("../models/RuleResult"); | ||
constructor() { | ||
super(RuleDefinitions_1.RuleDefinitions.UnusedVariables); | ||
super(RuleDefinitions_1.RuleDefinitions.UnusedVariables, [...FlowType_1.FlowType.backEndTypes, ...FlowType_1.FlowType.visualTypes]); | ||
} | ||
@@ -29,3 +30,3 @@ execute(flow) { | ||
} | ||
return new RuleResult_1.RuleResult('UnusedVariables', 'pattern', unusedVariables.length > 0, unusedVariables); | ||
return new RuleResult_1.RuleResult(unusedVariables.length > 0, this.name, 'pattern', unusedVariables); | ||
} | ||
@@ -32,0 +33,0 @@ } |
{ | ||
"name": "lightning-flow-scanner-core", | ||
"version": "1.0.43", | ||
"version": "1.0.45", | ||
"main": "out/**", | ||
@@ -5,0 +5,0 @@ "types": "out/index.d.ts", |
@@ -9,4 +9,5 @@ import {Flow} from '../models/Flow'; | ||
text: string; | ||
supportedTypes: string[]; | ||
execute(flow: Flow): RuleResult; | ||
} |
@@ -19,7 +19,8 @@ import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
for (const rule of selectedRules) { | ||
try { | ||
ruleResults.push(rule.execute(flow)); | ||
} catch (error) { | ||
// todo push error result | ||
ruleResults.push(new RuleResult(rule.name, "error", false, [error])); | ||
if(rule.supportedTypes.includes(flow.type[0])) { | ||
try { | ||
ruleResults.push(rule.execute(flow)); | ||
} catch (error) { | ||
ruleResults.push(new RuleResult( true, rule.name, 'error', [error])); | ||
} | ||
} | ||
@@ -26,0 +27,0 @@ } |
@@ -21,3 +21,2 @@ import {FlowElement} from './FlowElement'; | ||
public root?; | ||
public nodes?: FlowNode[]; | ||
@@ -24,0 +23,0 @@ |
@@ -8,11 +8,10 @@ import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
constructor(ruleName: string, type: string, occurs : boolean, details?: (FlowElement[] | FlowVariable[])) { | ||
constructor(occurs: boolean, ruleName: string, type: string, details?: (FlowElement[] | FlowVariable[])) { | ||
this.occurs = occurs; | ||
this.ruleName = ruleName; | ||
this.type = type; | ||
if(details){ | ||
this.details = details; | ||
} | ||
this.ruleName = ruleName; | ||
this.type = type; | ||
for (const ruleDefinitionName in RuleDefinitions) { | ||
@@ -19,0 +18,0 @@ if (ruleDefinitionName === ruleName) { |
@@ -1,2 +0,2 @@ | ||
import {FlowScanOverrides} from "./FlowScanOverrides"; | ||
import {FlowScanOverrides} from './FlowScanOverrides'; | ||
@@ -3,0 +3,0 @@ export class ScannerOptions { |
import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
import {Flow} from '../models/Flow'; | ||
import {FlowElement} from '../models/FlowElement'; | ||
import {FlowType} from '../models/FlowType'; | ||
import {RuleResult} from '../models/RuleResult'; | ||
import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
import {RuleCommon} from "./RuleCommon"; | ||
import {RuleCommon} from './RuleCommon'; | ||
@@ -11,7 +12,6 @@ export class DMLStatementInLoop extends RuleCommon implements IRuleDefinition{ | ||
constructor() { | ||
super(RuleDefinitions.DMLStatementInLoop, [{'label': 'Flow Best Practices', 'path':'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5'}]); | ||
super(RuleDefinitions.DMLStatementInLoop, [...FlowType.backEndTypes, ...FlowType.visualTypes],[{'label': 'Flow Best Practices', 'path':'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5'}]); | ||
} | ||
public execute(flow: Flow) : RuleResult { | ||
const dmlStatementTypes = ['recordLookups', 'recordDeletes', 'recordUpdates', 'recordCreates']; | ||
@@ -44,5 +44,5 @@ const flowElements: FlowElement[] = flow.nodes.filter(node => node.nodeType === 'element') as FlowElement[]; | ||
if (connectors.length > 0) { | ||
const elementsByReferences = flowElements.filter(element => connectors.map(c => c.reference).includes(element.name)); | ||
const elementsByReferences = flowElements.filter(anElement => connectors.map(c => c.reference).includes(anElement.name)); | ||
for (const nextElement of elementsByReferences) { | ||
const nextIndex = flowElements.findIndex(element => nextElement.name === element.name); | ||
const nextIndex = flowElements.findIndex(anElement => nextElement.name === anElement.name); | ||
if ('loops' === nextElement.subtype) { | ||
@@ -67,3 +67,3 @@ reachedEndOfLoop = true; | ||
} | ||
return new RuleResult('DMLStatementInLoop','pattern', dmlStatementsInLoops.length > 0, dmlStatementsInLoops); | ||
return new RuleResult(dmlStatementsInLoops.length > 0, this.name, 'pattern', dmlStatementsInLoops); | ||
} | ||
@@ -70,0 +70,0 @@ |
import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
import {Flow} from '../models/Flow'; | ||
import {FlowElement} from '../models/FlowElement'; | ||
import {FlowType} from '../models/FlowType'; | ||
import {RuleResult} from '../models/RuleResult'; | ||
@@ -11,3 +12,3 @@ import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
constructor() { | ||
super(RuleDefinitions.DuplicateDMLOperationsByNavigation); | ||
super(RuleDefinitions.DuplicateDMLOperationsByNavigation, FlowType.visualTypes); | ||
} | ||
@@ -66,3 +67,3 @@ | ||
} while ((processedElementIndexes.length + unconnectedElementIndexes.length) < flowElements.length); | ||
return new RuleResult('DuplicateDMLOperationsByNavigation', 'pattern', duplicateDMLOperationsByNavigation.length > 0, duplicateDMLOperationsByNavigation); | ||
return new RuleResult( duplicateDMLOperationsByNavigation.length > 0, this.name, 'pattern', duplicateDMLOperationsByNavigation); | ||
} | ||
@@ -69,0 +70,0 @@ |
import * as IdPrefixes from '../data/IdPrefixes.json'; | ||
import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
import {Flow} from '../models/Flow'; | ||
import {FlowType} from '../models/FlowType'; | ||
import {RuleResult} from '../models/RuleResult'; | ||
import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
import {RuleCommon} from "./RuleCommon"; | ||
import {RuleCommon} from './RuleCommon'; | ||
@@ -11,3 +12,3 @@ export class HardcodedIds extends RuleCommon implements IRuleDefinition{ | ||
constructor() { | ||
super(RuleDefinitions.HardcodedIds, [{'label': 'Flow Best Practices', 'path':'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5'}]); | ||
super(RuleDefinitions.HardcodedIds, FlowType.allTypes,[{'label': 'Flow Best Practices', 'path':'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5'}]); | ||
} | ||
@@ -39,4 +40,4 @@ | ||
} | ||
return new RuleResult('HardcodedIds', 'pattern', nodesWithHardcodedIds.length > 0, nodesWithHardcodedIds); | ||
return new RuleResult( nodesWithHardcodedIds.length > 0, this.name, 'pattern', nodesWithHardcodedIds); | ||
} | ||
} |
import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
import {Flow} from '../models/Flow'; | ||
import {FlowElement} from '../models/FlowElement'; | ||
import {FlowType} from '../models/FlowType'; | ||
import {RuleResult} from '../models/RuleResult'; | ||
import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
import {RuleCommon} from "./RuleCommon"; | ||
import {RuleCommon} from './RuleCommon'; | ||
@@ -11,3 +12,3 @@ export class MissingFaultPath extends RuleCommon implements IRuleDefinition { | ||
constructor() { | ||
super(RuleDefinitions.MissingFaultPath, [{'label': 'Flow Best Practices', 'path':'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5'}]); | ||
super(RuleDefinitions.MissingFaultPath, [...FlowType.backEndTypes, ...FlowType.visualTypes],[{label: 'Flow Best Practices', path:'https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5'}]); | ||
} | ||
@@ -17,3 +18,2 @@ | ||
public execute(flow: Flow) : RuleResult { | ||
const typesWithFaultPath = ['recordLookups', 'recordDeletes', 'recordUpdates', 'recordCreates', 'waits', 'actionCalls']; | ||
@@ -27,4 +27,4 @@ const flowElementsWhereFaultPathIsApplicable: FlowElement[] = flow.nodes.filter(node => node instanceof FlowElement && typesWithFaultPath.includes(node.subtype)) as FlowElement[]; | ||
} | ||
return new RuleResult('MissingFaultPath', 'pattern', elementsWithoutFaultPath.length > 0, elementsWithoutFaultPath); | ||
return new RuleResult( elementsWithoutFaultPath.length > 0, this.name, 'pattern', elementsWithoutFaultPath); | ||
} | ||
} |
import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
import {Flow} from '../models/Flow'; | ||
import {FlowType} from '../models/FlowType'; | ||
import {RuleResult} from '../models/RuleResult'; | ||
import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
import {RuleCommon} from "./RuleCommon"; | ||
import {RuleCommon} from './RuleCommon'; | ||
@@ -10,9 +11,9 @@ export class MissingFlowDescription extends RuleCommon implements IRuleDefinition{ | ||
constructor() { | ||
super(RuleDefinitions.MissingFlowDescription); | ||
super(RuleDefinitions.MissingFlowDescription, FlowType.allTypes); | ||
} | ||
public execute(flow: Flow) : RuleResult { | ||
let missingFlowDescription = !flow.xmldata.description; | ||
return new RuleResult(RuleDefinitions.MissingFlowDescription, 'flow', missingFlowDescription); | ||
const missingFlowDescription = !flow.xmldata.description; | ||
return new RuleResult(missingFlowDescription, this.name, 'flow'); | ||
} | ||
} |
import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
import {Flow} from '../models/Flow'; | ||
import {FlowElement} from '../models/FlowElement'; | ||
import {FlowType} from '../models/FlowType'; | ||
import {RuleResult} from '../models/RuleResult'; | ||
import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
import {RuleCommon} from "./RuleCommon"; | ||
import {RuleCommon} from './RuleCommon'; | ||
@@ -11,7 +12,6 @@ export class MissingNullHandler extends RuleCommon implements IRuleDefinition{ | ||
constructor() { | ||
super(RuleDefinitions.MissingNullHandler); | ||
super(RuleDefinitions.MissingNullHandler, [...FlowType.backEndTypes, ...FlowType.visualTypes]); | ||
} | ||
public execute(flow: Flow) : RuleResult { | ||
const getOperations = ['recordLookups']; | ||
@@ -54,4 +54,4 @@ const getOperationElements: FlowElement[] = flow.nodes.filter(node => node.nodeType === 'element' && getOperations.includes(node.subtype)) as FlowElement[]; | ||
} | ||
return new RuleResult('MissingNullHandler', 'pattern', getOperationsWithoutNullHandler.length > 0, getOperationsWithoutNullHandler); | ||
return new RuleResult( getOperationsWithoutNullHandler.length > 0, this.name, 'pattern', getOperationsWithoutNullHandler); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import {RuleDefinitions} from "../ruledefinitions/RuleDefinitions"; | ||
import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
import {RuleInfo} from '../ruledefinitions/RuleInfo'; | ||
@@ -11,4 +11,5 @@ | ||
public text: string; | ||
public supportedTypes: string[]; | ||
constructor(name:RuleDefinitions, docRefs? : {label: string, path: string}[]){ | ||
constructor(name:RuleDefinitions, supportedTypes:string[], docRefs? : {label: string, path: string}[]){ | ||
@@ -18,2 +19,3 @@ if(docRefs){ | ||
} | ||
this.supportedTypes = supportedTypes; | ||
this.name = name; | ||
@@ -20,0 +22,0 @@ const rule = RuleInfo(name); |
@@ -5,5 +5,6 @@ import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
import {FlowNode} from '../models/FlowNode'; | ||
import {FlowType} from '../models/FlowType'; | ||
import {RuleResult} from '../models/RuleResult'; | ||
import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
import {RuleCommon} from "./RuleCommon"; | ||
import {RuleCommon} from './RuleCommon'; | ||
@@ -13,3 +14,3 @@ export class UnconnectedElements extends RuleCommon implements IRuleDefinition{ | ||
constructor() { | ||
super(RuleDefinitions.UnconnectedElements); | ||
super(RuleDefinitions.UnconnectedElements, [...FlowType.backEndTypes, ...FlowType.visualTypes]); | ||
} | ||
@@ -46,5 +47,5 @@ | ||
if (references.length > 0) { | ||
const elementsByReferences = flowElements.filter(element => references.includes(element.name)); | ||
const elementsByReferences = flowElements.filter(anElement => references.includes(anElement.name)); | ||
for (const nextElement of elementsByReferences) { | ||
const nextIndex = flowElements.findIndex(element => nextElement.name === element.name); | ||
const nextIndex = flowElements.findIndex(anElement => nextElement.name === anElement.name); | ||
if (!processedElementIndexes.includes(nextIndex)) { | ||
@@ -62,3 +63,2 @@ indexesToProcess.push(nextIndex); | ||
unconnectedElementIndexes.push(index); | ||
unconnectedElementIndexes.push(index); | ||
} | ||
@@ -78,3 +78,3 @@ } | ||
} | ||
return new RuleResult('UnconnectedElements', 'pattern', unconnectedElements.length > 0, unconnectedElements); | ||
return new RuleResult( unconnectedElements.length > 0, this.name, 'pattern', unconnectedElements); | ||
} | ||
@@ -81,0 +81,0 @@ |
import {IRuleDefinition} from '../interfaces/IRuleDefinition'; | ||
import {Flow} from '../models/Flow'; | ||
import {FlowElement} from '../models/FlowElement'; | ||
import {FlowType} from '../models/FlowType'; | ||
import {FlowVariable} from '../models/FlowVariable'; | ||
import {RuleResult} from '../models/RuleResult'; | ||
import {RuleDefinitions} from '../ruledefinitions/RuleDefinitions'; | ||
import {RuleCommon} from "./RuleCommon"; | ||
import {RuleCommon} from './RuleCommon'; | ||
@@ -12,3 +13,3 @@ export class UnusedVariables extends RuleCommon implements IRuleDefinition{ | ||
constructor() { | ||
super(RuleDefinitions.UnusedVariables); | ||
super(RuleDefinitions.UnusedVariables, [...FlowType.backEndTypes, ...FlowType.visualTypes]); | ||
} | ||
@@ -30,5 +31,5 @@ | ||
} | ||
return new RuleResult('UnusedVariables', 'pattern', unusedVariables.length > 0, unusedVariables); | ||
return new RuleResult( unusedVariables.length > 0, this.name, 'pattern', unusedVariables); | ||
} | ||
} |
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
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
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
707395
161
26112