Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.
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
2 changes: 2 additions & 0 deletions assets/example-flows/.flow-scanner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ rules:
severity: error
UnusedVariable:
severity: error
MissingMetadataDescription:
severity: warning
exceptions:
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<actionCalls>
<name>create_account_manually</name>
<label>create account manually</label>
<locationX>440</locationX>
<locationY>242</locationY>
<actionName>FeedItem.NewTaskFromFeedItem</actionName>
<actionType>quickAction</actionType>
<flowTransactionModel>CurrentTransaction</flowTransactionModel>
<inputParameters>
<name>contextId</name>
<value>
<elementReference>$User.Id</elementReference>
</value>
</inputParameters>
<nameSegment>FeedItem.NewTaskFromFeedItem</nameSegment>
<versionSegment>1</versionSegment>
</actionCalls>
<apiVersion>58.0</apiVersion>
<description>This flow demonstrates a violation of the rule &quot;Missing Metadata Description&quot;.</description>
<environments>Default</environments>
<interviewLabel>Missing Metadata Description {!$Flow.CurrentDateTime}</interviewLabel>
<label>Missing Metadata Description</label>
<processMetadataValues>
<name>BuilderType</name>
<value>
<stringValue>LightningFlowBuilder</stringValue>
</value>
</processMetadataValues>
<processMetadataValues>
<name>CanvasMode</name>
<value>
<stringValue>AUTO_LAYOUT_CANVAS</stringValue>
</value>
</processMetadataValues>
<processMetadataValues>
<name>OriginBuilderType</name>
<value>
<stringValue>LightningFlowBuilder</stringValue>
</value>
</processMetadataValues>
<processType>AutoLaunchedFlow</processType>
<recordCreates>
<name>create_Test_Account</name>
<label>create Test Account</label>
<locationX>176</locationX>
<locationY>134</locationY>
<faultConnector>
<targetReference>create_account_manually</targetReference>
</faultConnector>
<inputAssignments>
<field>Name</field>
<value>
<stringValue>Test Account</stringValue>
</value>
</inputAssignments>
<object>Account</object>
<storeOutputAutomatically>true</storeOutputAutomatically>
</recordCreates>
<start>
<locationX>50</locationX>
<locationY>0</locationY>
<connector>
<targetReference>create_Test_Account</targetReference>
</connector>
</start>
<status>Active</status>
<variables>
<name>Account</name>
<dataType>SObject</dataType>
<isCollection>false</isCollection>
<isInput>false</isInput>
<isOutput>false</isOutput>
<objectType>Account</objectType>
</variables>
<triggerOrder>10</triggerOrder>
</Flow>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<actionCalls>
<name>create_account_manually</name>
<label>create account manually</label>
<description>create account description</description>
<locationX>440</locationX>
<locationY>242</locationY>
<actionName>FeedItem.NewTaskFromFeedItem</actionName>
Expand Down Expand Up @@ -44,6 +45,7 @@
<recordCreates>
<name>create_Test_Account</name>
<label>create Test Account</label>
<description>create Test Account description</description>
<locationX>176</locationX>
<locationY>134</locationY>
<faultConnector>
Expand Down Expand Up @@ -74,6 +76,7 @@
<status>Active</status>
<variables>
<name>Account</name>
<description>Account description</description>
<dataType>SObject</dataType>
<isCollection>false</isCollection>
<isInput>false</isInput>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<actionCalls>
<name>log_call</name>
<label>log call</label>
<description>description</description>
<locationX>176</locationX>
<locationY>134</locationY>
<actionName>LogACall</actionName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<actionCalls>
<name>dosomethingelse</name>
<label>dosomethingelse</label>
<description>description</description>
<locationX>440</locationX>
<locationY>242</locationY>
<actionName>NewTask</actionName>
Expand All @@ -20,6 +21,7 @@
<actionCalls>
<name>log_call</name>
<label>log call</label>
<description>description</description>
<locationX>176</locationX>
<locationY>134</locationY>
<actionName>LogACall</actionName>
Expand Down
41 changes: 41 additions & 0 deletions src/main/rules/MissingMetadataDescription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { IRuleDefinition } from "../interfaces/IRuleDefinition";
import * as core from "../internals/internals";
import { RuleCommon } from "../models/RuleCommon";

export class MissingMetadataDescription extends RuleCommon implements IRuleDefinition {
constructor() {
super({
autoFixable: false,
description: "Every element must have a meaningful description",
docRefs: [],
isConfigurable: false,
label: "Missing Metadata Description",
name: "MissingMetadataDescription",
supportedTypes: core.FlowType.allTypes(),
});
}

protected check(
flow: core.Flow,
_options: object | undefined,
_suppression: Set<string>
): core.Violation[] {
const violations: core.Violation[] = [];

flow.elements
.filter((elem) => {
if (
elem.metaType !== "metadata" &&
!elem.element["description"] &&
elem.subtype !== "start"
) {
return elem;
}
})
.forEach((elem) => {
return violations.push(new core.Violation(elem));
});

return violations;
}
}
2 changes: 2 additions & 0 deletions src/main/store/DefaultRuleStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { TriggerOrder } from "../rules/TriggerOrder";
import { UnconnectedElement } from "../rules/UnconnectedElement";
import { UnsafeRunningContext } from "../rules/UnsafeRunningContext";
import { UnusedVariable } from "../rules/UnusedVariable";
import { MissingMetadataDescription } from "../rules/MissingMetadataDescription";

export const DefaultRuleStore: object = {
ActionCallsInLoop,
Expand All @@ -46,6 +47,7 @@ export const DefaultRuleStore: object = {
UnconnectedElement,
UnsafeRunningContext,
UnusedVariable,
MissingMetadataDescription,
};

export const BetaRuleStore: object = {
Expand Down
16 changes: 16 additions & 0 deletions tests/MissingMetadataDescription.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as core from "../src";
import * as path from "path";

import { describe, it, expect } from "@jest/globals";

describe("HardcodedId", () => {
const example_uri = path.join(__dirname, "../assets/example-flows/force-app/main/default/flows/Missing_Metadata_Description.flow-meta.xml");

it("there should be 1 results for the rule MissingMetadataDescription", async () => {
const flows = await core.parse([example_uri]);
const results: core.ScanResult[] = core.scan(flows);
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
expect(occurringResults).toHaveLength(1);
expect(occurringResults.filter(ruleName => ruleName.ruleName === "MissingMetadataDescription")[0].ruleName).toBe("MissingMetadataDescription");
});
});
Loading