BusinessCentral.LinterCop icon indicating copy to clipboard operation
BusinessCentral.LinterCop copied to clipboard

LC0051: Raise diagnostic on Text.IncStr(Text) Method

Open Arthurvdv opened this issue 1 month ago • 1 comments

Currently there's no diagnostic raised when using the Text.IncStr(Text) Method, where the outcome of the method could increase the length with one extra character.

codeunit 50100 MyCodeunit
{
    procedure MyProcedure()
    var
        MyTable: Record MyTable;
        SomeVariable: Code[20];
    begin
        MyTable.Validate(MyField, IncStr(SomeVariable)); // This could return a Text with a length of 21, causing an overflow
    end;
}

table 50100 MyTable
{
    fields
    {
        field(1; MyField; Code[20]) { }
    }
}

Arthurvdv avatar Jan 30 '25 13:01 Arthurvdv