Skip to content

Latest commit

 

History

History
60 lines (45 loc) · 1.73 KB

FunctionReturnsSamePrimitive.md

File metadata and controls

60 lines (45 loc) · 1.73 KB

The function always returns the same primitive value (FunctionReturnsSamePrimitive)

Description

A function should not return the same primitive value. If the result of the function isn't use into code, then you need the function rewrite to the procedure.

Examples

Bad:

Function CheckString(Val RowTable)

    If ItsGoodString(RowTable) Then
        ActionGood();
        Return True;
    ElsIf ItsNodBadString(RowTable) Then
        ActionNoBad();
        Return True;
     Else
        Return True;
    EndIf;

EndFunction

Good:

Function CheckString(Val RowTable)

    If ItsGoodString(RowTable) Then
        ActionGood();
    ElsIf ItsNodBadString(RowTable) Then
        ActionNoBad();
    Else
        ActionElse();
    EndIf;

EndFunction

Nuances

Attachable functions excluded from the scan. Example:

Function Attachable_RandomAction(Command)

    If ValueIsFilled(CurrentDate) Then
        Return Undefined;
    EndIf;

    Return Undefined;

EndFunction

Sources