Lightning-Flow-Scanner / lightning-flow-scanner-core

A rule engine capable of conducting static analysis on the metadata associated with Salesforce Lightning Flows, Process Builders, and Workflows.
https://www.npmjs.com/package/lightning-flow-scanner-core
MIT License
27 stars 9 forks source link

Default values/assignements 'MissingNullHandler' rule #38

Closed TonyCrousty closed 11 months ago

TonyCrousty commented 1 year ago

Hi, in the flow I scanned, it looks 3 cases of false positive matched :

Get_all_opport (recordLookups)

Indeed, there is no decision on 'null' value of the result, but a variable is assigned with a count on the collection. If the collection is null, then the count is '0'. And a decision manages this case. Assignement extract :

    <assignments>
        <description>Nombre d&apos;offres créées. Si aucune offre trouvée (Get_all_opport = null), la variable est initialisée à 0.</description>
        <name>Nb_opport_found</name>
        <label>Nb opport found</label>
        <locationX>578</locationX>
        <locationY>1682</locationY>
        <assignmentItems>
            <assignToReference>nbExistingOpportFound</assignToReference>
            <operator>AssignCount</operator>
            <value>
                <elementReference>Get_all_opport</elementReference>
            </value>
        </assignmentItems>
        <connector>
            <targetReference>Offre</targetReference>
        </connector>
    </assignments>

Get_etab_from_Rubis (recordLookups)

is a recordLookup with a outputReference. This recordLookup is immediately followed with a 'null' check decision

Initial_lead_data (recordLookups)

same case than previous one. The only difference is the here, the 'null' check in the decision is part of several other conditions.

I can provide the full flow source if needed.

Regards,

RubenHalman commented 1 year ago

Hi @TonyCrousty , thank you very much for making us aware of these. The first one is clear to me, but the other two I'm not so sure about. If it is possible to give me one of those full flows in a way you mask any confidential information that would be ideal. You can also mail them to me via halmandevlabs@gmail.com

TonyCrousty commented 1 year ago

Hi, just mailed you the complete flow source

RubenHalman commented 1 year ago

@TonyCrousty We have resolved bugs in the MissingNullHandler rule in the latest version, v2.11. However, the first lookup 'Get_all_opport' is still coming up as a violation. We will definitely still aim to enhance the rule so to support these types of use cases where a default value is assigned, but for now I recommend you define it as an exception.

RubenHalman commented 1 year ago

@TonyCrousty do you know how to define the exception?

RubenHalman commented 11 months ago

For now I am closing this issue. @TonyCrousty please do let us know if you find the current solution acceptable