@flow-scanner/lightning-flow-scanner-core 6.16.2 → 6.17.1
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/.husky/pre-commit +1 -0
- package/.husky/pre-push +1 -0
- package/.prettierignore +5 -0
- package/.swcrc +26 -0
- package/.turbo/turbo-build.log +17 -0
- package/.turbo/turbo-test.log +144 -0
- package/.turbo/turbo-vite$colon$dist.log +21 -0
- package/coverage/coverage-final.json +63 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +236 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/index.ts.html +238 -0
- package/coverage/lcov-report/src/main/adapters/RegexAdapter.ts.html +118 -0
- package/coverage/lcov-report/src/main/adapters/index.html +116 -0
- package/coverage/lcov-report/src/main/config/NodeIcons.ts.html +376 -0
- package/coverage/lcov-report/src/main/config/RuleRegistry.ts.html +646 -0
- package/coverage/lcov-report/src/main/config/VariableIcons.ts.html +253 -0
- package/coverage/lcov-report/src/main/config/index.html +146 -0
- package/coverage/lcov-report/src/main/enums/MetaType.ts.html +100 -0
- package/coverage/lcov-report/src/main/enums/MetadataType.ts.html +103 -0
- package/coverage/lcov-report/src/main/enums/MetadataTypes.ts.html +100 -0
- package/coverage/lcov-report/src/main/enums/index.html +116 -0
- package/coverage/lcov-report/src/main/interfaces/IRulesConfig.ts.html +133 -0
- package/coverage/lcov-report/src/main/interfaces/index.html +116 -0
- package/coverage/lcov-report/src/main/internals/index.html +116 -0
- package/coverage/lcov-report/src/main/internals/internals.ts.html +190 -0
- package/coverage/lcov-report/src/main/libs/BuildFlow.ts.html +127 -0
- package/coverage/lcov-report/src/main/libs/Compiler.ts.html +241 -0
- package/coverage/lcov-report/src/main/libs/ConvertFlowNodes.ts.html +97 -0
- package/coverage/lcov-report/src/main/libs/DynamicRule.ts.html +118 -0
- package/coverage/lcov-report/src/main/libs/ExportDetails.ts.html +256 -0
- package/coverage/lcov-report/src/main/libs/ExportDiagram.ts.html +331 -0
- package/coverage/lcov-report/src/main/libs/ExportSarif.ts.html +358 -0
- package/coverage/lcov-report/src/main/libs/FixFlows.ts.html +265 -0
- package/coverage/lcov-report/src/main/libs/GenerateMarkdown.ts.html +331 -0
- package/coverage/lcov-report/src/main/libs/GetRuleDefinitions.ts.html +274 -0
- package/coverage/lcov-report/src/main/libs/ParseFlows.ts.html +184 -0
- package/coverage/lcov-report/src/main/libs/RuleDocumentation.ts.html +190 -0
- package/coverage/lcov-report/src/main/libs/ScanFlows.ts.html +508 -0
- package/coverage/lcov-report/src/main/libs/exportAsDetails.ts.html +160 -0
- package/coverage/lcov-report/src/main/libs/exportAsSarif.ts.html +346 -0
- package/coverage/lcov-report/src/main/libs/index.html +251 -0
- package/coverage/lcov-report/src/main/models/FlatViolation.ts.html +106 -0
- package/coverage/lcov-report/src/main/models/Flow.ts.html +1057 -0
- package/coverage/lcov-report/src/main/models/FlowAttribute.ts.html +115 -0
- package/coverage/lcov-report/src/main/models/FlowElement.ts.html +133 -0
- package/coverage/lcov-report/src/main/models/FlowElementConnector.ts.html +169 -0
- package/coverage/lcov-report/src/main/models/FlowGraph.ts.html +1672 -0
- package/coverage/lcov-report/src/main/models/FlowMetadata.ts.html +106 -0
- package/coverage/lcov-report/src/main/models/FlowNode.ts.html +1252 -0
- package/coverage/lcov-report/src/main/models/FlowResource.ts.html +106 -0
- package/coverage/lcov-report/src/main/models/FlowType.ts.html +244 -0
- package/coverage/lcov-report/src/main/models/FlowVariable.ts.html +553 -0
- package/coverage/lcov-report/src/main/models/LoopRuleCommon.ts.html +235 -0
- package/coverage/lcov-report/src/main/models/ParsedFlow.ts.html +121 -0
- package/coverage/lcov-report/src/main/models/RuleCommon.ts.html +442 -0
- package/coverage/lcov-report/src/main/models/RuleResult.ts.html +172 -0
- package/coverage/lcov-report/src/main/models/ScanResult.ts.html +121 -0
- package/coverage/lcov-report/src/main/models/Violation.ts.html +316 -0
- package/coverage/lcov-report/src/main/models/index.html +341 -0
- package/coverage/lcov-report/src/main/rules/APIVersion.ts.html +361 -0
- package/coverage/lcov-report/src/main/rules/ActionCallsInLoop.ts.html +157 -0
- package/coverage/lcov-report/src/main/rules/AutoLayout.ts.html +220 -0
- package/coverage/lcov-report/src/main/rules/CopyAPIName.ts.html +175 -0
- package/coverage/lcov-report/src/main/rules/CyclomaticComplexity.ts.html +292 -0
- package/coverage/lcov-report/src/main/rules/DMLStatementInLoop.ts.html +163 -0
- package/coverage/lcov-report/src/main/rules/DuplicateDMLOperation.ts.html +334 -0
- package/coverage/lcov-report/src/main/rules/FlowDescription.ts.html +184 -0
- package/coverage/lcov-report/src/main/rules/FlowName.ts.html +229 -0
- package/coverage/lcov-report/src/main/rules/GetRecordAllFields.ts.html +280 -0
- package/coverage/lcov-report/src/main/rules/HardcodedId.ts.html +238 -0
- package/coverage/lcov-report/src/main/rules/HardcodedSecret.ts.html +238 -0
- package/coverage/lcov-report/src/main/rules/HardcodedUrl.ts.html +247 -0
- package/coverage/lcov-report/src/main/rules/InactiveFlow.ts.html +184 -0
- package/coverage/lcov-report/src/main/rules/MissingFaultPath.ts.html +397 -0
- package/coverage/lcov-report/src/main/rules/MissingFilterRecordTrigger.ts.html +229 -0
- package/coverage/lcov-report/src/main/rules/MissingMetadataDescription.ts.html +211 -0
- package/coverage/lcov-report/src/main/rules/MissingNullHandler.ts.html +460 -0
- package/coverage/lcov-report/src/main/rules/MissingRecordTriggerFilter.ts.html +235 -0
- package/coverage/lcov-report/src/main/rules/ProcessBuilder.ts.html +190 -0
- package/coverage/lcov-report/src/main/rules/RecordIdAsString.ts.html +274 -0
- package/coverage/lcov-report/src/main/rules/RecursiveAfterUpdate.ts.html +364 -0
- package/coverage/lcov-report/src/main/rules/SOQLQueryInLoop.ts.html +160 -0
- package/coverage/lcov-report/src/main/rules/SameRecordFieldUpdates.ts.html +283 -0
- package/coverage/lcov-report/src/main/rules/TransformInsteadOfLoop.ts.html +250 -0
- package/coverage/lcov-report/src/main/rules/TriggerOrder.ts.html +238 -0
- package/coverage/lcov-report/src/main/rules/UnconnectedElement.ts.html +178 -0
- package/coverage/lcov-report/src/main/rules/UnsafeRunningContext.ts.html +226 -0
- package/coverage/lcov-report/src/main/rules/UnusedVariable.ts.html +283 -0
- package/coverage/lcov-report/src/main/rules/index.html +521 -0
- package/coverage/lcov-report/src/main/store/DefaultRuleStore.ts.html +265 -0
- package/coverage/lcov-report/src/main/store/RuleRegistry.ts.html +118 -0
- package/coverage/lcov-report/src/main/store/index.html +116 -0
- package/coverage/lcov.info +6261 -0
- package/eslint.config.mjs +36 -0
- package/jest.config.cjs +32 -0
- package/jest.env-setup.js +101 -0
- package/lint-staged.config.mjs +8 -0
- package/out/main/config/RegexAdapter.d.ts +32 -0
- package/out/main/config/RegexAdapter.js +86 -0
- package/{main → out/main}/config/RuleRegistry.js +2 -0
- package/out/main/rules/FlowName.d.ts +15 -0
- package/{main → out/main}/rules/FlowName.js +24 -11
- package/out/main/rules/HardcodedId.d.ts +13 -0
- package/{main → out/main}/rules/HardcodedId.js +23 -4
- package/out/main/rules/HardcodedSecret.d.ts +13 -0
- package/out/main/rules/HardcodedSecret.js +101 -0
- package/{main → out/main}/rules/HardcodedUrl.d.ts +6 -0
- package/{main → out/main}/rules/HardcodedUrl.js +23 -5
- package/package.json +58 -8
- package/prettier.config.mjs +5 -0
- package/src/index.ts +52 -0
- package/src/main/config/NodeIcons.ts +98 -0
- package/src/main/config/RegexAdapter.ts +98 -0
- package/src/main/config/RuleRegistry.ts +188 -0
- package/src/main/config/VariableIcons.ts +57 -0
- package/src/main/enums/MetadataTypes.ts +6 -0
- package/src/main/interfaces/IExceptions.ts +6 -0
- package/src/main/interfaces/IRuleConfig.ts +6 -0
- package/src/main/interfaces/IRuleDefinition.ts +15 -0
- package/src/main/interfaces/IRuleOptions.ts +5 -0
- package/src/main/interfaces/IRulesConfig.ts +17 -0
- package/src/main/internals/internals.ts +35 -0
- package/src/main/libs/BuildFlow.ts +14 -0
- package/src/main/libs/Compiler.ts +53 -0
- package/src/main/libs/ExportDetails.ts +58 -0
- package/src/main/libs/ExportDiagram.ts +83 -0
- package/src/main/libs/ExportSarif.ts +92 -0
- package/src/main/libs/FixFlows.ts +61 -0
- package/src/main/libs/GetRuleDefinitions.ts +64 -0
- package/src/main/libs/ParseFlows.ts +34 -0
- package/src/main/libs/RuleDocumentation.ts +35 -0
- package/src/main/libs/ScanFlows.ts +142 -0
- package/src/main/models/FlatViolation.ts +16 -0
- package/src/main/models/Flow.ts +325 -0
- package/src/main/models/FlowAttribute.ts +11 -0
- package/src/main/models/FlowElement.ts +16 -0
- package/src/main/models/FlowElementConnector.ts +28 -0
- package/src/main/models/FlowGraph.ts +530 -0
- package/src/main/models/FlowMetadata.ts +8 -0
- package/src/main/models/FlowNode.ts +390 -0
- package/src/main/models/FlowResource.ts +8 -0
- package/src/main/models/FlowType.ts +53 -0
- package/src/main/models/FlowVariable.ts +157 -0
- package/src/main/models/LoopRuleCommon.ts +51 -0
- package/src/main/models/ParsedFlow.ts +13 -0
- package/src/main/models/RuleCommon.ts +120 -0
- package/src/main/models/RuleInfo.ts +54 -0
- package/src/main/models/RuleResult.ts +29 -0
- package/src/main/models/ScanResult.ts +12 -0
- package/src/main/models/Violation.ts +78 -0
- package/src/main/rules/APIVersion.ts +93 -0
- package/src/main/rules/ActionCallsInLoop.ts +25 -0
- package/src/main/rules/AutoLayout.ts +46 -0
- package/src/main/rules/CopyAPIName.ts +31 -0
- package/src/main/rules/CyclomaticComplexity.ts +70 -0
- package/src/main/rules/DMLStatementInLoop.ts +26 -0
- package/src/main/rules/DuplicateDMLOperation.ts +83 -0
- package/src/main/rules/FlowDescription.ts +34 -0
- package/src/main/rules/FlowName.ts +49 -0
- package/src/main/rules/GetRecordAllFields.ts +65 -0
- package/src/main/rules/HardcodedId.ts +51 -0
- package/src/main/rules/HardcodedSecret.ts +51 -0
- package/src/main/rules/HardcodedUrl.ts +54 -0
- package/src/main/rules/InactiveFlow.ts +33 -0
- package/src/main/rules/MissingFaultPath.ts +105 -0
- package/src/main/rules/MissingMetadataDescription.ts +42 -0
- package/src/main/rules/MissingNullHandler.ts +126 -0
- package/src/main/rules/MissingRecordTriggerFilter.ts +51 -0
- package/src/main/rules/ProcessBuilder.ts +35 -0
- package/src/main/rules/RecordIdAsString.ts +64 -0
- package/src/main/rules/RecursiveAfterUpdate.ts +94 -0
- package/src/main/rules/SOQLQueryInLoop.ts +26 -0
- package/src/main/rules/SameRecordFieldUpdates.ts +66 -0
- package/src/main/rules/TransformInsteadOfLoop.ts +56 -0
- package/src/main/rules/TriggerOrder.ts +51 -0
- package/src/main/rules/UnconnectedElement.ts +32 -0
- package/src/main/rules/UnsafeRunningContext.ts +47 -0
- package/src/main/rules/UnusedVariable.ts +66 -0
- package/stryker.config.mjs +23 -0
- package/tests/APIVersion.test.ts +87 -0
- package/tests/AutoLayout.test.ts +41 -0
- package/tests/Config.test.ts +122 -0
- package/tests/ConfigBetaMode.test.ts +26 -0
- package/tests/CopyAPIName.test.ts +45 -0
- package/tests/CyclomaticComplexity.test.ts +125 -0
- package/tests/DMLStatementInLoop.test.ts +32 -0
- package/tests/DuplicateDMLOperation.test.ts +43 -0
- package/tests/EnabledFalse.test.ts +63 -0
- package/tests/Exceptions.test.ts +815 -0
- package/tests/ExportSarif.test.ts +62 -0
- package/tests/FlowDescription.test.ts +44 -0
- package/tests/FlowDocumentation.test.ts +74 -0
- package/tests/FlowName.test.ts +61 -0
- package/tests/GetRecordElementAllFields.test.ts +182 -0
- package/tests/HardcodedId.test.ts +16 -0
- package/tests/HardcodedSecret.test.ts +32 -0
- package/tests/HardcodedUrl.test.ts +253 -0
- package/tests/InactiveFlow.test.ts +103 -0
- package/tests/MissingFaultPath.test.ts +52 -0
- package/tests/MissingMetadataDescription.test.ts +25 -0
- package/tests/MissingNullHandler.test.ts +45 -0
- package/tests/MissingRecordTriggerFilter.test.ts +54 -0
- package/tests/RecordIdAsString.test.ts +60 -0
- package/tests/RecursiveAfterUpdate.test.ts +183 -0
- package/tests/SOQLQueryInLoop.test.ts +33 -0
- package/tests/SameRecordFieldUpdates.test.ts +205 -0
- package/tests/SanityTest.test.ts +15 -0
- package/tests/TransformInsteadOfLoop.test.ts +33 -0
- package/tests/TriggerOrder.test.ts +112 -0
- package/tests/UnconnectedElement.test.ts +76 -0
- package/tests/UnsafeRunningContext.test.ts +46 -0
- package/tests/UnusedVariable.test.ts +59 -0
- package/tests/UnusedVariableExceptions.test.ts +87 -0
- package/tests/jsonfiles/MissingFaultPath_BeforeSave_Bypass.json +128 -0
- package/tests/jsonfiles/MissingFaultPath_WaitConditions.json +102 -0
- package/tests/jsonfiles/MissingFaultPath_WaitDate.json +88 -0
- package/tests/jsonfiles/MissingFaultPath_WaitDuration.json +90 -0
- package/tests/models/Flow.test.ts +107 -0
- package/tests/models/LoopRuleCommon.test.ts +246 -0
- package/tests/models/RuleCommon.test.ts +41 -0
- package/tsconfig.json +28 -0
- package/tsconfig.types.json +26 -0
- package/types/index.d.ts +27 -0
- package/types/index.d.ts.map +1 -0
- package/types/main/adapters/RegexAdapter.d.ts +33 -0
- package/types/main/adapters/RegexAdapter.d.ts.map +1 -0
- package/types/main/config/NodeIcons.d.ts +25 -0
- package/types/main/config/NodeIcons.d.ts.map +1 -0
- package/types/main/config/RegexAdapter.d.ts +33 -0
- package/types/main/config/RegexAdapter.d.ts.map +1 -0
- package/types/main/config/RuleRegistry.d.ts +23 -0
- package/types/main/config/RuleRegistry.d.ts.map +1 -0
- package/types/main/config/VariableIcons.d.ts +26 -0
- package/types/main/config/VariableIcons.d.ts.map +1 -0
- package/types/main/enums/MetadataTypes.d.ts +7 -0
- package/types/main/enums/MetadataTypes.d.ts.map +1 -0
- package/types/main/interfaces/IExceptions.d.ts +6 -0
- package/types/main/interfaces/IExceptions.d.ts.map +1 -0
- package/types/main/interfaces/IRuleConfig.d.ts +7 -0
- package/types/main/interfaces/IRuleConfig.d.ts.map +1 -0
- package/types/main/interfaces/IRuleDefinition.d.ts +18 -0
- package/types/main/interfaces/IRuleDefinition.d.ts.map +1 -0
- package/types/main/interfaces/IRuleOptions.d.ts +5 -0
- package/types/main/interfaces/IRuleOptions.d.ts.map +1 -0
- package/types/main/interfaces/IRulesConfig.d.ts +16 -0
- package/types/main/interfaces/IRulesConfig.d.ts.map +1 -0
- package/types/main/internals/internals.d.ts +19 -0
- package/types/main/internals/internals.d.ts.map +1 -0
- package/types/main/libs/BuildFlow.d.ts +2 -0
- package/types/main/libs/BuildFlow.d.ts.map +1 -0
- package/types/main/libs/Compiler.d.ts +8 -0
- package/types/main/libs/Compiler.d.ts.map +1 -0
- package/types/main/libs/ConvertFlowNodes.d.ts +2 -0
- package/types/main/libs/ConvertFlowNodes.d.ts.map +1 -0
- package/types/main/libs/DynamicRule.d.ts +5 -0
- package/types/main/libs/DynamicRule.d.ts.map +1 -0
- package/types/main/libs/ExportDetails.d.ts +4 -0
- package/types/main/libs/ExportDetails.d.ts.map +1 -0
- package/types/main/libs/ExportDiagram.d.ts +42 -0
- package/types/main/libs/ExportDiagram.d.ts.map +1 -0
- package/types/main/libs/ExportSarif.d.ts +3 -0
- package/types/main/libs/ExportSarif.d.ts.map +1 -0
- package/types/main/libs/FixFlows.d.ts +4 -0
- package/types/main/libs/FixFlows.d.ts.map +1 -0
- package/types/main/libs/GetRuleDefinitions.d.ts +5 -0
- package/types/main/libs/GetRuleDefinitions.d.ts.map +1 -0
- package/types/main/libs/ParseFlows.d.ts +3 -0
- package/types/main/libs/ParseFlows.d.ts.map +1 -0
- package/types/main/libs/RuleDocumentation.d.ts +21 -0
- package/types/main/libs/RuleDocumentation.d.ts.map +1 -0
- package/types/main/libs/ScanFlows.d.ts +5 -0
- package/types/main/libs/ScanFlows.d.ts.map +1 -0
- package/types/main/libs/exportAsDetails.d.ts +4 -0
- package/types/main/libs/exportAsDetails.d.ts.map +1 -0
- package/types/main/libs/exportAsSarif.d.ts +3 -0
- package/types/main/libs/exportAsSarif.d.ts.map +1 -0
- package/types/main/models/FlatViolation.d.ts +16 -0
- package/types/main/models/FlatViolation.d.ts.map +1 -0
- package/types/main/models/Flow.d.ts +70 -0
- package/types/main/models/Flow.d.ts.map +1 -0
- package/types/main/models/FlowAttribute.d.ts +6 -0
- package/types/main/models/FlowAttribute.d.ts.map +1 -0
- package/types/main/models/FlowElement.d.ts +11 -0
- package/types/main/models/FlowElement.d.ts.map +1 -0
- package/types/main/models/FlowElementConnector.d.ts +16 -0
- package/types/main/models/FlowElementConnector.d.ts.map +1 -0
- package/types/main/models/FlowGraph.d.ts +86 -0
- package/types/main/models/FlowGraph.d.ts.map +1 -0
- package/types/main/models/FlowMetadata.d.ts +5 -0
- package/types/main/models/FlowMetadata.d.ts.map +1 -0
- package/types/main/models/FlowNode.d.ts +66 -0
- package/types/main/models/FlowNode.d.ts.map +1 -0
- package/types/main/models/FlowResource.d.ts +5 -0
- package/types/main/models/FlowResource.d.ts.map +1 -0
- package/types/main/models/FlowType.d.ts +24 -0
- package/types/main/models/FlowType.d.ts.map +1 -0
- package/types/main/models/FlowVariable.d.ts +64 -0
- package/types/main/models/FlowVariable.d.ts.map +1 -0
- package/types/main/models/LoopRuleCommon.d.ts +15 -0
- package/types/main/models/LoopRuleCommon.d.ts.map +1 -0
- package/types/main/models/ParsedFlow.d.ts +8 -0
- package/types/main/models/ParsedFlow.d.ts.map +1 -0
- package/types/main/models/RuleCommon.d.ts +58 -0
- package/types/main/models/RuleCommon.d.ts.map +1 -0
- package/types/main/models/RuleInfo.d.ts +50 -0
- package/types/main/models/RuleInfo.d.ts.map +1 -0
- package/types/main/models/RuleResult.d.ts +15 -0
- package/types/main/models/RuleResult.d.ts.map +1 -0
- package/types/main/models/ScanResult.d.ts +8 -0
- package/types/main/models/ScanResult.d.ts.map +1 -0
- package/types/main/models/Violation.d.ts +12 -0
- package/types/main/models/Violation.d.ts.map +1 -0
- package/{main/rules/FlowName.d.ts → types/main/rules/APIVersion.d.ts} +2 -1
- package/types/main/rules/APIVersion.d.ts.map +1 -0
- package/types/main/rules/ActionCallsInLoop.d.ts +7 -0
- package/types/main/rules/ActionCallsInLoop.d.ts.map +1 -0
- package/types/main/rules/AutoLayout.d.ts +8 -0
- package/types/main/rules/AutoLayout.d.ts.map +1 -0
- package/types/main/rules/CopyAPIName.d.ts +8 -0
- package/types/main/rules/CopyAPIName.d.ts.map +1 -0
- package/types/main/rules/CyclomaticComplexity.d.ts +12 -0
- package/types/main/rules/CyclomaticComplexity.d.ts.map +1 -0
- package/types/main/rules/DMLStatementInLoop.d.ts +7 -0
- package/types/main/rules/DMLStatementInLoop.d.ts.map +1 -0
- package/types/main/rules/DuplicateDMLOperation.d.ts +9 -0
- package/types/main/rules/DuplicateDMLOperation.d.ts.map +1 -0
- package/{main/rules/HardcodedId.d.ts → types/main/rules/FlowDescription.d.ts} +2 -1
- package/types/main/rules/FlowDescription.d.ts.map +1 -0
- package/types/main/rules/FlowName.d.ts +16 -0
- package/types/main/rules/FlowName.d.ts.map +1 -0
- package/types/main/rules/GetRecordAllFields.d.ts +8 -0
- package/types/main/rules/GetRecordAllFields.d.ts.map +1 -0
- package/types/main/rules/HardcodedId.d.ts +14 -0
- package/types/main/rules/HardcodedId.d.ts.map +1 -0
- package/types/main/rules/HardcodedSecret.d.ts +14 -0
- package/types/main/rules/HardcodedSecret.d.ts.map +1 -0
- package/types/main/rules/HardcodedUrl.d.ts +14 -0
- package/types/main/rules/HardcodedUrl.d.ts.map +1 -0
- package/types/main/rules/InactiveFlow.d.ts +8 -0
- package/types/main/rules/InactiveFlow.d.ts.map +1 -0
- package/types/main/rules/MissingFaultPath.d.ts +15 -0
- package/types/main/rules/MissingFaultPath.d.ts.map +1 -0
- package/types/main/rules/MissingFilterRecordTrigger.d.ts +8 -0
- package/types/main/rules/MissingFilterRecordTrigger.d.ts.map +1 -0
- package/types/main/rules/MissingMetadataDescription.d.ts +8 -0
- package/types/main/rules/MissingMetadataDescription.d.ts.map +1 -0
- package/types/main/rules/MissingNullHandler.d.ts +8 -0
- package/types/main/rules/MissingNullHandler.d.ts.map +1 -0
- package/types/main/rules/MissingRecordTriggerFilter.d.ts +8 -0
- package/types/main/rules/MissingRecordTriggerFilter.d.ts.map +1 -0
- package/types/main/rules/ProcessBuilder.d.ts +8 -0
- package/types/main/rules/ProcessBuilder.d.ts.map +1 -0
- package/types/main/rules/RecordIdAsString.d.ts +8 -0
- package/types/main/rules/RecordIdAsString.d.ts.map +1 -0
- package/types/main/rules/RecursiveAfterUpdate.d.ts +9 -0
- package/types/main/rules/RecursiveAfterUpdate.d.ts.map +1 -0
- package/types/main/rules/SOQLQueryInLoop.d.ts +7 -0
- package/types/main/rules/SOQLQueryInLoop.d.ts.map +1 -0
- package/types/main/rules/SameRecordFieldUpdates.d.ts +9 -0
- package/types/main/rules/SameRecordFieldUpdates.d.ts.map +1 -0
- package/types/main/rules/TransformInsteadOfLoop.d.ts +8 -0
- package/types/main/rules/TransformInsteadOfLoop.d.ts.map +1 -0
- package/types/main/rules/TriggerOrder.d.ts +8 -0
- package/types/main/rules/TriggerOrder.d.ts.map +1 -0
- package/types/main/rules/UnconnectedElement.d.ts +8 -0
- package/types/main/rules/UnconnectedElement.d.ts.map +1 -0
- package/types/main/rules/UnsafeRunningContext.d.ts +8 -0
- package/types/main/rules/UnsafeRunningContext.d.ts.map +1 -0
- package/types/main/rules/UnusedVariable.d.ts +8 -0
- package/types/main/rules/UnusedVariable.d.ts.map +1 -0
- package/types/main/store/DefaultRuleStore.d.ts +3 -0
- package/types/main/store/DefaultRuleStore.d.ts.map +1 -0
- package/types/main/store/RuleRegistry.d.ts +23 -0
- package/types/main/store/RuleRegistry.d.ts.map +1 -0
- package/vite.config.ts +33 -0
- package/README.md +0 -635
- /package/{index.d.ts → out/index.d.ts} +0 -0
- /package/{index.js → out/index.js} +0 -0
- /package/{main → out/main}/config/NodeIcons.d.ts +0 -0
- /package/{main → out/main}/config/NodeIcons.js +0 -0
- /package/{main → out/main}/config/RuleRegistry.d.ts +0 -0
- /package/{main → out/main}/config/VariableIcons.d.ts +0 -0
- /package/{main → out/main}/config/VariableIcons.js +0 -0
- /package/{main → out/main}/enums/MetadataTypes.d.ts +0 -0
- /package/{main → out/main}/enums/MetadataTypes.js +0 -0
- /package/{main → out/main}/interfaces/IExceptions.d.ts +0 -0
- /package/{main → out/main}/interfaces/IExceptions.js +0 -0
- /package/{main → out/main}/interfaces/IRuleConfig.d.ts +0 -0
- /package/{main → out/main}/interfaces/IRuleConfig.js +0 -0
- /package/{main → out/main}/interfaces/IRuleDefinition.d.ts +0 -0
- /package/{main → out/main}/interfaces/IRuleDefinition.js +0 -0
- /package/{main → out/main}/interfaces/IRuleOptions.d.ts +0 -0
- /package/{main → out/main}/interfaces/IRuleOptions.js +0 -0
- /package/{main → out/main}/interfaces/IRulesConfig.d.ts +0 -0
- /package/{main → out/main}/interfaces/IRulesConfig.js +0 -0
- /package/{main → out/main}/internals/internals.d.ts +0 -0
- /package/{main → out/main}/internals/internals.js +0 -0
- /package/{main → out/main}/libs/BuildFlow.d.ts +0 -0
- /package/{main → out/main}/libs/BuildFlow.js +0 -0
- /package/{main → out/main}/libs/Compiler.d.ts +0 -0
- /package/{main → out/main}/libs/Compiler.js +0 -0
- /package/{main → out/main}/libs/ExportDetails.d.ts +0 -0
- /package/{main → out/main}/libs/ExportDetails.js +0 -0
- /package/{main → out/main}/libs/ExportDiagram.d.ts +0 -0
- /package/{main → out/main}/libs/ExportDiagram.js +0 -0
- /package/{main → out/main}/libs/ExportSarif.d.ts +0 -0
- /package/{main → out/main}/libs/ExportSarif.js +0 -0
- /package/{main → out/main}/libs/FixFlows.d.ts +0 -0
- /package/{main → out/main}/libs/FixFlows.js +0 -0
- /package/{main → out/main}/libs/GetRuleDefinitions.d.ts +0 -0
- /package/{main → out/main}/libs/GetRuleDefinitions.js +0 -0
- /package/{main → out/main}/libs/ParseFlows.d.ts +0 -0
- /package/{main → out/main}/libs/ParseFlows.js +0 -0
- /package/{main → out/main}/libs/RuleDocumentation.d.ts +0 -0
- /package/{main → out/main}/libs/RuleDocumentation.js +0 -0
- /package/{main → out/main}/libs/ScanFlows.d.ts +0 -0
- /package/{main → out/main}/libs/ScanFlows.js +0 -0
- /package/{main → out/main}/models/FlatViolation.d.ts +0 -0
- /package/{main → out/main}/models/FlatViolation.js +0 -0
- /package/{main → out/main}/models/Flow.d.ts +0 -0
- /package/{main → out/main}/models/Flow.js +0 -0
- /package/{main → out/main}/models/FlowAttribute.d.ts +0 -0
- /package/{main → out/main}/models/FlowAttribute.js +0 -0
- /package/{main → out/main}/models/FlowElement.d.ts +0 -0
- /package/{main → out/main}/models/FlowElement.js +0 -0
- /package/{main → out/main}/models/FlowElementConnector.d.ts +0 -0
- /package/{main → out/main}/models/FlowElementConnector.js +0 -0
- /package/{main → out/main}/models/FlowGraph.d.ts +0 -0
- /package/{main → out/main}/models/FlowGraph.js +0 -0
- /package/{main → out/main}/models/FlowMetadata.d.ts +0 -0
- /package/{main → out/main}/models/FlowMetadata.js +0 -0
- /package/{main → out/main}/models/FlowNode.d.ts +0 -0
- /package/{main → out/main}/models/FlowNode.js +0 -0
- /package/{main → out/main}/models/FlowResource.d.ts +0 -0
- /package/{main → out/main}/models/FlowResource.js +0 -0
- /package/{main → out/main}/models/FlowType.d.ts +0 -0
- /package/{main → out/main}/models/FlowType.js +0 -0
- /package/{main → out/main}/models/FlowVariable.d.ts +0 -0
- /package/{main → out/main}/models/FlowVariable.js +0 -0
- /package/{main → out/main}/models/LoopRuleCommon.d.ts +0 -0
- /package/{main → out/main}/models/LoopRuleCommon.js +0 -0
- /package/{main → out/main}/models/ParsedFlow.d.ts +0 -0
- /package/{main → out/main}/models/ParsedFlow.js +0 -0
- /package/{main → out/main}/models/RuleCommon.d.ts +0 -0
- /package/{main → out/main}/models/RuleCommon.js +0 -0
- /package/{main → out/main}/models/RuleInfo.d.ts +0 -0
- /package/{main → out/main}/models/RuleInfo.js +0 -0
- /package/{main → out/main}/models/RuleResult.d.ts +0 -0
- /package/{main → out/main}/models/RuleResult.js +0 -0
- /package/{main → out/main}/models/ScanResult.d.ts +0 -0
- /package/{main → out/main}/models/ScanResult.js +0 -0
- /package/{main → out/main}/models/Violation.d.ts +0 -0
- /package/{main → out/main}/models/Violation.js +0 -0
- /package/{main → out/main}/rules/APIVersion.d.ts +0 -0
- /package/{main → out/main}/rules/APIVersion.js +0 -0
- /package/{main → out/main}/rules/ActionCallsInLoop.d.ts +0 -0
- /package/{main → out/main}/rules/ActionCallsInLoop.js +0 -0
- /package/{main → out/main}/rules/AutoLayout.d.ts +0 -0
- /package/{main → out/main}/rules/AutoLayout.js +0 -0
- /package/{main → out/main}/rules/CopyAPIName.d.ts +0 -0
- /package/{main → out/main}/rules/CopyAPIName.js +0 -0
- /package/{main → out/main}/rules/CyclomaticComplexity.d.ts +0 -0
- /package/{main → out/main}/rules/CyclomaticComplexity.js +0 -0
- /package/{main → out/main}/rules/DMLStatementInLoop.d.ts +0 -0
- /package/{main → out/main}/rules/DMLStatementInLoop.js +0 -0
- /package/{main → out/main}/rules/DuplicateDMLOperation.d.ts +0 -0
- /package/{main → out/main}/rules/DuplicateDMLOperation.js +0 -0
- /package/{main → out/main}/rules/FlowDescription.d.ts +0 -0
- /package/{main → out/main}/rules/FlowDescription.js +0 -0
- /package/{main → out/main}/rules/GetRecordAllFields.d.ts +0 -0
- /package/{main → out/main}/rules/GetRecordAllFields.js +0 -0
- /package/{main → out/main}/rules/InactiveFlow.d.ts +0 -0
- /package/{main → out/main}/rules/InactiveFlow.js +0 -0
- /package/{main → out/main}/rules/MissingFaultPath.d.ts +0 -0
- /package/{main → out/main}/rules/MissingFaultPath.js +0 -0
- /package/{main → out/main}/rules/MissingMetadataDescription.d.ts +0 -0
- /package/{main → out/main}/rules/MissingMetadataDescription.js +0 -0
- /package/{main → out/main}/rules/MissingNullHandler.d.ts +0 -0
- /package/{main → out/main}/rules/MissingNullHandler.js +0 -0
- /package/{main → out/main}/rules/MissingRecordTriggerFilter.d.ts +0 -0
- /package/{main → out/main}/rules/MissingRecordTriggerFilter.js +0 -0
- /package/{main → out/main}/rules/ProcessBuilder.d.ts +0 -0
- /package/{main → out/main}/rules/ProcessBuilder.js +0 -0
- /package/{main → out/main}/rules/RecordIdAsString.d.ts +0 -0
- /package/{main → out/main}/rules/RecordIdAsString.js +0 -0
- /package/{main → out/main}/rules/RecursiveAfterUpdate.d.ts +0 -0
- /package/{main → out/main}/rules/RecursiveAfterUpdate.js +0 -0
- /package/{main → out/main}/rules/SOQLQueryInLoop.d.ts +0 -0
- /package/{main → out/main}/rules/SOQLQueryInLoop.js +0 -0
- /package/{main → out/main}/rules/SameRecordFieldUpdates.d.ts +0 -0
- /package/{main → out/main}/rules/SameRecordFieldUpdates.js +0 -0
- /package/{main → out/main}/rules/TransformInsteadOfLoop.d.ts +0 -0
- /package/{main → out/main}/rules/TransformInsteadOfLoop.js +0 -0
- /package/{main → out/main}/rules/TriggerOrder.d.ts +0 -0
- /package/{main → out/main}/rules/TriggerOrder.js +0 -0
- /package/{main → out/main}/rules/UnconnectedElement.d.ts +0 -0
- /package/{main → out/main}/rules/UnconnectedElement.js +0 -0
- /package/{main → out/main}/rules/UnsafeRunningContext.d.ts +0 -0
- /package/{main → out/main}/rules/UnsafeRunningContext.js +0 -0
- /package/{main → out/main}/rules/UnusedVariable.d.ts +0 -0
- /package/{main → out/main}/rules/UnusedVariable.js +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as core from "../src";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
import { describe, it, expect } from "@jest/globals";
|
|
5
|
+
|
|
6
|
+
describe("Autolayout", () => {
|
|
7
|
+
const example_uri = path.join(__dirname, "../../../example-flows/force-app/demo/Missing_Auto_Layout.flow-meta.xml");
|
|
8
|
+
const fixed_uri = path.join(__dirname, "../../../example-flows/force-app/testing/Outdated_API_Version_Fixed.flow-meta.xml");
|
|
9
|
+
|
|
10
|
+
it("should have a result when CanvasMode is set to FREE_FORM_CANVAS", async () => {
|
|
11
|
+
const flows = await core.parse([example_uri]);
|
|
12
|
+
const ruleConfig = {
|
|
13
|
+
ruleMode: "isolated",
|
|
14
|
+
rules: {
|
|
15
|
+
AutoLayout: {
|
|
16
|
+
severity: "error",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
22
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
23
|
+
expect(occurringResults).toHaveLength(1);
|
|
24
|
+
expect(occurringResults.find((res) => res.ruleName === "AutoLayout")).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should not have result when autolayout is configured", async () => {
|
|
28
|
+
const flows = await core.parse([fixed_uri]);
|
|
29
|
+
const ruleConfig = {
|
|
30
|
+
rules: {
|
|
31
|
+
ruleMode: "isolated",
|
|
32
|
+
AutoLayout: {
|
|
33
|
+
severity: "error",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
38
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
39
|
+
expect(occurringResults).toHaveLength(0);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { describe, expect, it } from "@jest/globals";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
import * as core from "../src";
|
|
5
|
+
|
|
6
|
+
describe("Rule Configurations ", () => {
|
|
7
|
+
const example_uri1 = path.join(__dirname, "../../../example-flows/force-app/demo/Unreachable_Element.flow-meta.xml");
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line jest/no-disabled-tests
|
|
10
|
+
it.skip("should use default when no configuration is provided", async () => {
|
|
11
|
+
const flows = await core.parse([example_uri1]);
|
|
12
|
+
const results: core.ScanResult[] = core.scan(flows, undefined);
|
|
13
|
+
const rules = [...core.getRules(), ...core.getBetaRules()];
|
|
14
|
+
const allRuleNames = rules.map((r) => r.name);
|
|
15
|
+
const allRuleResults = results[0].ruleResults.map((r) => r.ruleName);
|
|
16
|
+
expect(allRuleNames).toEqual(allRuleResults);
|
|
17
|
+
expect(results[0].ruleResults).toHaveLength(rules.length);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line jest/no-disabled-tests
|
|
21
|
+
it.skip("should use default when no rules are specified", async () => {
|
|
22
|
+
const flows = await core.parse([example_uri1]);
|
|
23
|
+
const ruleConfig = {
|
|
24
|
+
exceptions: {
|
|
25
|
+
CreateANewAccountWithChild: { DuplicateDMLOperation: ["ViewAccountId"] },
|
|
26
|
+
},
|
|
27
|
+
rules: {},
|
|
28
|
+
};
|
|
29
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
30
|
+
const rules = [...core.getRules(), ...core.getBetaRules()];
|
|
31
|
+
const allRuleNames = rules.map((r) => r.name);
|
|
32
|
+
const allRuleResults = results[0].ruleResults.map((r) => r.ruleName);
|
|
33
|
+
expect(allRuleNames).toEqual(allRuleResults);
|
|
34
|
+
expect(results[0].ruleResults).toHaveLength(rules.length);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("incorrect rule severity configurations are defaulted", async () => {
|
|
38
|
+
const flows = await core.parse([example_uri1]);
|
|
39
|
+
const ruleConfig = {
|
|
40
|
+
ruleMode: "isolated",
|
|
41
|
+
rules: {
|
|
42
|
+
MissingNullHandler: {
|
|
43
|
+
severity: "errorr",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
48
|
+
expect(results[0].ruleResults).toHaveLength(1);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("incorrect rule configurations are skipped", async () => {
|
|
52
|
+
const flows = await core.parse([example_uri1]);
|
|
53
|
+
jest.spyOn(global.console, "error").mockImplementation(() => {});
|
|
54
|
+
jest.spyOn(global.console, "log").mockImplementation(() => {});
|
|
55
|
+
|
|
56
|
+
const ruleConfig = {
|
|
57
|
+
exceptions: {
|
|
58
|
+
CreateANewAccountWithChild: { DuplicateDMLOperation: ["ViewAccountId"] },
|
|
59
|
+
},
|
|
60
|
+
ruleMode: "isolated",
|
|
61
|
+
rules: {
|
|
62
|
+
MissingNullHandler: {
|
|
63
|
+
severity: "error",
|
|
64
|
+
},
|
|
65
|
+
MissingNullHandler2: {
|
|
66
|
+
severity: "error",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
71
|
+
expect(results[0].ruleResults).toHaveLength(1);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("Multiple Expressions are individually checked", async () => {
|
|
75
|
+
const flows = await core.parse([example_uri1]);
|
|
76
|
+
const ruleConfig = {
|
|
77
|
+
ruleMode: "isolated",
|
|
78
|
+
rules: {
|
|
79
|
+
APIVersion: {
|
|
80
|
+
expression: ">50",
|
|
81
|
+
severity: "error",
|
|
82
|
+
},
|
|
83
|
+
CopyAPIName: {
|
|
84
|
+
severity: "error",
|
|
85
|
+
},
|
|
86
|
+
DMLStatementInLoop: {
|
|
87
|
+
severity: "error",
|
|
88
|
+
},
|
|
89
|
+
DuplicateDMLOperation: {
|
|
90
|
+
severity: "error",
|
|
91
|
+
},
|
|
92
|
+
FlowDescription: {
|
|
93
|
+
severity: "error",
|
|
94
|
+
},
|
|
95
|
+
FlowName: {
|
|
96
|
+
expression: "[A-Za-z0-9]+_[A-Za-z0-9]+",
|
|
97
|
+
severity: "error",
|
|
98
|
+
},
|
|
99
|
+
HardcodedId: {
|
|
100
|
+
severity: "error",
|
|
101
|
+
},
|
|
102
|
+
MissingFaultPath: {
|
|
103
|
+
severity: "error",
|
|
104
|
+
},
|
|
105
|
+
MissingNullHandler: {
|
|
106
|
+
severity: "error",
|
|
107
|
+
},
|
|
108
|
+
SOQLQueryInLoop: {
|
|
109
|
+
severity: "error",
|
|
110
|
+
},
|
|
111
|
+
UnconnectedElement: {
|
|
112
|
+
severity: "error",
|
|
113
|
+
},
|
|
114
|
+
UnusedVariable: {
|
|
115
|
+
severity: "error",
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
120
|
+
expect(results[0].ruleResults.find((r) => r.ruleName === "FlowName")?.occurs).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from "@jest/globals";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
import * as core from "../src";
|
|
5
|
+
import { MissingMetadataDescription } from "../src/main/rules/MissingMetadataDescription";
|
|
6
|
+
|
|
7
|
+
describe("Beta Rule Handling", () => {
|
|
8
|
+
const example_uri1 = path.join(__dirname, "../../../example-flows/force-app/demo/Unreachable_Element.flow-meta.xml");
|
|
9
|
+
|
|
10
|
+
it("should include beta rule when betaMode is true and no rules are specified", async () => {
|
|
11
|
+
const flows = await core.parse([example_uri1]);
|
|
12
|
+
const results = core.scan(flows, { betaMode: true, rules: {} });
|
|
13
|
+
|
|
14
|
+
// There should be at least 1 rule result (from beta rules)
|
|
15
|
+
expect(results[0].ruleResults.length).toBeGreaterThan(0);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should not include beta rule if betaMode is false even if rule exists in beta", async () => {
|
|
19
|
+
const flows = await core.parse([example_uri1]);
|
|
20
|
+
const results = core.scan(flows, { betaMode: false });
|
|
21
|
+
|
|
22
|
+
// If the rule is only in beta and betaMode is false, it should not appear
|
|
23
|
+
const ruleNames = results[0].ruleResults.map(r => r.ruleName);
|
|
24
|
+
expect(ruleNames).not.toContain("MissingMetadataDescription");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as core from "../src";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
import { describe, it, expect } from "@jest/globals";
|
|
5
|
+
|
|
6
|
+
describe("CopyAPIName ", () => {
|
|
7
|
+
const example_uri = path.join(__dirname, "../../../example-flows/force-app/demo/Unclear_API_Name.flow-meta.xml");
|
|
8
|
+
const fixed_uri = path.join(__dirname, "../../../example-flows/force-app/testing/Copy_API_Name_Fixed.flow-meta.xml");
|
|
9
|
+
|
|
10
|
+
it("CopyAPIName should have a result", async () => {
|
|
11
|
+
const flows = await core.parse([example_uri]);
|
|
12
|
+
const ruleConfig = {
|
|
13
|
+
ruleMode: "isolated",
|
|
14
|
+
rules: {
|
|
15
|
+
CopyAPIName: {
|
|
16
|
+
severity: "error",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
22
|
+
|
|
23
|
+
expect(results[0].ruleResults).toHaveLength(1);
|
|
24
|
+
expect(results[0].ruleResults[0].ruleName).toBe("CopyAPIName");
|
|
25
|
+
expect(results[0].ruleResults[0].occurs).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("CopyAPIName should have no result", async () => {
|
|
29
|
+
const flows = await core.parse([fixed_uri]);
|
|
30
|
+
const ruleConfig = {
|
|
31
|
+
ruleMode: "isolated",
|
|
32
|
+
rules: {
|
|
33
|
+
CopyAPIName: {
|
|
34
|
+
severity: "error",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
40
|
+
|
|
41
|
+
expect(results[0].ruleResults).toHaveLength(1);
|
|
42
|
+
expect(results[0].ruleResults[0].ruleName).toBe("CopyAPIName");
|
|
43
|
+
expect(results[0].ruleResults[0].occurs).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { describe, it, expect } from "@jest/globals";
|
|
3
|
+
|
|
4
|
+
import * as core from "../src";
|
|
5
|
+
import { CyclomaticComplexity } from "../src/main/rules/CyclomaticComplexity";
|
|
6
|
+
|
|
7
|
+
describe("CyclomaticComplexity ", () => {
|
|
8
|
+
const example_uri = path.join(__dirname, "../../../example-flows/force-app/demo/Excessive_Cyclomatic_Complexity.flow-meta.xml");
|
|
9
|
+
const other_uri = path.join(__dirname, "../../../example-flows/force-app/demo/SOQL_Query_In_A_Loop.flow-meta.xml");
|
|
10
|
+
const defaultConfig = {
|
|
11
|
+
ruleMode: "isolated",
|
|
12
|
+
rules: {
|
|
13
|
+
CyclomaticComplexity: {
|
|
14
|
+
severity: "error",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
it("should have a result when there are more than 25 decision options", async () => {
|
|
20
|
+
const flows = await core.parse([example_uri]);
|
|
21
|
+
debugger;
|
|
22
|
+
const results: core.ScanResult[] = core.scan(flows, defaultConfig);
|
|
23
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
24
|
+
expect(occurringResults).toHaveLength(1);
|
|
25
|
+
expect(occurringResults[0].ruleName).toBe("CyclomaticComplexity");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should have no result when value is below threshold", async () => {
|
|
29
|
+
const flows = await core.parse([other_uri]);
|
|
30
|
+
|
|
31
|
+
const results: core.ScanResult[] = core.scan(flows, defaultConfig);
|
|
32
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
33
|
+
expect(occurringResults).toHaveLength(0);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should have a result when value surpasses a configured threshold", async () => {
|
|
37
|
+
const flows = await core.parse([other_uri]);
|
|
38
|
+
const ruleConfig = {
|
|
39
|
+
ruleMode: "isolated",
|
|
40
|
+
rules: {
|
|
41
|
+
CyclomaticComplexity: {
|
|
42
|
+
threshold: 1,
|
|
43
|
+
severity: "error",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
49
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
50
|
+
expect(occurringResults).toHaveLength(1);
|
|
51
|
+
expect(occurringResults[0].ruleName).toBe("CyclomaticComplexity");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should correctly count the number of decisions and underlying rules one level", () => {
|
|
55
|
+
const sut = new CyclomaticComplexity();
|
|
56
|
+
const raw = {
|
|
57
|
+
elements: [
|
|
58
|
+
{
|
|
59
|
+
subtype: "decisions",
|
|
60
|
+
element: {
|
|
61
|
+
rules: [{}, {}, {}],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
} as Partial<core.Flow>;
|
|
66
|
+
const given = raw as core.Flow;
|
|
67
|
+
sut.execute(given);
|
|
68
|
+
expect(sut["cyclomaticComplexityUnit"]).toBe(5);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should correctly count the number of decisions and underlying rules multi level", () => {
|
|
72
|
+
const sut = new CyclomaticComplexity();
|
|
73
|
+
const raw = {
|
|
74
|
+
elements: [
|
|
75
|
+
{
|
|
76
|
+
subtype: "decisions",
|
|
77
|
+
element: {
|
|
78
|
+
rules: [{}, {}, {}],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{ subtype: "decisions", element: { rules: [{}] } },
|
|
82
|
+
],
|
|
83
|
+
} as Partial<core.Flow>;
|
|
84
|
+
const given = raw as core.Flow;
|
|
85
|
+
sut.execute(given);
|
|
86
|
+
expect(sut["cyclomaticComplexityUnit"]).toBe(7);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("should not throw an exception when theres no elements at all", () => {
|
|
90
|
+
const sut = new CyclomaticComplexity();
|
|
91
|
+
const raw = {
|
|
92
|
+
elements: [],
|
|
93
|
+
} as Partial<core.Flow>;
|
|
94
|
+
const given = raw as core.Flow;
|
|
95
|
+
expect(() => {
|
|
96
|
+
sut.execute(given);
|
|
97
|
+
}).not.toThrow();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("should not throw an exception when element isn't present", () => {
|
|
101
|
+
const sut = new CyclomaticComplexity();
|
|
102
|
+
const raw = {} as Partial<core.Flow>;
|
|
103
|
+
const given = raw as core.Flow;
|
|
104
|
+
expect(() => {
|
|
105
|
+
sut.execute(given);
|
|
106
|
+
}).not.toThrow();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("should correctly count the number of loops", () => {
|
|
110
|
+
const sut = new CyclomaticComplexity();
|
|
111
|
+
const raw = {
|
|
112
|
+
elements: [
|
|
113
|
+
{
|
|
114
|
+
subtype: "loops",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
subtype: "loops",
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
} as Partial<core.Flow>;
|
|
121
|
+
const given = raw as core.Flow;
|
|
122
|
+
sut.execute(given);
|
|
123
|
+
expect(sut["cyclomaticComplexityUnit"]).toBe(3);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it } from "@jest/globals";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
import * as core from "../src";
|
|
5
|
+
|
|
6
|
+
describe("DMLStatementInLoop ", () => {
|
|
7
|
+
const example_uri = path.join(__dirname, "../../../example-flows/force-app/demo/DML_Statement_In_A_Loop.flow-meta.xml");
|
|
8
|
+
const fixed_uri = path.join(__dirname, "../../../example-flows/force-app/testing/Duplicate_DML_Operation_Fixed.flow-meta.xml");
|
|
9
|
+
const config = {
|
|
10
|
+
ruleMode: "isolated",
|
|
11
|
+
rules: {
|
|
12
|
+
DMLStatementInLoop: {
|
|
13
|
+
severity: "error",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
it("there should be one result for the rule DMLStatementInLoop", async () => {
|
|
19
|
+
const flows = await core.parse([example_uri]);
|
|
20
|
+
const results: core.ScanResult[] = core.scan(flows, config);
|
|
21
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
22
|
+
expect(occurringResults).toHaveLength(1);
|
|
23
|
+
expect(occurringResults[0].ruleName).toBe("DMLStatementInLoop");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("there should be no result for the rule DMLStatementInLoop", async () => {
|
|
27
|
+
const flows = await core.parse([fixed_uri]);
|
|
28
|
+
const results: core.ScanResult[] = core.scan(flows, config);
|
|
29
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
30
|
+
expect(occurringResults).toHaveLength(0);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, it } from "@jest/globals";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
import * as core from "../src";
|
|
5
|
+
|
|
6
|
+
describe("DuplicateDMLOperation ", () => {
|
|
7
|
+
const example_uri = path.join(__dirname, "../../../example-flows/force-app/demo/Duplicate_DML_Operation.flow-meta.xml");
|
|
8
|
+
const fixed_uri = path.join(__dirname, "../../../example-flows/force-app/testing/Duplicate_DML_Operation_Fixed.flow-meta.xml");
|
|
9
|
+
|
|
10
|
+
it("should have 1 result in a flow with a DML statement inbetween screens ", async () => {
|
|
11
|
+
const flows = await core.parse([example_uri]);
|
|
12
|
+
|
|
13
|
+
const ruleConfig = {
|
|
14
|
+
ruleMode: "isolated",
|
|
15
|
+
rules: {
|
|
16
|
+
DuplicateDMLOperation: {
|
|
17
|
+
severity: "error",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
22
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
23
|
+
expect(occurringResults).toHaveLength(1);
|
|
24
|
+
expect(occurringResults[0].ruleName).toBe("DuplicateDMLOperation");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should have no results in the fixed example", async () => {
|
|
28
|
+
const flows = await core.parse([fixed_uri]);
|
|
29
|
+
|
|
30
|
+
const ruleConfig = {
|
|
31
|
+
ruleMode: "isolated",
|
|
32
|
+
rules: {
|
|
33
|
+
DuplicateDMLOperation: {
|
|
34
|
+
severity: "error",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
40
|
+
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
|
|
41
|
+
expect(occurringResults).toHaveLength(0);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as core from "../src";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { describe, it, expect } from "@jest/globals";
|
|
4
|
+
|
|
5
|
+
describe("Rule Enabled Flag", () => {
|
|
6
|
+
const example_uri = path.join(
|
|
7
|
+
__dirname,
|
|
8
|
+
"../../../example-flows/force-app/demo/Invalid_API_Version.flow-meta.xml"
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
it("should not run a rule when enabled is set to false", async () => {
|
|
12
|
+
const flows = await core.parse([example_uri]);
|
|
13
|
+
const ruleConfig = {
|
|
14
|
+
ruleMode: "isolated",
|
|
15
|
+
rules: {
|
|
16
|
+
APIVersion: {
|
|
17
|
+
enabled: false,
|
|
18
|
+
severity: "error",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
23
|
+
|
|
24
|
+
// No rules should be executed since the only rule is disabled
|
|
25
|
+
expect(results[0].ruleResults).toHaveLength(0);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should run other rules when one is disabled in merged mode", async () => {
|
|
29
|
+
const flows = await core.parse([example_uri]);
|
|
30
|
+
const ruleConfig = {
|
|
31
|
+
ruleMode: "merged",
|
|
32
|
+
rules: {
|
|
33
|
+
APIVersion: {
|
|
34
|
+
enabled: false,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
39
|
+
|
|
40
|
+
// Should have results from other default rules, but not APIVersion
|
|
41
|
+
expect(results[0].ruleResults.length).toBeGreaterThan(0);
|
|
42
|
+
const apiVersionResult = results[0].ruleResults.find(r => r.ruleName === "APIVersion");
|
|
43
|
+
expect(apiVersionResult).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should run a rule when enabled is explicitly set to true", async () => {
|
|
47
|
+
const flows = await core.parse([example_uri]);
|
|
48
|
+
const ruleConfig = {
|
|
49
|
+
ruleMode: "isolated",
|
|
50
|
+
rules: {
|
|
51
|
+
APIVersion: {
|
|
52
|
+
enabled: true,
|
|
53
|
+
severity: "error",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
const results: core.ScanResult[] = core.scan(flows, ruleConfig);
|
|
58
|
+
|
|
59
|
+
expect(results[0].ruleResults).toHaveLength(1);
|
|
60
|
+
expect(results[0].ruleResults[0].ruleName).toBe("APIVersion");
|
|
61
|
+
expect(results[0].ruleResults[0].occurs).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
});
|