AL icon indicating copy to clipboard operation
AL copied to clipboard

CodeCops not working properly

Open jmadrigalTCN opened this issue 1 month ago • 1 comments

1. Describe the bug Codecops do not behave properly in similar situations

2. To Reproduce Create this peace of code:

internal procedure updateWarehouseActivityLine(pWarehouseActivityLine: Record "Warehouse Activity Line") var warehouseActivityLine: Record "Warehouse Activity Line"; description: Text; begin if pWarehouseActivityLine."Source Document" <> pWarehouseActivityLine."Source Document"::"Sales Order" then exit; if getItemNoAndNovatixNo(pWarehouseActivityLine."Source No.", pWarehouseActivityLine."Source Line No.", description) then begin warehouseActivityLine.get(pWarehouseActivityLine."Activity Type", pWarehouseActivityLine."No.", pWarehouseActivityLine."Line No."); warehouseActivityLine.validate(Description, CopyStr(description, 1, MaxStrLen(warehouseActivityLine.Description))); warehouseActivityLine.Description := description; // <-------- Warning of posible overload warehouseActivityLine.Modify(true); end; end;

And codecop, in this line: warehouseActivityLine.Description := description; // <-------- Warning of posible overload gives a warning.

But if you do the very same peace of code

internal procedure updateWarehouseActivityLine(pWarehouseActivityLine: Record "Warehouse Activity Line") var warehouseActivityLine: Record "Warehouse Activity Line"; description: Text; begin if pWarehouseActivityLine."Source Document" <> pWarehouseActivityLine."Source Document"::"Sales Order" then exit; if getItemNoAndNovatixNo(pWarehouseActivityLine."Source No.", pWarehouseActivityLine."Source Line No.", description) then begin warehouseActivityLine.get(pWarehouseActivityLine."Activity Type", pWarehouseActivityLine."No.", pWarehouseActivityLine."Line No."); warehouseActivityLine.validate(Description, CopyStr(description, 1, MaxStrLen(warehouseActivityLine.Description))); warehouseActivityLine.Validate(Description,description); // <---------- No warning warehouseActivityLine.Modify(true); end; end;

But you change the line with the warning with:

warehouseActivityLine.Validate(Description,description); // <---------- No warning

Namely, instead rec.field := value, rec.validate(field,value) CodeCops, do not give any warning

  • AL Language: 16.2.1869542

  • Visual Studio Code: Version: 1.106.3 (system setup) Commit: bf9252a2fb45be6893dd8870c0bf37e2e1766d61 Date: 2025-11-25T22:28:18.024Z Electron: 37.7.0 ElectronBuildId: 12781156 Chromium: 138.0.7204.251 Node.js: 22.20.0 V8: 13.8.258.32-electron.0 OS: Windows_NT x64 10.0.26200

  • Business Central: Not relevant

  • List of Visual Studio Code extensions that you have installed:

  • AL LAnguaje

  • Operating System:

    • [X] Windows
    • [ ] Linux
    • [ ] MacOS

Please remember to do the following:

  • [ ] Search the issue repository to ensure you are reporting a new issue

  • [ ] Reproduce the issue after disabling all extensions except the AL Language extension

  • [ ] Simplify your code around the issue to better isolate the problem

Internal work item: AB#615683

jmadrigalTCN avatar Dec 05 '25 10:12 jmadrigalTCN